Skip to content

cobalt: Time splash screen from first video frame - #13464

Merged
borongc merged 12 commits into
youtube:mainfrom
borongc:video_splash_timer_from_first_frame
Oct 21, 2026
Merged

borongc merged 12 commits into
youtube:mainfrom
borongc:video_splash_timer_from_first_frame

Conversation

@borongc

@borongc borongc commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

The splash screen duration currently starts counting when the splash
page loads. For video splash screens, there is often a significant
delay before the first frame is rendered, which causes the video to
be cut short when the browser transitions to the main content.

Calculating the duration from the moment the video actually starts
playing ensures that the splash video is seen by the user for its
intended length. A fallback timer is included to prevent the splash
screen from hanging if the video content fails to render.

Issue: 574814787
TAG=agy
CONV=f324298c-685c-4857-af47-73303781366d

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor
Context State Description
CI / All Pass ✅ PASS All checks passed
CI / android ✅ PASS Passed
CI / evergreen ✅ PASS Passed
CI / linux ✅ PASS Passed
CI / tvos ✅ PASS Passed
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Gemini Suggested Commit Message


cobalt: Time splash screen from first video frame

The splash screen duration currently starts counting when the splash
page loads. For video splash screens, there is often a significant
delay before the first frame is rendered, which causes the video to
be cut short when the browser transitions to the main content.

Calculating the duration from the moment the video actually starts
playing ensures that the splash video is seen by the user for its
intended length. A fallback timer is included to prevent the splash
screen from hanging if the video content fails to render.

Bug: 574814787

💡 Pro Tips for a Better Commit Message:

  1. Influence the Result: Want to change the output? You can write custom prompts or instructions directly in the Pull Request description. The model uses that text to generate the message.
  2. Re-run the Generator: Post a comment with: /generate-commit-message
@borongc borongc changed the title cobalt: Count the video splash screen's duration from its first frame Oct 17, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the splash screen logic to wait for the first frame of a video splash screen before starting its minimum duration timer, with a fallback timeout of 2 seconds. This behavior is verified with several new unit tests. The review feedback points out a bug where the flag awaiting_splash_video_first_frame_ is set to true even when the web contents observer is null, which would always trigger the fallback delay. Moving this flag assignment inside the observer check is recommended.

Comment thread cobalt/shell/browser/shell.cc Resolved
Comment thread cobalt/shell/browser/shell.cc Resolved

@linxinan-yt linxinan-yt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM % comments

The splash screen's duration (the default 1.5 s, or SplashScreenConfig's
timeout) counts from the load of the splash screen page. With
ForceVideoSplashScreen, the page's video only shows its first frame
later, e.g., about 0.6 s later on Android TV devices. So once the main
WebContents has loaded, the switch to it cuts the 1.33 s video short: in
30 cold starts each on Google TV Streamer and Chromecast with Google TV,
the video showed fully only 4 and 5 times, and about 0.9 s of it at the
median.

The duration now starts with the video's first frame, which is when the
video starts playing in the splash screen WebContents
(MediaStartedPlaying()), or 2 s after the page load if the video hasn't
shown by then.

TAG=agy
CONV=f324298c-685c-4857-af47-73303781366d
Without the splash screen observer, nothing reports the video's first
frame, so the splash screen would always wait the full 2 s before its
duration starts.

Issue: 574814787
TAG=agy
CONV=f324298c-685c-4857-af47-73303781366d
With SplashScreenConfig, splash.html stays up until the timeout, which it
counted from its load, while Shell counts it from the video's first
frame. So the page closed itself before Shell's timeout, e.g., about
0.6 s before on Android TV devices, and the last frame of the video
stayed up for less than the timeout. The page now counts the timeout
from its video's first frame too (its playing event). The image still
counts from the page load.

Issue: 574814787
TAG=agy
CONV=f324298c-685c-4857-af47-73303781366d
tvOS enables ForceVideoSplashScreen by default, so SplashScreenTest's
timing tests ran the video splash screen there. Its duration now counts
from the video's first frame, which those tests don't simulate, so 8 of
them failed in tvos_cobalt_unittests.

The fixture now disables ForceVideoSplashScreen, so the tests run the
image splash screen on every platform unless they enable the video one,
as the tests of the video's first frame do.

Issue: 574814787
TAG=agy
CONV=f324298c-685c-4857-af47-73303781366d
Since the previous commits, the splash screen's duration counts from its
video's first frame, within 2s, rather than from when its page loads.

Issue: 574814787
TAG=agy
CONV=f324298c-685c-4857-af47-73303781366d
Shell waited for the splash video's first frame whenever
ForceVideoSplashScreen is enabled, as it is by default on tvOS, while
splash.html only plays its video if MediaSource.isTypeSupported()
accepts VP9, and shows its image otherwise, e.g., on tvOS devices
without hardware VP9 decoding. Shell then waited up to 2s for a frame
that never came. That only delayed the switch to the main WebContents
if the page didn't close itself, e.g., if its image failed to load.

