compositor: Allow canvas to upload rendered contents asynchronously (#37776)

Adds epoch to each WR image op command that is sent to compositor. The
renderer now has a `FrameDelayer` data structure that is responsible for
tracking when a frame is ready to be displayed. When asking canvases to
update their rendering, they are given an optional `Epoch` which denotes
the `Document`'s canvas epoch. When all image updates for that `Epoch`
are seen in the renderer, the frame can be displayed.

Testing: Existing WPT tests
Fixes: #35733

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Sam 2025-08-29 12:04:41 +02:00 committed by GitHub
parent 4700149fcb
commit 8beef6c21f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
36 changed files with 452 additions and 100 deletions

View file

@ -5,6 +5,7 @@
use std::default::Default;
use std::str::FromStr;
use base::Epoch;
use euclid::Angle;
use euclid::approxeq::ApproxEq;
use euclid::default::{Point2D, Rect, Size2D, Transform2D};
@ -516,7 +517,7 @@ pub enum Canvas2dMsg {
CompositionOptions,
Transform2D<f64>,
),
UpdateImage(IpcSender<()>),
UpdateImage(Option<Epoch>),
}
#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)]

View file

@ -7,6 +7,7 @@ use std::fmt;
use std::num::{NonZeroU32, NonZeroU64};
use std::ops::Deref;
use base::Epoch;
/// Receiver type used in WebGLCommands.
pub use base::generic_channel::GenericReceiver as WebGLReceiver;
/// Sender type used in WebGLCommands.
@ -107,7 +108,7 @@ pub enum WebGLMsg {
/// The third field contains the time (in ns) when the request
/// was initiated. The u64 in the second field will be the time the
/// request is fulfilled
SwapBuffers(Vec<WebGLContextId>, WebGLSender<u64>, u64),
SwapBuffers(Vec<WebGLContextId>, Option<Epoch>, u64),
/// Frees all resources and closes the thread.
Exit(IpcSender<()>),
}