What is a reflow?
Reflow is the process by which the geometry of the layout engine’s formatting objects are computed. Last week, I was searching around and stumbled on these really cool visuals of what a reflow looks like. If you’re a visual person, you will dig these:
Reflow of Mozilla.org:
Reflow of Google.co.jp:
Reflow of Wikipedia:
If you produced these, kudos! If you know how to produce such things, please drop a note!
Update:
Satoshi Ueyama is the author of this cool demo. He sent Gen a note on how he did it:
First, he builds Mozilla so that the layout portions (nsIFrame::SetRect, nsIFrame::SetSize, nsIFrame;;SetPosition, PresShell::DoReflow, etc) are set to output to the log file.
He then gives an example of the log of each of the frame movements from Reflow:
{"event": "MoveFrame", "frame": {"address": "0x04FE41A8", "type": "TextFrame", "content": {"address": "0x05014150", "type": "other"}, "rect": {"x": 0, "y": 0, "w": 0, "h": 0}}}, {"event": "MoveFrame", "frame": {"address": "0x04FE41A8", "type": "TextFrame", "content": {"address": "0x05014150", "type": "other"}, "rect": {"x": 0, "y": 0, "w": 0, "h": 0}}},Here is an example of dump from the termination of the tree structure.
{"event": "FinishReflow", frame: Â {"address": "0x04FE3E28", "type": "ViewportFrame", "content": null, "children":[ Â Â Â Â {"address": "0x04FE4000", "type": "ScrollFrame", "content": {"address": "0x04FD4858", "type": "element", "tagName": "HTML"}, "children":[ Â Â Â Â Â Â Â Â {"address": "0x04FE43EC", "type": "ScrollbarFrame", "content": {"address": "0x04FFEFF8", "type": "element", "tagName": "scrollbar"}, "children":[ Â Â Â Â Â Â Â Â Â Â Â Â {"address": "0x04FE4578", "type": "BoxFrame", "content": {"address": "0x04FFE0F8", "type": "element", "tagName": "xul:scrollbarbutton"} } Â Â Â Â , Â Â Â Â Â Â {"address": "0x04FE47BC", "type": "sliderFrame", "content": {"address": "0x04FFE278", "type": "element", "tagName": "xul:slider"}, "children":[ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â {"address": "0x05004E6C", "type": "BoxFrame", "content": {"address": "0x050030E8", "type": "element", "tagName": "xul:thumb"}, "children":[ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â {"address": "0x05004FDC", "type": "BoxFrame", "content": {"address": "0x050013F0", "type": "element", "tagName": "xul:gripper"} } Â Â Â Â Â Â Â Â ] }He then makes the video animation (for Google Video he suggests Ruby+Ruby/SDL, for the video from Mozilla 24 he used C+++Direct3d.) As memory address is outputted to the log each frame can be distinct.
The behavior of each frame in chronological order is reproducible as the log has each frame’s memory. (For instance, in tracking the frame “address”:”0x04FE41A8″, you can reproduce that frame’s behavior chronologically.
UPDATE:
New links for the videos (thanks Gen!):
http://www.youtube.com/watch?v=nJtBUHyNBxs
http://www.youtube.com/watch?v=ZTnIxIA5KGw
http://www.youtube.com/watch?v=dndeRnzkJDU
Trackbacks & Pingbacks
- Reflow Visualisation » randomosity » Blog Archive Reflow Visualisation »
- Browser rendering and web performance: Reflow | Bitcurrent
- Top Posts « WordPress.com
- Un gaditano en Silicon Valley » » Reflow
- kann hier jemand Polnisch? - XHTMLforum
- Giavasan » Special FX
- Create A Website » Blog Archive » Reflow
- O que é reflow? | fabioricotta - SEO, Blogs, Google e um pouco mais
- Comment les navigateurs chargent les pages des sites Internet
- schonleben mittendrin: subjektiv, subversiv! » Blog Archive » Google Reflow
- Como o navegador trabalha na internet? - Google Discovery
- ¿Cómo piensa un navegador?
- Mobimeet - Reflows
- » Reflow
- 形象化的reflow - æ ·å¼ä¹‹ç¾Ž
- What is a reflow? « Science Notes
- gregs » Blog Archive » Reflow
- Something Unimportant » Blog Archive » What is a reflow?
- Weekly Links: ASP.NET MVC, .NET, ADO.NET Data Services, Silverlight, WPF… | Code-Inside Blog International
- Mozilla in Asia » Blog Archive » 3D in JavaScript and Canvas
- Mozilla in Asia » Blog Archive » how to make your own Gecko reflow video
Someone totally needs to make that into a Firefox extension.
Wow. That’s awesome.
That’s awesome. I second post #1
Interesting that it’s reflowing the whole thing twice for mozilla.org and wikipedia, but *not* google.
Woah, it’s awesome, seriously. Who made these? Any chance for higher resolution ones? Or even better an interactive thingie (1st post, further seconded.)
That is just spectacular. I am dying to find out who was responsible.
Wow, someone please add that to Firebug or WebDeveloper extension! I’d love to see how the reflow unfolds on my website and if there’d be anyway I could then optimise it for faster rendering.
glandium: I think that is because Mozilla and Wikipedia becomes larger then fit on screen so the scrollbar needs to be placed on the right. And therefor there is a second reflow.
Maybe that is because google doesn’t use CSS?
f this s, Opera draws pages as soon as data comes in, does not hide the layout until it’s fully generated.
I think it’s animations related to this talk at Shibuya.js:
http://video.google.com/videoplay?docid=4146973749385284875
This seems to be the guy who made it:
http://gyu.que.jp/sjs2007/
Guessing it’s done in Processing, since he has some other stuff done in that too.
Those are cool. A firefox extension would be pretty cool!
Interesting. I completely agree with Dan above… it’d be great if this were a Firefox extension.
It looks like this animation captures all calls to SetRect/SetPosition/SetSize on frames or something along those lines. At least that’s what it looks like to me given how it’s handling the floats and the inline layout. Doing that from an extension would be quite difficult, actually, and any setup that _did_ do it would have a pretty hefty impact on layout performance.
Awesome visual demos. Thank you!
This is awesome, seeing the process slowed down and outlined like this. A firefox extension would be great!
@16:
You wouldn’t need to do it real time; you would just need to log the calls to those functions somewhere so that you can parse them and create an animation (that said it would still be difficult from an extension I think; you may want a custom build of the browser instead).
Seeing as almost all pages have vertical scrolling, it seems like a sensible optimisation to render assuming a scrollbar first, and then if it isn’t required, to reflow.
In fact I remember that Opera 6 or so always rendered with a scrollbar visible. At the time I assumed it was to avoid the content jumping around on sites where some pages have scrollbars and some don’t. But maybe it was an optimisation. Opera has always focused on speed more than the other browsers.
I like it.
That is all.
(Apologies I’m not very tech savvy and there cannot make this comment more interesting)
Looks cool!
I like the pretty colors… Just kidding. Seriously, I AM a visual person, and I LOVE watching technical things like this unfold visually before me. Great videos, thanks a lot for sharing!
Thanks. I don’t know much about computers but I really thought that was so cool.
Check out Timelapse CSS by Mattew Buchanan:
http://matthewbuchanan.name/post/33504871/timelapse-css
> Which makes you wonder why the entire mozilla
> page needs to be reflown for that since it has
> fixed margins.
Wow, from 3 small, lo rez videos we already have a possible bug.
Interesting how information presented in a new way helps us all understand a complex process.
monk.e.boy
Doug- that was at our Mozilla 24 event, albeit in the Tokyo part of the event.
That was a lot of good info.
dave, http://www.thehistorybluff.com
I can’t see anything? Sorry!
I want the tool that makes these animations, it would be SOOO helpfull when developing websites!
I might finally understand floats if that was an extension.
awesome posts
thanks dear
Fantastic rendering demonstration. Its only a matter of time before something like this gets pushed out into the open source domain.
Bill, you’d definitely need a custom build (not possible to hook into those layout guts from an extension). And I wasn’t talking about doing anything in realtime: just logging those function calls might be expensive enough to noticeably affect layout performance. Those functions are called a _lot_.
Excellent! I didn’t get why on the first video (Mozilla.org reflow) it went over the whole thing two times?
That is just insane!!! Fantastic demo, should totally be made into a extension.