# WaylandFrame and WaylandFrameManager Checking how the frame is processed and sequence id is used. ## What is WaylandFrame and its Manager [WaylandFrame](https://source.chromium.org/chromium/chromium/src/+/main:ui/ozone/platform/wayland/host/wayland_frame_manager.h;l=37;drc=ad1b7f95b5c0758fcbbdd17e3596fc13ef99b974) is a representation of a graphical frame update. It holds the queue of subsurfaces attached to this frame as [`subsurfaces_to_overlays`](https://source.chromium.org/chromium/chromium/src/+/main:ui/ozone/platform/wayland/host/wayland_frame_manager.h;l=67;drc=f4a00cc248dd2dc8ec8759fb51620d47b5114090). [`frame_id`](https://source.chromium.org/chromium/chromium/src/+/main:ui/ozone/platform/wayland/host/wayland_frame_manager.h;l=63;drc=f4a00cc248dd2dc8ec8759fb51620d47b5114090) is a unique number representing the frame. [`wl_frame_callback`](https://source.chromium.org/chromium/chromium/src/+/main:ui/ozone/platform/wayland/host/wayland_frame_manager.h;l=78;drc=f4a00cc248dd2dc8ec8759fb51620d47b5114090) is a wayland callback called on wl_buffer committed. [`seq`](https://source.chromium.org/chromium/chromium/src/+/main:ui/ozone/platform/wayland/host/wayland_frame_manager.h;l=96;drc=f4a00cc248dd2dc8ec8759fb51620d47b5114090) is `int64_t` value. This sequence id is used to handle configure event. [WaylandFrameManager](https://source.chromium.org/chromium/chromium/src/+/main:ui/ozone/platform/wayland/host/wayland_frame_manager.h;l=106;drc=f4a00cc248dd2dc8ec8759fb51620d47b5114090) manages the frame update. It configures graphical window state and submits buffer swaps to a window. WaylandFrame is first recorded by [RecordFrame](https://source.chromium.org/chromium/chromium/src/+/main:ui/ozone/platform/wayland/host/wayland_frame_manager.h;l=118;drc=f4a00cc248dd2dc8ec8759fb51620d47b5114090) on CommitOverlays. This appends the passed `frame` to [`pending_frame_`](https://source.chromium.org/chromium/chromium/src/+/main:ui/ozone/platform/wayland/host/wayland_frame_manager.h;l=216;drc=f4a00cc248dd2dc8ec8759fb51620d47b5114090). On [MaybeProcessPendingFrame](https://source.chromium.org/chromium/chromium/src/+/main:ui/ozone/platform/wayland/host/wayland_frame_manager.cc;l=146;drc=f4a00cc248dd2dc8ec8759fb51620d47b5114090), it obtains the top of `pending_frame_` queue, and [PlayBackFrame](https://source.chromium.org/chromium/chromium/src/+/main:ui/ozone/platform/wayland/host/wayland_frame_manager.cc;l=231;drc=f4a00cc248dd2dc8ec8759fb51620d47b5114090) if it meets the condition. The conditions are 1. previous frame's frame callback is acknowledged, 2. window is configured, 3. wl_buffers are ready. This will submit the frame and append the frame to [`submitted_frames_`](https://source.chromium.org/chromium/chromium/src/+/main:ui/ozone/platform/wayland/host/wayland_frame_manager.h;l=220;drc=f4a00cc248dd2dc8ec8759fb51620d47b5114090). ## seq id On processing frame, [OnSequencePoint](https://source.chromium.org/chromium/chromium/src/+/main:ui/ozone/platform/wayland/host/wayland_frame_manager.cc;l=191;drc=f4a00cc248dd2dc8ec8759fb51620d47b5114090) is called aginst `seq` for the frame to play back. This is a virtual method of WaylandWindow and it will [ProcessSequencePoint](https://source.chromium.org/chromium/chromium/src/+/main:ui/ozone/platform/wayland/host/wayland_window.cc;l=1309;drc=f4a00cc248dd2dc8ec8759fb51620d47b5114090). `seq` is named as `viz_seq` in WaylandWindow. On processing sequence point, it proceeds until the pending request with passed `viz_seq` and then latch the latest request only. This seq id is incremented by the order, and each in-flight request corresponds to one `viz_seq` stored as [StateRequest](https://source.chromium.org/chromium/chromium/src/+/main:ui/ozone/platform/wayland/host/wayland_window.h;l=521;drc=f4a00cc248dd2dc8ec8759fb51620d47b5114090). `viz_seq` is generated by [OnStateUpdate](https://source.chromium.org/chromium/chromium/src/+/main:ui/ozone/platform/wayland/host/wayland_window.cc;l=1465;drc=f4a00cc248dd2dc8ec8759fb51620d47b5114090) ([WaylandTreeHostPlatform](https://source.chromium.org/chromium/chromium/src/+/main:ui/aura/window_tree_host_platform.cc;l=317;drc=f4a00cc248dd2dc8ec8759fb51620d47b5114090) has an implementation for Lacros). If we predict that there is a new frame, we allocate new local surface id and get [`parent_sequence_number`](https://source.chromium.org/chromium/chromium/src/+/main:components/viz/common/surfaces/local_surface_id.h;l=100;drc=f4a00cc248dd2dc8ec8759fb51620d47b5114090) as a next viz seq. We predict whether we produce a new frame by following logic: 1. If size, window scale or raster scale is updated ([ProducesFrameOnUpdateFrom](https://source.chromium.org/chromium/chromium/src/+/main:ui/platform_window/platform_window_delegate.cc;l=23;drc=f4a00cc248dd2dc8ec8759fb51620d47b5114090)) 2. If compositor is invisible