Shell now asks Starboard the same as the page, as
MediaSource.isTypeSupported() passes its type string to
SbMediaCanPlayMimeAndKeySystem() as is. It asks off the UI thread, and
if the page shows its image, the splash screen starts when its page
has loaded, as for the image splash screen.

Issue: 574814787
TAG=agy
CONV=f324298c-685c-4857-af47-73303781366d
The unit tests cover Shell's timeout, which counts from the splash
video's first frame, but not splash.html's, which counts from its
video's playing event too. The new browser test starts the page's video
500 ms after the page has loaded, and checks that the page closes itself
once the timeout has passed since the video started, rather than since
the page loaded.

The test sends the video's events itself, with the image forced so that
no real video plays, so it doesn't depend on media playback.

Issue: 574814787
TAG=agy
CONV=f324298c-685c-4857-af47-73303781366d
The log said that the splash screen hadn't loaded yet, but its duration
now also waits for its video's first frame.

Issue: 574814787
TAG=agy
CONV=f324298c-685c-4857-af47-73303781366d
Tests set and reset the override of CanSplashScreenPlayVideo() on the
main thread, while the check read it on the thread pool, so a check
still running when a test ended raced with the reset. The UI thread now
passes its value to the check when it posts it, so only the UI thread
accesses the override.

Issue: 574814787
TAG=agy
CONV=f324298c-685c-4857-af47-73303781366d
Says which condition the #else and #endif of
MAYBE_SplashTimeoutCountsFromVideoStart belong to, as is usual for
preprocessor branches.

Issue: 574814787
TAG=agy
CONV=f324298c-685c-4857-af47-73303781366d
The splash screen starts when its video starts playing: when the SbPlayer
reports kSbPlayerStatePresenting, i.e., once it has prerolled the video,
which MediaStartedPlaying and the page's playing event follow. The first
frame may only show a refresh later, so the comments and logs no longer
say that it has been presented.

Issue: 574814787
TAG=agy
CONV=f324298c-685c-4857-af47-73303781366d
The splash.html browser tests that are disabled on Android load the
page's video with MediaSource, which Android's browser tests don't
support yet (478334656). SplashTimeoutCountsFromVideoStart forces the
image, so the page doesn't use MediaSource, and the test sends the
events of the page's video itself, so it runs on Android too.

Issue: 574814787
TAG=agy
CONV=f324298c-685c-4857-af47-73303781366d
@borongc
borongc force-pushed the video_splash_timer_from_first_frame branch from b7ed3ba to 81868ad Compare October 21, 2026 17:44
@borongc
borongc merged commit 96bba12 into youtube:main Oct 21, 2026
883 of 888 checks passed
@borongc
borongc deleted the video_splash_timer_from_first_frame branch October 21, 2026 19:07
cobalt-github-releaser-bot pushed a commit that referenced this pull request Oct 21, 2026
Refer to original PR: #13464

The splash screen duration currently starts counting when the splash
page loads. For video splash screens, there is often a significant
delay before the first frame is rendered, which causes the video to
be cut short when the browser transitions to the main content.

Calculating the duration from the moment the video actually starts
playing ensures that the splash video is seen by the user for its
intended length. A fallback timer is included to prevent the splash
screen from hanging if the video content fails to render.

Issue: 574814787
TAG=agy
CONV=f324298c-685c-4857-af47-73303781366d

(cherry picked from commit 96bba12)
briantting pushed a commit that referenced this pull request Oct 22, 2026
Refer to original PR: #13464

The splash screen duration currently starts counting when the splash
page loads. For video splash screens, there is often a significant
delay before the first frame is rendered, which causes the video to
be cut short when the browser transitions to the main content.

Calculating the duration from the moment the video actually starts
playing ensures that the splash video is seen by the user for its
intended length. A fallback timer is included to prevent the splash
screen from hanging if the video content fails to render.

Issue: 574814787
TAG=agy
CONV=f324298c-685c-4857-af47-73303781366d

(cherry picked from commit 96bba12)
borongc added a commit to borongc/cobalt that referenced this pull request Oct 24, 2026
The image splash screen started its minimum duration when its page
loaded, and splash.html closed itself 1s after fetching its image. Both
happen before the image is on screen. In single-process mode, the image
is painted on the renderer thread that the WebApp's startup keeps busy,
so a fast WebApp could take over before the image ever showed.

Apply the approach of youtube#13464 to images: Shell starts the minimum at the
splash screen's first contentful paint, within 2s of its page loading
by default. In splash.html's image path, that's the frame that shows
the image, as neither the background, the empty video element, nor the
placeholder while transparent is contentful. splash.html closes itself
1s after the same paint instead of after the fetch, and right away if
the image can't be shown. The video splash screen still starts at its
first frame, as its page paints before that.

