Implement off-main-thread Layout (frame construction and reflow)

Assigned to



3 years ago
3 years ago


(Reporter: kanru, Assigned: kanru)


Firefox Tracking Flags

(Not tracked)




3 years ago
Rationale: multi-core devices are becoming more common. JavaScript on main-thread often has to compete CPU time with layout & rendering. To improve app startup / first page load speed.

Approach: move layout to per-document thread with following conditions,

 1) Any modification to DOM is blocked by the Layout thread. Every ContentInserted, ContentAppended and ContentRemoved notification has to wait the layout thread finishes its previous task.

 2) Any modification to Style is also blocked by the Layout thread.

 3) Any scripts that triggers synchronous reflow (eg. read clientWidth) should also be blocked.

 4) When Layout thread has to use objects on the main thread, it should do it synchronously. For example, post a task to the main thread and wait until the task signals it's finished. In order to avoid dead lock, main thread will always execute the layout task even if it's blocked.

In the future we could remove the dependency between layout and main thread iteratively and loose above conditions.
You need to log in before you can comment on or make changes to this bug.