servo/components
Martin Robinson 9c0561536d
script: Do not run layout in a thread (#31346)
* script: Do not run layout in a thread

Instead of spawning a thread for layout that almost always runs
synchronously with script, simply run layout in the script thread.

This is a resurrection of #28708, taking just the bits that remove the
layout thread. It's a complex change and thus is just a first step
toward cleaning up the interface between script and layout. Messages are
still passed from script to layout via a `process()` method and script
proxies some messages to layout from other threads as well.

Big changes:

1. Layout is created in the script thread on Document load, thus every
   live document is guaranteed to have a layout. This isn't completely
   hidden in the interface, but we can safely `unwrap()` on a Document's
   layout.
2. Layout configuration is abstracted away into a LayoutConfig struct
   and the LayoutFactory is a struct passed around by the Constellation.
   This is to avoid having to monomorphize the entire script thread
   for each layout.
3. Instead of having the Constellation block on the layout thread to
   figure out the current epoch and whether there are pending web fonts
   loading, updates are sent synchronously to the Constellation when
   rendering to a screenshot. This practically only used by the WPT.

A couple tests start to fail, which is probably inevitable since removing
the layout thread has introduced timing changes in "exit after load" and
screenshot behavior.

Co-authored-by: Josh Matthews <josh@joshmatthews.net>

* Update test expectations

* Fix some issues found during review

* Clarify some comments

* Address review comments

---------

Co-authored-by: Josh Matthews <josh@joshmatthews.net>
2024-02-23 08:14:10 +00:00
..
allocator Preliminary Android build support (#31086) 2024-01-22 13:00:15 +00:00
atoms Further changes required by Servo 2023-11-06 09:35:57 +01:00
background_hang_monitor BHM: Support aarch64 for Mac sampler (#31298) 2024-02-09 13:55:28 +00:00
bluetooth Preliminary Android build support (#31086) 2024-01-22 13:00:15 +00:00
canvas canvas2d: Implement .reset() (#31258) 2024-02-05 08:53:00 +00:00
compositing script: Do not run layout in a thread (#31346) 2024-02-23 08:14:10 +00:00
config script: implement navigator.hardwareConcurrency (#31268) 2024-02-07 18:41:58 +00:00
config_plugins Remove use of proc_macro_diagnostics feature (#30745) 2023-11-17 10:36:09 +00:00
constellation script: Do not run layout in a thread (#31346) 2024-02-23 08:14:10 +00:00
deny_public_fields Strict import formatting (grouping and granularity) (#30325) 2023-09-11 19:16:54 +00:00
derive_common Revert remaining Stylo changes (#31408) 2024-02-22 09:56:26 +00:00
devtools rustdoc: Fix many rustdoc errors (#31147) 2024-01-22 13:13:48 +00:00
dom_struct Replace script_plugins with a clippy like rustc driver (named crown) (#30508) 2023-12-01 15:50:52 +00:00
domobject_derive Strict import formatting (grouping and granularity) (#30325) 2023-09-11 19:16:54 +00:00
geometry deps: Stop vendoring WebRender (#31212) 2024-01-30 08:10:13 +00:00
gfx script: Do not run layout in a thread (#31346) 2024-02-23 08:14:10 +00:00
hyper_serde Revert "Replace time with std::time in components/net (#31079)" (#31120) 2024-01-18 15:10:48 +00:00
jstraceable_derive Update to syn 2 where possible (#30387) 2023-09-19 15:57:37 +00:00
layout script: Do not run layout in a thread (#31346) 2024-02-23 08:14:10 +00:00
layout_2020 script: Do not run layout in a thread (#31346) 2024-02-23 08:14:10 +00:00
layout_thread script: Do not run layout in a thread (#31346) 2024-02-23 08:14:10 +00:00
layout_thread_2020 script: Do not run layout in a thread (#31346) 2024-02-23 08:14:10 +00:00
malloc_size_of Revert remaining Stylo changes (#31408) 2024-02-22 09:56:26 +00:00
media chore: re-export servo-media types (#31180) 2024-01-26 23:25:38 +00:00
metrics script: Do not run layout in a thread (#31346) 2024-02-23 08:14:10 +00:00
net script: Do not run layout in a thread (#31346) 2024-02-23 08:14:10 +00:00
pixels Strict import formatting (grouping and granularity) (#30325) 2023-09-11 19:16:54 +00:00
profile Preliminary Android build support (#31086) 2024-01-22 13:00:15 +00:00
rand Strict import formatting (grouping and granularity) (#30325) 2023-09-11 19:16:54 +00:00
range Strict import formatting (grouping and granularity) (#30325) 2023-09-11 19:16:54 +00:00
remutex rustdoc: Fix many rustdoc errors (#31147) 2024-01-22 13:13:48 +00:00
script script: Do not run layout in a thread (#31346) 2024-02-23 08:14:10 +00:00
selectors Revert remaining Stylo changes (#31408) 2024-02-22 09:56:26 +00:00
servo script: Do not run layout in a thread (#31346) 2024-02-23 08:14:10 +00:00
servo_arc Revert changes to servo_arc, style_derive, and style_traits (#31387) 2024-02-22 04:40:37 +00:00
shared script: Do not run layout in a thread (#31346) 2024-02-23 08:14:10 +00:00
size_of_test Further changes required by Servo 2023-08-16 17:46:41 +02:00
style script: Do not run layout in a thread (#31346) 2024-02-23 08:14:10 +00:00
style_derive Revert changes to servo_arc, style_derive, and style_traits (#31387) 2024-02-22 04:40:37 +00:00
style_static_prefs style: Add a static_prefs implementation (#31351) 2024-02-14 17:02:13 +00:00
style_traits Revert changes to servo_arc, style_derive, and style_traits (#31387) 2024-02-22 04:40:37 +00:00
to_shmem style: Reduce Servo's diff with upstream to_shmem (#31349) 2024-02-14 11:17:00 +00:00
to_shmem_derive style: Reduce Servo's diff with upstream to_shmem (#31349) 2024-02-14 11:17:00 +00:00
url style: Remove dependency on servo_url (#31358) 2024-02-16 11:56:35 +00:00
webdriver_server deps: Remove unused crate dependencies (#31185) 2024-01-26 23:18:26 +00:00
webgpu Fix failed request for adapter when not available (#31002) 2024-01-09 09:12:53 +00:00