The wait for the content is behind the SplashScreenContentWait feature,
enabled by default, whose max_delay param bounds it (2s by default), so
it can be tuned for slower devices. If the feature is disabled, or
max_delay isn't positive, the minimum starts when the page loads again,
for both the image and the video.
Cobalt.SplashScreen.ContentWaitTimedOut.{Image,Video} records whether
the wait timed out. Switching to the main WebContents now also ends the
wait: if the splash screen closed itself before its content showed, the
end of the wait scheduled another switch, which hid the main
WebContents of a video splash screen.

The image's "content shown" startup metrics now use the first
contentful paint as well, rather than the first visually non-empty
paint, which can be the background alone.

Bug: 563221091
TAG=agy
CONV=96668df3-1b7c-46af-b387-71b647fad31c
CONV=92c9a3de-e02e-4df0-afa8-f9713b3b050e
briantting pushed a commit that referenced this pull request Oct 27, 2026
Refer to original PR: #13464

The splash screen duration currently starts counting when the splash
page loads. For video splash screens, there is often a significant
delay before the first frame is rendered, which causes the video to
be cut short when the browser transitions to the main content.

Calculating the duration from the moment the video actually starts
playing ensures that the splash video is seen by the user for its
intended length. A fallback timer is included to prevent the splash
screen from hanging if the video content fails to render.

Issue: 574814787
TAG=agy
CONV=f324298c-685c-4857-af47-73303781366d

(cherry picked from commit 96bba12)
borongc added a commit to borongc/cobalt that referenced this pull request Oct 27, 2026
The image splash screen started its minimum duration when its page
loaded, and splash.html closed itself 1s after fetching its image. Both
happen before the image is on screen. In single-process mode, the image
is painted on the renderer thread that the WebApp's startup keeps busy,
so a fast WebApp could take over before the image ever showed.

Apply the approach of youtube#13464 to images: Shell starts the minimum at the
splash screen's first contentful paint, within 2s of its page loading
by default. In splash.html's image path, that's the frame that shows
the image, as neither the background, the empty video element, nor the
placeholder while transparent is contentful. splash.html closes itself
1s after the same paint instead of after the fetch, and right away if
the image can't be shown. The video splash screen still starts at its
first frame, as its page paints before that.

The wait for the content is behind the SplashScreenContentWait feature,
enabled by default, whose max_delay param bounds it (2s by default), so
it can be tuned for slower devices. If the feature is disabled, or
max_delay isn't positive, the minimum starts when the page loads again,
for both the image and the video.
Cobalt.SplashScreen.ContentWaitTimedOut.{Image,Video} records whether
the wait timed out. Switching to the main WebContents now also ends the
wait: if the splash screen closed itself before its content showed, the
end of the wait scheduled another switch, which hid the main
WebContents of a video splash screen.

The image's "content shown" startup metrics now use the first
contentful paint as well, rather than the first visually non-empty
paint, which can be the background alone.

Bug: 563221091
TAG=agy
CONV=96668df3-1b7c-46af-b387-71b647fad31c
CONV=92c9a3de-e02e-4df0-afa8-f9713b3b050e
borongc added a commit to borongc/cobalt that referenced this pull request Oct 27, 2026
The image splash screen started its minimum duration when its page
loaded, and splash.html closed itself 1s after fetching its image. Both
happen before the image is on screen. In single-process mode, the image
is painted on the renderer thread that the WebApp's startup keeps busy,
so a fast WebApp could take over before the image ever showed.

Apply the approach of youtube#13464 to images: Shell starts the minimum at the
splash screen's first contentful paint, within 2s of its page loading
by default. In splash.html's image path, that's the frame that shows
the image, as neither the background, the empty video element, nor the
placeholder while transparent is contentful. splash.html closes itself
1s after the same paint instead of after the fetch, and right away if
the image can't be shown. The video splash screen still starts at its
first frame, as its page paints before that.

The wait for the content is behind the SplashScreenContentWait feature,
enabled by default, whose SplashScreenContentWait_max_delay param bounds
it (2s by default), so it can be tuned for slower devices. If the
feature is disabled, or the param isn't positive, the minimum starts
when the page loads again, for both the image and the video.
Cobalt.SplashScreen.ContentWaitResult.{Image,Video} records how the
wait ended, under what it waited for: the content showed, the wait
timed out, or Cobalt switched before either, e.g., as the splash screen
closed itself when it couldn't show its image. Switching to the main
WebContents now also ends the wait: if the splash screen closed itself
before its content showed, the end of the wait scheduled another
switch, which hid the main WebContents of a video splash screen.

The image's "content shown" startup metrics now use the first
contentful paint as well, rather than the first visually non-empty
paint, which can be the background alone, and only if the page shows
its image: the page of a video that never started paints its video
element, which counts as contentful before the video's first frame.

Bug: 563221091
TAG=agy
CONV=96668df3-1b7c-46af-b387-71b647fad31c
CONV=92c9a3de-e02e-4df0-afa8-f9713b3b050e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants