Repository navigation
Upgrade to Stylo with layout.unimplemented replaced - #48915
Merged
Merged
Conversation
nicoburns
force-pushed
the
update-stylo-prefs
branch
from
October 14, 2026 19:18
c7aaf12 to
2173ffc
Compare
|
🔨 Triggering try run (#38622805704) for Linux (WPT) |
nicoburns
force-pushed
the
update-stylo-prefs
branch
3 times, most recently
from
October 14, 2026 19:43
ac24ae6 to
005306a
Compare
|
Test results for linux-wpt from try job (#38622805704): Flaky unexpected result (12)
Stable unexpected results that are known to be intermittent (8)
|
|
✨ Try run (#38622805704) succeeded. |
Loirooriol
approved these changes
Oct 14, 2026
Signed-off-by: Nico Burns <[email protected]>
nicoburns
force-pushed
the
update-stylo-prefs
branch
from
October 14, 2026 22:35
005306a to
f593f9d
Compare
nicoburns
enabled auto-merge
October 14, 2026 22:35
shubhamg13
pushed a commit
to shubhamg13/stylo
that referenced
this pull request
Oct 15, 2026
…with Gecko convention. (servo#492) This PR makes two changes: - Splits the `layout.unimplemented` into individual prefs for groups of related properties - Renames some prefs (adds `.css` to them) to align with Gecko convention (other Servo prefs already followed this). Servo PR: servo/servo#48915 ### `layout.unimplemented` properties moved under existing prefs | Pref | Additional properties | |---|---| | `layout.css.anchor-positioning.enabled` | `position-area`, `position-try-fallbacks` | | `layout.css.scroll-driven-animations.enabled` | `animation-timeline`, `animation-range-start`, `animation-range-end` | ### `layout.unimplemented` properties moved under new prefs | Pref | Properties affected | |---|---| | `layout.css.appearance.enabled` | `appearance` | | `layout.css.backdrop-filter.enabled` | `backdrop-filter` | | `layout.css.contain.enabled` | `contain` | | `layout.css.corner-shape.enabled` | `corner-{top-left,top-right,bottom-right,bottom-left,start-start,start-end,end-start,end-end}-shape`, `corner-shape`, `corner-{top,right,bottom,left,block-start,block-end,inline-start,inline-end}-shape` | | `layout.css.counters.enabled` | `counter-increment`, `counter-reset` | | `layout.css.font-size-adjust.enabled` | `font-size-adjust` | | `layout.css.forced-color-adjust.enabled` | `forced-color-adjust` | | `layout.css.masking.enabled` | `mask-image`, `mask-position-x`, `mask-position-y`, `mask-repeat`, `mask-size`, `mask-type`, `mask-mode`, `mask-clip`, `mask-origin`, `mask-composite`, `mask`, `mask-position` | | `layout.css.math-properties.enabled` | `math-depth`, `math-style` | | `layout.css.motion-path.enabled` | `offset-path` | | `layout.css.overscroll-behavior.enabled` | `overscroll-behavior-{x,y,block,inline}`, `overscroll-behavior` | | `layout.css.scroll-behavior.enabled` | `scroll-behavior` | | `layout.css.scrollbar-styling.enabled` | `scrollbar-color`, `scrollbar-width` | | `layout.css.text-decoration-inset.enabled` | `text-decoration-inset` | | `layout.css.text-overflow.enabled` | `text-overflow` | | `layout.css.text-underline.enabled` | `text-underline-offset`, `text-underline-position` | | `layout.css.view-transitions.enabled` | `view-transition-name`, `view-transition-class` | | `layout.css.writing-mode.text-orientation.enabled` | `text-orientation` | | `layout.css.zoom.enabled` | `zoom` | ### Renamed prefs | Old pref name | New pref name | | :--- | :--- | | `layout.columns.enabled` | `layout.css.columns.enabled` | | `layout.container-queries.enabled` | `layout.css.container-queries.enabled` | | `layout.variable_fonts.enabled` | `layout.css.font-variations.enabled` | | `layout.writing-mode.enabled` | `layout.css.writing-mode.enabled` | | `layout.writing-mode.sideways.enabled` | `layout.css.writing-mode.sideways.enabled` | | `layout.flexbox.balance` | `layout.css.flexbox-balance.enabled` |
jschwe
added a commit
to openharmony-rs/servo-ohos
that referenced
this pull request
Oct 22, 2026
…r is full When its player has enough data, a media element cancels a fetch with range support, to restart it with a Range request once the player needs data again, and keeps queueing the data of a fetch without range support, up to 32 MiB, before it cancels it and fetches the resource from its start again. Every restart costs a request, on HTTP/1.1 a new connection, and the bytes that were in flight. Ask net to suspend a fetch that is read from the network instead, and queue the data that was in flight. Net answers whether it suspended the fetch. If it did, flow control holds back the server, the download is suspended (NETWORK_IDLE and suspend, then NETWORK_LOADING once it resumes, and no progress events meanwhile), and once the player needs data, the same fetch resumes and the queue drains. If it did not, as for a cache hit or when two fetches to the origin are suspended already, the fetch backs off as before; so it does if the answer is lost, and it is resumed in case net suspended it. Responses that are not read from the network are handled as before, and the cap on the queue stays for data that keeps arriving. When a fetch completes, progress, then NETWORK_IDLE and suspend follow, also if the fetch was suspended. A fetch with range support that stays suspended for media_fetch_suspension_timeout_ms (30 s) is cancelled, to restart where the player stopped once it needs data again, so that an element paused for long does not hold a connection, which servers would time out anyway. A fetch without range support stays suspended, since its restart would fetch the resource from its start again, until net gives up on it after network_fetch_suspend_timeout_ms (60 s). Such a server, and net, end the fetch: net with a network error, which ran the fatal steps (MEDIA_ERR_NETWORK, "If the connection is interrupted after some media data has been received"), and a closed connection like a complete body, so the stream ended early. So if a fetch that was suspended ends with a network error, or with fewer bytes than its Content-Length, restart it at the byte where the player stopped, with a Range request, which a server without range support answers from the start of the resource, whose bytes before that position are discarded as after a seek: at once if the player accepts data, or else once it needs data again. A restart past the end of the resource, which the server answers with 416 or which the length of the resource tells, ends the stream, as when the server's Content-Length was too large; so does a restart without range support whose body ends without an error where the player stopped. Any other restart that ends early before it delivers data runs the fatal steps: net ends a body that loses its connection without an error. A restart that delivered data may be restarted again, so a fetch is only restarted while it makes progress. The Content-Length of an encoded body is not the length of the decoded body, so it is not compared. The state of the suspension in the fetch context grows HTMLVideoElement from 1264 to 1296 bytes. Fork note: meant for upstream. Drop once upstream has it. Testing: no test; a fetch only backs off once the 50 MiB queue of the GStreamer player is full. See Validation. Validation: Linux, GStreamer, a 150 MB, 40 s H.264 file in a muted <video preload=metadata> that plays, from a Python server that sends at most 25 MB/s per connection; the base is the parent commit. With range support: 1 request and 149.7 MB sent (base: 3 requests, 149.9 MB); networkState turns NETWORK_IDLE with a suspend event once net confirms the suspension 3.5 s in, and NETWORK_LOADING when the fetch resumes 17.4 s in, with no seeking, stalled or error event. Without range support: 1 request, 149.7 MB, peak RSS 422 MiB (base: 2 requests, 269.9 MB, 419 MiB); paused for 25 s, 1 request, 149.7 MB (base: 2 requests, 269.9 MB). Paused for 40 s with range support: the timeout cancels the fetch 30 s after the suspension, and the restart when playback needs data again plays to the end: 2 requests, 155.4 MB (base: 3 requests, 149.9 MB). Three elements on one origin: net suspends two fetches, which take 1 request each, and the third backs off when net declines its suspension: 4 requests, 449.1 MB (base: 9 requests, 449.8 MB). A suspension costs peak RSS (423 instead of 392 MiB for one element, 738 instead of 683 MiB for three), although only 53 bytes were queued when net confirmed it: once the fetch resumes, net reads at once what the socket buffers held. A server that closes a connection it could not write to for 5 s: the earlier revision of this patch without the restart ended playback after 16.5 s of the media, with no error; with it, the media plays to the end, in 3 requests and 149.7 MB with range support and 2 requests and 238.3 MB without. With network_fetch_suspend_timeout_ms=5000 and playback paused for 40 s, net ends the suspended fetch with a network error, and the media plays to the end after the restart: 3 requests and 156.9 MB with range support, 2 requests and 239.1 MB without, no error event. A server whose Content-Length is 10 MB too large: playback ends normally, as on the base; at 25 MB/s the restart fetches the 10.5 MB that were queued again (2 requests, 160.2 MB) and, without range support, the whole resource again (2 requests, 299.3 MB); at 8 and 12 MB/s the restart starts at the end of the file, which the server answers with 416 (2 requests, 149.7 MB). A server that closes idle connections and closes the restart right after its headers: MEDIA_ERR_NETWORK at the restart, 16.5 s into the media, with and without range support. `./mach test-wpt --release --processes 6 --timeout-multiplier 2` html/semantics/embedded-content/media-elements, the-video-element and html/canvas/element/manual/drawing-images-to-the-canvas with the series: 451 tests, 446 as expected; the other five behave the same on the parent commit of the series when run alone: autoplay-default-permissions-policy.https.sub.html passes where a timeout is expected (3/3 on both), media_fragment_seek.html fails a subtest (3/3 on both), src_object_blob.html times out 1 of 3 runs on both, video_timeupdate_on_seek.html passes a subtest that is expected to time out, and load-removes-queued-error-event.html hangs intermittently because GStreamer never reports the metadata of the 539-byte sound_0.mp3 (3 of 8 runs with the series, 4 of 8 without, alternating). In a later run of media-elements, track-cues-seeking.html timed out, which it does intermittently with and without the series (3 of 39 and 2 of 39 isolated runs, alternating); its 192 KB video never fills the player. `./mach check --ohos` passes at each commit; `./mach test-tidy` reports only the known rustls advisories. AI-assisted: Yes (agent session; implemented, tested and measured by the agent) AI-assisted: Yes (agent session; 2026-10-22 sync -- mechanical conflict resolution: the `media_fetch_suspension_timeout_ms` pref where upstream removed the `layout_unimplemented`, variable-fonts and writing-mode prefs (servo#48915), and the patch's +32 bytes of `HTMLVideoElement` applied to upstream's new size (servo#48082)) AI-assisted: Yes (agent session; 2026-10-22 sync -- compile fix folded in: the two early returns for a fetch that ended early pass the fetch listener's global to `submit_timing`, which takes it since upstream 51d1117 (servo#49032)) Signed-off-by: Jonathan Schwender <[email protected]>
jschwe
added a commit
to openharmony-rs/servo-ohos
that referenced
this pull request
Oct 22, 2026
Nothing caches media in Servo apart from the backends' own buffers: every loop, seek back, replay, second element and reload downloads the resource again, and the media element manages each player's fetch, with its own backoff, suspension and restarts. Add the crate servo-media-cache, a process-wide cache that fetches media resources on behalf of their readers and keeps them in blocks of 64 KiB, as Gecko's MediaCache and Chromium's MultiBuffer do. A resource is identified by its URL, CORS mode and the origin of the document, is shared by every reader that opens it, and is reused for 300 s after its last reader is gone. Storage: a resource of known length up to 8 MiB keeps its blocks in memory, all of them together within 32 MiB, beyond which unused ones go first and then new ones use the file. Every other resource uses slots of one anonymous temporary file in the directory of the pref media_cache_directory, or the system temporary directory, so that its data is page cache that the kernel can reclaim. If the file cannot be created, read or written, blocks stay in memory within 32 MiB. When the budget is used up, the block whose next use is predicted latest goes first, as with Gecko's PredictNextUse; the read-ahead of the readers is protected, up to half of the budget, and blocks read for metadata go by their last use. Fetching: a resource has at most two fetches, started through a Fetcher that the media element implements, for the readers that still need them. The main fetch loads 30 s ahead of each reader at its rate, else 8 MiB, is suspended there and resumes below 10 s, else 2 MiB. A reader that only needs metadata loads 1 MiB ahead, and an idle one nothing. A read more than 1 MiB from every fetch starts a second fetch at its block, so that the probe of an index at the end of a file costs one small request; the last few read positions of a reader keep their fetches, but only the current one starts fetches. A fetch that reaches cached data stops unless the next missing byte is within 1 MiB. A declined suspension cancels a fetch with range support, which restarts at the first missing byte once it is needed, and so does a suspension that lasts 30 s; without range support, the fetch keeps loading within its share of the protected read-ahead, since a restart fetches the resource from its start again and discards what lies before the read. Requests after the first carry If-Range. Each response is verified as HTML's "verify a media response" asks: a CORS-cross-origin response from another origin than the earlier ones fails the load, and any CORS-cross-origin response taints the media data. A 200 to a range request with the same validator and length makes the resource sequential; a differing validator or length fails the readers with ResourceChanged instead of splicing two versions of the resource. A fetch that ends early is restarted where it stopped while it stores new data, and otherwise the readers fail with a network error; a 416 ends the resource. Reading: readers never block. A read returns the cached bytes at a position, or Pending, and the reader's waker is called once data is there. An observer hears of the metadata, progress at most every 350 ms, suspension, resumption and completion of the download, and of errors. The cache queues its calls of fetchers, wakers and observers, and the user objects it drops, under its lock, and one thread at a time makes them once the lock is released; file I/O also happens without the lock, on pinned slots. Time comes from a clock that tests replace. A reader that a player still holds can be closed, which detaches it as dropping it does and fails its later reads; a reader also tells whether the resource is tainted, before its metadata event arrives. New prefs set the directory, budgets and thresholds: media_cache_directory, media_cache_file_budget_mb (128 on OpenHarmony and Android, 512 elsewhere), media_cache_memory_resource_limit_kb, media_cache_memory_fallback_mb, media_cache_readahead_seconds, media_cache_resume_seconds, media_cache_suspend_seconds and media_cache_reuse_seconds. `./mach test-unit -p servo-media-cache` runs the tests of the crate. Players may read a reader directly through the new Player::set_data_source, which backends that cannot refuse with PlayerError::NotSupported. Fork note: meant for upstream. Drop once upstream has it. Testing: 54 unit tests with a fake fetcher and a fake clock, which cover sharing, suspension and resumption, gap and probe fetches, resources without range support or of unknown length, validators and 200s to range requests, origin verification and taint, recovery from early ends, 416, eviction, memory and file backing and their I/O errors, the reuse window, trimming, activities, wakers and observers called without the lock and dropped from inside callbacks, and readers on other threads, and closing a reader that a player holds. Validation: `./mach test-unit -p servo-media-cache` passes ten runs in a row; each of 22 deliberate breaks makes at least one test fail. Two independent reviews of the crate; their findings are fixed. `./mach check`, `cargo clippy -p servo-media-cache --tests` and `./mach fmt` pass. AI-assisted: Yes (agent session; implemented, reviewed, tested and mutation-checked by agents) AI-assisted: Yes (agent session; 2026-10-22 sync -- mechanical conflict resolution: the media cache prefs where upstream removed the `layout_unimplemented`, variable-fonts and writing-mode prefs (servo#48915)) Signed-off-by: Jonathan Schwender <[email protected]>
jschwe
added a commit
to openharmony-rs/servo-ohos
that referenced
this pull request
Oct 30, 2026
…r is full When its player has enough data, a media element cancels a fetch with range support, to restart it with a Range request once the player needs data again, and keeps queueing the data of a fetch without range support, up to 32 MiB, before it cancels it and fetches the resource from its start again. Every restart costs a request, on HTTP/1.1 a new connection, and the bytes that were in flight. Ask net to suspend a fetch that is read from the network instead, and queue the data that was in flight. Net answers whether it suspended the fetch. If it did, flow control holds back the server, the download is suspended (NETWORK_IDLE and suspend, then NETWORK_LOADING once it resumes, and no progress events meanwhile), and once the player needs data, the same fetch resumes and the queue drains. If it did not, as for a cache hit or when two fetches to the origin are suspended already, the fetch backs off as before; so it does if the answer is lost, and it is resumed in case net suspended it. Responses that are not read from the network are handled as before, and the cap on the queue stays for data that keeps arriving. When a fetch completes, progress, then NETWORK_IDLE and suspend follow, also if the fetch was suspended. A fetch with range support that stays suspended for media_fetch_suspension_timeout_ms (30 s) is cancelled, to restart where the player stopped once it needs data again, so that an element paused for long does not hold a connection, which servers would time out anyway. A fetch without range support stays suspended, since its restart would fetch the resource from its start again, until net gives up on it after network_fetch_suspend_timeout_ms (60 s). Such a server, and net, end the fetch: net with a network error, which ran the fatal steps (MEDIA_ERR_NETWORK, "If the connection is interrupted after some media data has been received"), and a closed connection like a complete body, so the stream ended early. So if a fetch that was suspended ends with a network error, or with fewer bytes than its Content-Length, restart it at the byte where the player stopped, with a Range request, which a server without range support answers from the start of the resource, whose bytes before that position are discarded as after a seek: at once if the player accepts data, or else once it needs data again. A restart past the end of the resource, which the server answers with 416 or which the length of the resource tells, ends the stream, as when the server's Content-Length was too large; so does a restart without range support whose body ends without an error where the player stopped. Any other restart that ends early before it delivers data runs the fatal steps: net ends a body that loses its connection without an error. A restart that delivered data may be restarted again, so a fetch is only restarted while it makes progress. The Content-Length of an encoded body is not the length of the decoded body, so it is not compared. The state of the suspension in the fetch context grows HTMLVideoElement from 1264 to 1296 bytes. Fork note: meant for upstream. Drop once upstream has it. Testing: no test; a fetch only backs off once the 50 MiB queue of the GStreamer player is full. See Validation. Validation: Linux, GStreamer, a 150 MB, 40 s H.264 file in a muted <video preload=metadata> that plays, from a Python server that sends at most 25 MB/s per connection; the base is the parent commit. With range support: 1 request and 149.7 MB sent (base: 3 requests, 149.9 MB); networkState turns NETWORK_IDLE with a suspend event once net confirms the suspension 3.5 s in, and NETWORK_LOADING when the fetch resumes 17.4 s in, with no seeking, stalled or error event. Without range support: 1 request, 149.7 MB, peak RSS 422 MiB (base: 2 requests, 269.9 MB, 419 MiB); paused for 25 s, 1 request, 149.7 MB (base: 2 requests, 269.9 MB). Paused for 40 s with range support: the timeout cancels the fetch 30 s after the suspension, and the restart when playback needs data again plays to the end: 2 requests, 155.4 MB (base: 3 requests, 149.9 MB). Three elements on one origin: net suspends two fetches, which take 1 request each, and the third backs off when net declines its suspension: 4 requests, 449.1 MB (base: 9 requests, 449.8 MB). A suspension costs peak RSS (423 instead of 392 MiB for one element, 738 instead of 683 MiB for three), although only 53 bytes were queued when net confirmed it: once the fetch resumes, net reads at once what the socket buffers held. A server that closes a connection it could not write to for 5 s: the earlier revision of this patch without the restart ended playback after 16.5 s of the media, with no error; with it, the media plays to the end, in 3 requests and 149.7 MB with range support and 2 requests and 238.3 MB without. With network_fetch_suspend_timeout_ms=5000 and playback paused for 40 s, net ends the suspended fetch with a network error, and the media plays to the end after the restart: 3 requests and 156.9 MB with range support, 2 requests and 239.1 MB without, no error event. A server whose Content-Length is 10 MB too large: playback ends normally, as on the base; at 25 MB/s the restart fetches the 10.5 MB that were queued again (2 requests, 160.2 MB) and, without range support, the whole resource again (2 requests, 299.3 MB); at 8 and 12 MB/s the restart starts at the end of the file, which the server answers with 416 (2 requests, 149.7 MB). A server that closes idle connections and closes the restart right after its headers: MEDIA_ERR_NETWORK at the restart, 16.5 s into the media, with and without range support. `./mach test-wpt --release --processes 6 --timeout-multiplier 2` html/semantics/embedded-content/media-elements, the-video-element and html/canvas/element/manual/drawing-images-to-the-canvas with the series: 451 tests, 446 as expected; the other five behave the same on the parent commit of the series when run alone: autoplay-default-permissions-policy.https.sub.html passes where a timeout is expected (3/3 on both), media_fragment_seek.html fails a subtest (3/3 on both), src_object_blob.html times out 1 of 3 runs on both, video_timeupdate_on_seek.html passes a subtest that is expected to time out, and load-removes-queued-error-event.html hangs intermittently because GStreamer never reports the metadata of the 539-byte sound_0.mp3 (3 of 8 runs with the series, 4 of 8 without, alternating). In a later run of media-elements, track-cues-seeking.html timed out, which it does intermittently with and without the series (3 of 39 and 2 of 39 isolated runs, alternating); its 192 KB video never fills the player. `./mach check --ohos` passes at each commit; `./mach test-tidy` reports only the known rustls advisories. AI-assisted: Yes (agent session; implemented, tested and measured by the agent) AI-assisted: Yes (agent session; 2026-10-22 sync -- mechanical conflict resolution: the `media_fetch_suspension_timeout_ms` pref where upstream removed the `layout_unimplemented`, variable-fonts and writing-mode prefs (servo#48915), and the patch's +32 bytes of `HTMLVideoElement` applied to upstream's new size (servo#48082)) AI-assisted: Yes (agent session; 2026-10-22 sync -- compile fix folded in: the two early returns for a fetch that ended early pass the fetch listener's global to `submit_timing`, which takes it since upstream 51d1117 (servo#49032)) AI-assisted: Yes (agent session; 2026-10-29 sync -- mechanical conflict resolution: the pref next to upstream's `mathml_core_enabled` (servo#48631), the origin-clean line in upstream's `CorsStatus` form (servo#48748); `HTMLVideoElement` is 1256 bytes, measured at this commit with a compile-time probe, since patch 65 no longer adds a field) Signed-off-by: Jonathan Schwender <[email protected]>
jschwe
added a commit
to openharmony-rs/servo-ohos
that referenced
this pull request
Oct 30, 2026
Nothing caches media in Servo apart from the backends' own buffers: every loop, seek back, replay, second element and reload downloads the resource again, and the media element manages each player's fetch, with its own backoff, suspension and restarts. Add the crate servo-media-cache, a process-wide cache that fetches media resources on behalf of their readers and keeps them in blocks of 64 KiB, as Gecko's MediaCache and Chromium's MultiBuffer do. A resource is identified by its URL, CORS mode and the origin of the document, is shared by every reader that opens it, and is reused for 300 s after its last reader is gone. Storage: a resource of known length up to 8 MiB keeps its blocks in memory, all of them together within 32 MiB, beyond which unused ones go first and then new ones use the file. Every other resource uses slots of one anonymous temporary file in the directory of the pref media_cache_directory, or the system temporary directory, so that its data is page cache that the kernel can reclaim. If the file cannot be created, read or written, blocks stay in memory within 32 MiB. When the budget is used up, the block whose next use is predicted latest goes first, as with Gecko's PredictNextUse; the read-ahead of the readers is protected, up to half of the budget, and blocks read for metadata go by their last use. Fetching: a resource has at most two fetches, started through a Fetcher that the media element implements, for the readers that still need them. The main fetch loads 30 s ahead of each reader at its rate, else 8 MiB, is suspended there and resumes below 10 s, else 2 MiB. A reader that only needs metadata loads 1 MiB ahead, and an idle one nothing. A read more than 1 MiB from every fetch starts a second fetch at its block, so that the probe of an index at the end of a file costs one small request; the last few read positions of a reader keep their fetches, but only the current one starts fetches. A fetch that reaches cached data stops unless the next missing byte is within 1 MiB. A declined suspension cancels a fetch with range support, which restarts at the first missing byte once it is needed, and so does a suspension that lasts 30 s; without range support, the fetch keeps loading within its share of the protected read-ahead, since a restart fetches the resource from its start again and discards what lies before the read. Requests after the first carry If-Range. Each response is verified as HTML's "verify a media response" asks: a CORS-cross-origin response from another origin than the earlier ones fails the load, and any CORS-cross-origin response taints the media data. A 200 to a range request with the same validator and length makes the resource sequential; a differing validator or length fails the readers with ResourceChanged instead of splicing two versions of the resource. A fetch that ends early is restarted where it stopped while it stores new data, and otherwise the readers fail with a network error; a 416 ends the resource. Reading: readers never block. A read returns the cached bytes at a position, or Pending, and the reader's waker is called once data is there. An observer hears of the metadata, progress at most every 350 ms, suspension, resumption and completion of the download, and of errors. The cache queues its calls of fetchers, wakers and observers, and the user objects it drops, under its lock, and one thread at a time makes them once the lock is released; file I/O also happens without the lock, on pinned slots. Time comes from a clock that tests replace. A reader that a player still holds can be closed, which detaches it as dropping it does and fails its later reads; a reader also tells whether the resource is tainted, before its metadata event arrives. New prefs set the directory, budgets and thresholds: media_cache_directory, media_cache_file_budget_mb (128 on OpenHarmony and Android, 512 elsewhere), media_cache_memory_resource_limit_kb, media_cache_memory_fallback_mb, media_cache_readahead_seconds, media_cache_resume_seconds, media_cache_suspend_seconds and media_cache_reuse_seconds. `./mach test-unit -p servo-media-cache` runs the tests of the crate. Players may read a reader directly through the new Player::set_data_source, which backends that cannot refuse with PlayerError::NotSupported. Fork note: meant for upstream. Drop once upstream has it. Testing: 54 unit tests with a fake fetcher and a fake clock, which cover sharing, suspension and resumption, gap and probe fetches, resources without range support or of unknown length, validators and 200s to range requests, origin verification and taint, recovery from early ends, 416, eviction, memory and file backing and their I/O errors, the reuse window, trimming, activities, wakers and observers called without the lock and dropped from inside callbacks, and readers on other threads, and closing a reader that a player holds. Validation: `./mach test-unit -p servo-media-cache` passes ten runs in a row; each of 22 deliberate breaks makes at least one test fail. Two independent reviews of the crate; their findings are fixed. `./mach check`, `cargo clippy -p servo-media-cache --tests` and `./mach fmt` pass. AI-assisted: Yes (agent session; implemented, reviewed, tested and mutation-checked by agents) AI-assisted: Yes (agent session; 2026-10-22 sync -- mechanical conflict resolution: the media cache prefs where upstream removed the `layout_unimplemented`, variable-fonts and writing-mode prefs (servo#48915)) AI-assisted: Yes (agent session; 2026-10-29 sync -- mechanical conflict resolution, no semantic change: the prefs next to upstream's `mathml_core_enabled` (servo#48631)) Signed-off-by: Jonathan Schwender <[email protected]>
jschwe
added a commit
to openharmony-rs/servo-ohos
that referenced
this pull request
Nov 9, 2026
…r is full When its player has enough data, a media element cancels a fetch with range support, to restart it with a Range request once the player needs data again, and keeps queueing the data of a fetch without range support, up to 32 MiB, before it cancels it and fetches the resource from its start again. Every restart costs a request, on HTTP/1.1 a new connection, and the bytes that were in flight. Ask net to suspend a fetch that is read from the network instead, and queue the data that was in flight. Net answers whether it suspended the fetch. If it did, flow control holds back the server, the download is suspended (NETWORK_IDLE and suspend, then NETWORK_LOADING once it resumes, and no progress events meanwhile), and once the player needs data, the same fetch resumes and the queue drains. If it did not, as for a cache hit or when two fetches to the origin are suspended already, the fetch backs off as before; so it does if the answer is lost, and it is resumed in case net suspended it. Responses that are not read from the network are handled as before, and the cap on the queue stays for data that keeps arriving. When a fetch completes, progress, then NETWORK_IDLE and suspend follow, also if the fetch was suspended. A fetch with range support that stays suspended for media_fetch_suspension_timeout_ms (30 s) is cancelled, to restart where the player stopped once it needs data again, so that an element paused for long does not hold a connection, which servers would time out anyway. A fetch without range support stays suspended, since its restart would fetch the resource from its start again, until net gives up on it after network_fetch_suspend_timeout_ms (60 s). Such a server, and net, end the fetch: net with a network error, which ran the fatal steps (MEDIA_ERR_NETWORK, "If the connection is interrupted after some media data has been received"), and a closed connection like a complete body, so the stream ended early. So if a fetch that was suspended ends with a network error, or with fewer bytes than its Content-Length, restart it at the byte where the player stopped, with a Range request, which a server without range support answers from the start of the resource, whose bytes before that position are discarded as after a seek: at once if the player accepts data, or else once it needs data again. A restart past the end of the resource, which the server answers with 416 or which the length of the resource tells, ends the stream, as when the server's Content-Length was too large; so does a restart without range support whose body ends without an error where the player stopped. Any other restart that ends early before it delivers data runs the fatal steps: net ends a body that loses its connection without an error. A restart that delivered data may be restarted again, so a fetch is only restarted while it makes progress. The Content-Length of an encoded body is not the length of the decoded body, so it is not compared. The state of the suspension in the fetch context grows HTMLVideoElement from 1264 to 1296 bytes. Fork note: meant for upstream. Drop once upstream has it. Testing: no test; a fetch only backs off once the 50 MiB queue of the GStreamer player is full. See Validation. Validation: Linux, GStreamer, a 150 MB, 40 s H.264 file in a muted <video preload=metadata> that plays, from a Python server that sends at most 25 MB/s per connection; the base is the parent commit. With range support: 1 request and 149.7 MB sent (base: 3 requests, 149.9 MB); networkState turns NETWORK_IDLE with a suspend event once net confirms the suspension 3.5 s in, and NETWORK_LOADING when the fetch resumes 17.4 s in, with no seeking, stalled or error event. Without range support: 1 request, 149.7 MB, peak RSS 422 MiB (base: 2 requests, 269.9 MB, 419 MiB); paused for 25 s, 1 request, 149.7 MB (base: 2 requests, 269.9 MB). Paused for 40 s with range support: the timeout cancels the fetch 30 s after the suspension, and the restart when playback needs data again plays to the end: 2 requests, 155.4 MB (base: 3 requests, 149.9 MB). Three elements on one origin: net suspends two fetches, which take 1 request each, and the third backs off when net declines its suspension: 4 requests, 449.1 MB (base: 9 requests, 449.8 MB). A suspension costs peak RSS (423 instead of 392 MiB for one element, 738 instead of 683 MiB for three), although only 53 bytes were queued when net confirmed it: once the fetch resumes, net reads at once what the socket buffers held. A server that closes a connection it could not write to for 5 s: the earlier revision of this patch without the restart ended playback after 16.5 s of the media, with no error; with it, the media plays to the end, in 3 requests and 149.7 MB with range support and 2 requests and 238.3 MB without. With network_fetch_suspend_timeout_ms=5000 and playback paused for 40 s, net ends the suspended fetch with a network error, and the media plays to the end after the restart: 3 requests and 156.9 MB with range support, 2 requests and 239.1 MB without, no error event. A server whose Content-Length is 10 MB too large: playback ends normally, as on the base; at 25 MB/s the restart fetches the 10.5 MB that were queued again (2 requests, 160.2 MB) and, without range support, the whole resource again (2 requests, 299.3 MB); at 8 and 12 MB/s the restart starts at the end of the file, which the server answers with 416 (2 requests, 149.7 MB). A server that closes idle connections and closes the restart right after its headers: MEDIA_ERR_NETWORK at the restart, 16.5 s into the media, with and without range support. `./mach test-wpt --release --processes 6 --timeout-multiplier 2` html/semantics/embedded-content/media-elements, the-video-element and html/canvas/element/manual/drawing-images-to-the-canvas with the series: 451 tests, 446 as expected; the other five behave the same on the parent commit of the series when run alone: autoplay-default-permissions-policy.https.sub.html passes where a timeout is expected (3/3 on both), media_fragment_seek.html fails a subtest (3/3 on both), src_object_blob.html times out 1 of 3 runs on both, video_timeupdate_on_seek.html passes a subtest that is expected to time out, and load-removes-queued-error-event.html hangs intermittently because GStreamer never reports the metadata of the 539-byte sound_0.mp3 (3 of 8 runs with the series, 4 of 8 without, alternating). In a later run of media-elements, track-cues-seeking.html timed out, which it does intermittently with and without the series (3 of 39 and 2 of 39 isolated runs, alternating); its 192 KB video never fills the player. `./mach check --ohos` passes at each commit; `./mach test-tidy` reports only the known rustls advisories. AI-assisted: Yes (agent session; implemented, tested and measured by the agent) AI-assisted: Yes (agent session; 2026-10-22 sync -- mechanical conflict resolution: the `media_fetch_suspension_timeout_ms` pref where upstream removed the `layout_unimplemented`, variable-fonts and writing-mode prefs (servo#48915), and the patch's +32 bytes of `HTMLVideoElement` applied to upstream's new size (servo#48082)) AI-assisted: Yes (agent session; 2026-10-22 sync -- compile fix folded in: the two early returns for a fetch that ended early pass the fetch listener's global to `submit_timing`, which takes it since upstream 51d1117 (servo#49032)) AI-assisted: Yes (agent session; 2026-10-29 sync -- mechanical conflict resolution: the pref next to upstream's `mathml_core_enabled` (servo#48631), the origin-clean line in upstream's `CorsStatus` form (servo#48748); `HTMLVideoElement` is 1256 bytes, measured at this commit with a compile-time probe, since patch 65 no longer adds a field) Signed-off-by: Jonathan Schwender <[email protected]>
jschwe
added a commit
to openharmony-rs/servo-ohos
that referenced
this pull request
Nov 9, 2026
Nothing caches media in Servo apart from the backends' own buffers: every loop, seek back, replay, second element and reload downloads the resource again, and the media element manages each player's fetch, with its own backoff, suspension and restarts. Add the crate servo-media-cache, a process-wide cache that fetches media resources on behalf of their readers and keeps them in blocks of 64 KiB, as Gecko's MediaCache and Chromium's MultiBuffer do. A resource is identified by its URL, CORS mode and the origin of the document, is shared by every reader that opens it, and is reused for 300 s after its last reader is gone. Storage: a resource of known length up to 8 MiB keeps its blocks in memory, all of them together within 32 MiB, beyond which unused ones go first and then new ones use the file. Every other resource uses slots of one anonymous temporary file in the directory of the pref media_cache_directory, or the system temporary directory, so that its data is page cache that the kernel can reclaim. If the file cannot be created, read or written, blocks stay in memory within 32 MiB. When the budget is used up, the block whose next use is predicted latest goes first, as with Gecko's PredictNextUse; the read-ahead of the readers is protected, up to half of the budget, and blocks read for metadata go by their last use. Fetching: a resource has at most two fetches, started through a Fetcher that the media element implements, for the readers that still need them. The main fetch loads 30 s ahead of each reader at its rate, else 8 MiB, is suspended there and resumes below 10 s, else 2 MiB. A reader that only needs metadata loads 1 MiB ahead, and an idle one nothing. A read more than 1 MiB from every fetch starts a second fetch at its block, so that the probe of an index at the end of a file costs one small request; the last few read positions of a reader keep their fetches, but only the current one starts fetches. A fetch that reaches cached data stops unless the next missing byte is within 1 MiB. A declined suspension cancels a fetch with range support, which restarts at the first missing byte once it is needed, and so does a suspension that lasts 30 s; without range support, the fetch keeps loading within its share of the protected read-ahead, since a restart fetches the resource from its start again and discards what lies before the read. Requests after the first carry If-Range. Each response is verified as HTML's "verify a media response" asks: a CORS-cross-origin response from another origin than the earlier ones fails the load, and any CORS-cross-origin response taints the media data. A 200 to a range request with the same validator and length makes the resource sequential; a differing validator or length fails the readers with ResourceChanged instead of splicing two versions of the resource. A fetch that ends early is restarted where it stopped while it stores new data, and otherwise the readers fail with a network error; a 416 ends the resource. Reading: readers never block. A read returns the cached bytes at a position, or Pending, and the reader's waker is called once data is there. An observer hears of the metadata, progress at most every 350 ms, suspension, resumption and completion of the download, and of errors. The cache queues its calls of fetchers, wakers and observers, and the user objects it drops, under its lock, and one thread at a time makes them once the lock is released; file I/O also happens without the lock, on pinned slots. Time comes from a clock that tests replace. A reader that a player still holds can be closed, which detaches it as dropping it does and fails its later reads; a reader also tells whether the resource is tainted, before its metadata event arrives. New prefs set the directory, budgets and thresholds: media_cache_directory, media_cache_file_budget_mb (128 on OpenHarmony and Android, 512 elsewhere), media_cache_memory_resource_limit_kb, media_cache_memory_fallback_mb, media_cache_readahead_seconds, media_cache_resume_seconds, media_cache_suspend_seconds and media_cache_reuse_seconds. `./mach test-unit -p servo-media-cache` runs the tests of the crate. Players may read a reader directly through the new Player::set_data_source, which backends that cannot refuse with PlayerError::NotSupported. Fork note: meant for upstream. Drop once upstream has it. Testing: 54 unit tests with a fake fetcher and a fake clock, which cover sharing, suspension and resumption, gap and probe fetches, resources without range support or of unknown length, validators and 200s to range requests, origin verification and taint, recovery from early ends, 416, eviction, memory and file backing and their I/O errors, the reuse window, trimming, activities, wakers and observers called without the lock and dropped from inside callbacks, and readers on other threads, and closing a reader that a player holds. Validation: `./mach test-unit -p servo-media-cache` passes ten runs in a row; each of 22 deliberate breaks makes at least one test fail. Two independent reviews of the crate; their findings are fixed. `./mach check`, `cargo clippy -p servo-media-cache --tests` and `./mach fmt` pass. AI-assisted: Yes (agent session; implemented, reviewed, tested and mutation-checked by agents) AI-assisted: Yes (agent session; 2026-10-22 sync -- mechanical conflict resolution: the media cache prefs where upstream removed the `layout_unimplemented`, variable-fonts and writing-mode prefs (servo#48915)) AI-assisted: Yes (agent session; 2026-10-29 sync -- mechanical conflict resolution, no semantic change: the prefs next to upstream's `mathml_core_enabled` (servo#48631)) AI-assisted: Yes (agent session; 2026-11-09 sync -- the media cache crate joins upstream's 0.8.0 workspace version block (servo#49467), and Cargo.lock gives it that version) Signed-off-by: Jonathan Schwender <[email protected]>
Loirooriol
pushed a commit
to servo/stylo
that referenced
this pull request
Nov 9, 2026
…with Gecko convention. (#492) This PR makes two changes: - Splits the `layout.unimplemented` into individual prefs for groups of related properties - Renames some prefs (adds `.css` to them) to align with Gecko convention (other Servo prefs already followed this). Servo PR: servo/servo#48915 | Pref | Additional properties | |---|---| | `layout.css.anchor-positioning.enabled` | `position-area`, `position-try-fallbacks` | | `layout.css.scroll-driven-animations.enabled` | `animation-timeline`, `animation-range-start`, `animation-range-end` | ### `layout.unimplemented` properties moved under new prefs | Pref | Properties affected | |---|---| | `layout.css.appearance.enabled` | `appearance` | | `layout.css.backdrop-filter.enabled` | `backdrop-filter` | | `layout.css.contain.enabled` | `contain` | | `layout.css.corner-shape.enabled` | `corner-{top-left,top-right,bottom-right,bottom-left,start-start,start-end,end-start,end-end}-shape`, `corner-shape`, `corner-{top,right,bottom,left,block-start,block-end,inline-start,inline-end}-shape` | | `layout.css.counters.enabled` | `counter-increment`, `counter-reset` | | `layout.css.font-size-adjust.enabled` | `font-size-adjust` | | `layout.css.forced-color-adjust.enabled` | `forced-color-adjust` | | `layout.css.masking.enabled` | `mask-image`, `mask-position-x`, `mask-position-y`, `mask-repeat`, `mask-size`, `mask-type`, `mask-mode`, `mask-clip`, `mask-origin`, `mask-composite`, `mask`, `mask-position` | | `layout.css.math-properties.enabled` | `math-depth`, `math-style` | | `layout.css.motion-path.enabled` | `offset-path` | | `layout.css.overscroll-behavior.enabled` | `overscroll-behavior-{x,y,block,inline}`, `overscroll-behavior` | | `layout.css.scroll-behavior.enabled` | `scroll-behavior` | | `layout.css.scrollbar-styling.enabled` | `scrollbar-color`, `scrollbar-width` | | `layout.css.text-decoration-inset.enabled` | `text-decoration-inset` | | `layout.css.text-overflow.enabled` | `text-overflow` | | `layout.css.text-underline.enabled` | `text-underline-offset`, `text-underline-position` | | `layout.css.view-transitions.enabled` | `view-transition-name`, `view-transition-class` | | `layout.css.writing-mode.text-orientation.enabled` | `text-orientation` | | `layout.css.zoom.enabled` | `zoom` | ### Renamed prefs | Old pref name | New pref name | | :--- | :--- | | `layout.columns.enabled` | `layout.css.columns.enabled` | | `layout.container-queries.enabled` | `layout.css.container-queries.enabled` | | `layout.variable_fonts.enabled` | `layout.css.font-variations.enabled` | | `layout.writing-mode.enabled` | `layout.css.writing-mode.enabled` | | `layout.writing-mode.sideways.enabled` | `layout.css.writing-mode.sideways.enabled` | | `layout.flexbox.balance` | `layout.css.flexbox-balance.enabled` |
jschwe
added a commit
to openharmony-rs/servo-ohos
that referenced
this pull request
Nov 10, 2026
…r is full When its player has enough data, a media element cancels a fetch with range support, to restart it with a Range request once the player needs data again, and keeps queueing the data of a fetch without range support, up to 32 MiB, before it cancels it and fetches the resource from its start again. Every restart costs a request, on HTTP/1.1 a new connection, and the bytes that were in flight. Ask net to suspend a fetch that is read from the network instead, and queue the data that was in flight. Net answers whether it suspended the fetch. If it did, flow control holds back the server, the download is suspended (NETWORK_IDLE and suspend, then NETWORK_LOADING once it resumes, and no progress events meanwhile), and once the player needs data, the same fetch resumes and the queue drains. If it did not, as for a cache hit or when two fetches to the origin are suspended already, the fetch backs off as before; so it does if the answer is lost, and it is resumed in case net suspended it. Responses that are not read from the network are handled as before, and the cap on the queue stays for data that keeps arriving. When a fetch completes, progress, then NETWORK_IDLE and suspend follow, also if the fetch was suspended. A fetch with range support that stays suspended for media_fetch_suspension_timeout_ms (30 s) is cancelled, to restart where the player stopped once it needs data again, so that an element paused for long does not hold a connection, which servers would time out anyway. A fetch without range support stays suspended, since its restart would fetch the resource from its start again, until net gives up on it after network_fetch_suspend_timeout_ms (60 s). Such a server, and net, end the fetch: net with a network error, which ran the fatal steps (MEDIA_ERR_NETWORK, "If the connection is interrupted after some media data has been received"), and a closed connection like a complete body, so the stream ended early. So if a fetch that was suspended ends with a network error, or with fewer bytes than its Content-Length, restart it at the byte where the player stopped, with a Range request, which a server without range support answers from the start of the resource, whose bytes before that position are discarded as after a seek: at once if the player accepts data, or else once it needs data again. A restart past the end of the resource, which the server answers with 416 or which the length of the resource tells, ends the stream, as when the server's Content-Length was too large; so does a restart without range support whose body ends without an error where the player stopped. Any other restart that ends early before it delivers data runs the fatal steps: net ends a body that loses its connection without an error. A restart that delivered data may be restarted again, so a fetch is only restarted while it makes progress. The Content-Length of an encoded body is not the length of the decoded body, so it is not compared. The state of the suspension in the fetch context grows HTMLVideoElement from 1264 to 1296 bytes. Fork note: meant for upstream. Drop once upstream has it. Testing: no test; a fetch only backs off once the 50 MiB queue of the GStreamer player is full. See Validation. Validation: Linux, GStreamer, a 150 MB, 40 s H.264 file in a muted <video preload=metadata> that plays, from a Python server that sends at most 25 MB/s per connection; the base is the parent commit. With range support: 1 request and 149.7 MB sent (base: 3 requests, 149.9 MB); networkState turns NETWORK_IDLE with a suspend event once net confirms the suspension 3.5 s in, and NETWORK_LOADING when the fetch resumes 17.4 s in, with no seeking, stalled or error event. Without range support: 1 request, 149.7 MB, peak RSS 422 MiB (base: 2 requests, 269.9 MB, 419 MiB); paused for 25 s, 1 request, 149.7 MB (base: 2 requests, 269.9 MB). Paused for 40 s with range support: the timeout cancels the fetch 30 s after the suspension, and the restart when playback needs data again plays to the end: 2 requests, 155.4 MB (base: 3 requests, 149.9 MB). Three elements on one origin: net suspends two fetches, which take 1 request each, and the third backs off when net declines its suspension: 4 requests, 449.1 MB (base: 9 requests, 449.8 MB). A suspension costs peak RSS (423 instead of 392 MiB for one element, 738 instead of 683 MiB for three), although only 53 bytes were queued when net confirmed it: once the fetch resumes, net reads at once what the socket buffers held. A server that closes a connection it could not write to for 5 s: the earlier revision of this patch without the restart ended playback after 16.5 s of the media, with no error; with it, the media plays to the end, in 3 requests and 149.7 MB with range support and 2 requests and 238.3 MB without. With network_fetch_suspend_timeout_ms=5000 and playback paused for 40 s, net ends the suspended fetch with a network error, and the media plays to the end after the restart: 3 requests and 156.9 MB with range support, 2 requests and 239.1 MB without, no error event. A server whose Content-Length is 10 MB too large: playback ends normally, as on the base; at 25 MB/s the restart fetches the 10.5 MB that were queued again (2 requests, 160.2 MB) and, without range support, the whole resource again (2 requests, 299.3 MB); at 8 and 12 MB/s the restart starts at the end of the file, which the server answers with 416 (2 requests, 149.7 MB). A server that closes idle connections and closes the restart right after its headers: MEDIA_ERR_NETWORK at the restart, 16.5 s into the media, with and without range support. `./mach test-wpt --release --processes 6 --timeout-multiplier 2` html/semantics/embedded-content/media-elements, the-video-element and html/canvas/element/manual/drawing-images-to-the-canvas with the series: 451 tests, 446 as expected; the other five behave the same on the parent commit of the series when run alone: autoplay-default-permissions-policy.https.sub.html passes where a timeout is expected (3/3 on both), media_fragment_seek.html fails a subtest (3/3 on both), src_object_blob.html times out 1 of 3 runs on both, video_timeupdate_on_seek.html passes a subtest that is expected to time out, and load-removes-queued-error-event.html hangs intermittently because GStreamer never reports the metadata of the 539-byte sound_0.mp3 (3 of 8 runs with the series, 4 of 8 without, alternating). In a later run of media-elements, track-cues-seeking.html timed out, which it does intermittently with and without the series (3 of 39 and 2 of 39 isolated runs, alternating); its 192 KB video never fills the player. `./mach check --ohos` passes at each commit; `./mach test-tidy` reports only the known rustls advisories. AI-assisted: Yes (agent session; implemented, tested and measured by the agent) AI-assisted: Yes (agent session; 2026-10-22 sync -- mechanical conflict resolution: the `media_fetch_suspension_timeout_ms` pref where upstream removed the `layout_unimplemented`, variable-fonts and writing-mode prefs (servo#48915), and the patch's +32 bytes of `HTMLVideoElement` applied to upstream's new size (servo#48082)) AI-assisted: Yes (agent session; 2026-10-22 sync -- compile fix folded in: the two early returns for a fetch that ended early pass the fetch listener's global to `submit_timing`, which takes it since upstream 51d1117 (servo#49032)) AI-assisted: Yes (agent session; 2026-10-29 sync -- mechanical conflict resolution: the pref next to upstream's `mathml_core_enabled` (servo#48631), the origin-clean line in upstream's `CorsStatus` form (servo#48748); `HTMLVideoElement` is 1256 bytes, measured at this commit with a compile-time probe, since patch 65 no longer adds a field) Signed-off-by: Jonathan Schwender <[email protected]>
jschwe
added a commit
to openharmony-rs/servo-ohos
that referenced
this pull request
Nov 10, 2026
Nothing caches media in Servo apart from the backends' own buffers: every loop, seek back, replay, second element and reload downloads the resource again, and the media element manages each player's fetch, with its own backoff, suspension and restarts. Add the crate servo-media-cache, a process-wide cache that fetches media resources on behalf of their readers and keeps them in blocks of 64 KiB, as Gecko's MediaCache and Chromium's MultiBuffer do. A resource is identified by its URL, CORS mode and the origin of the document, is shared by every reader that opens it, and is reused for 300 s after its last reader is gone. Storage: a resource of known length up to 8 MiB keeps its blocks in memory, all of them together within 32 MiB, beyond which unused ones go first and then new ones use the file. Every other resource uses slots of one anonymous temporary file in the directory of the pref media_cache_directory, or the system temporary directory, so that its data is page cache that the kernel can reclaim. If the file cannot be created, read or written, blocks stay in memory within 32 MiB. When the budget is used up, the block whose next use is predicted latest goes first, as with Gecko's PredictNextUse; the read-ahead of the readers is protected, up to half of the budget, and blocks read for metadata go by their last use. Fetching: a resource has at most two fetches, started through a Fetcher that the media element implements, for the readers that still need them. The main fetch loads 30 s ahead of each reader at its rate, else 8 MiB, is suspended there and resumes below 10 s, else 2 MiB. A reader that only needs metadata loads 1 MiB ahead, and an idle one nothing. A read more than 1 MiB from every fetch starts a second fetch at its block, so that the probe of an index at the end of a file costs one small request; the last few read positions of a reader keep their fetches, but only the current one starts fetches. A fetch that reaches cached data stops unless the next missing byte is within 1 MiB. A declined suspension cancels a fetch with range support, which restarts at the first missing byte once it is needed, and so does a suspension that lasts 30 s; without range support, the fetch keeps loading within its share of the protected read-ahead, since a restart fetches the resource from its start again and discards what lies before the read. Requests after the first carry If-Range. Each response is verified as HTML's "verify a media response" asks: a CORS-cross-origin response from another origin than the earlier ones fails the load, and any CORS-cross-origin response taints the media data. A 200 to a range request with the same validator and length makes the resource sequential; a differing validator or length fails the readers with ResourceChanged instead of splicing two versions of the resource. A fetch that ends early is restarted where it stopped while it stores new data, and otherwise the readers fail with a network error; a 416 ends the resource. Reading: readers never block. A read returns the cached bytes at a position, or Pending, and the reader's waker is called once data is there. An observer hears of the metadata, progress at most every 350 ms, suspension, resumption and completion of the download, and of errors. The cache queues its calls of fetchers, wakers and observers, and the user objects it drops, under its lock, and one thread at a time makes them once the lock is released; file I/O also happens without the lock, on pinned slots. Time comes from a clock that tests replace. A reader that a player still holds can be closed, which detaches it as dropping it does and fails its later reads; a reader also tells whether the resource is tainted, before its metadata event arrives. New prefs set the directory, budgets and thresholds: media_cache_directory, media_cache_file_budget_mb (128 on OpenHarmony and Android, 512 elsewhere), media_cache_memory_resource_limit_kb, media_cache_memory_fallback_mb, media_cache_readahead_seconds, media_cache_resume_seconds, media_cache_suspend_seconds and media_cache_reuse_seconds. `./mach test-unit -p servo-media-cache` runs the tests of the crate. Players may read a reader directly through the new Player::set_data_source, which backends that cannot refuse with PlayerError::NotSupported. Fork note: meant for upstream. Drop once upstream has it. Testing: 54 unit tests with a fake fetcher and a fake clock, which cover sharing, suspension and resumption, gap and probe fetches, resources without range support or of unknown length, validators and 200s to range requests, origin verification and taint, recovery from early ends, 416, eviction, memory and file backing and their I/O errors, the reuse window, trimming, activities, wakers and observers called without the lock and dropped from inside callbacks, and readers on other threads, and closing a reader that a player holds. Validation: `./mach test-unit -p servo-media-cache` passes ten runs in a row; each of 22 deliberate breaks makes at least one test fail. Two independent reviews of the crate; their findings are fixed. `./mach check`, `cargo clippy -p servo-media-cache --tests` and `./mach fmt` pass. AI-assisted: Yes (agent session; implemented, reviewed, tested and mutation-checked by agents) AI-assisted: Yes (agent session; 2026-10-22 sync -- mechanical conflict resolution: the media cache prefs where upstream removed the `layout_unimplemented`, variable-fonts and writing-mode prefs (servo#48915)) AI-assisted: Yes (agent session; 2026-10-29 sync -- mechanical conflict resolution, no semantic change: the prefs next to upstream's `mathml_core_enabled` (servo#48631)) AI-assisted: Yes (agent session; 2026-11-09 sync -- the media cache crate joins upstream's 0.8.0 workspace version block (servo#49467), and Cargo.lock gives it that version) Signed-off-by: Jonathan Schwender <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Servo PR for:
layout.unimplementedinto individual prefs. Align pref names with Gecko convention. stylo#492Which replaces the
layout.unimplementedprefs with individual prefs + renames a few prefs for consistency.Servo-side changes:
layout_unimplementedpreflayout_css_backdrop_filter_enabledpref (it's used in a test)-ZCLI argument. Previously some now-removed prefs were documented as examples. But this argument doesn't accept prefs as value anyway! Updated with values that are valid.Testing: not needed, no behavior change