Skip to content

cobalt: Move VideoGeometrySetterService on gpu thread#8962

Merged
borongc merged 1 commit intoyoutube:mainfrom
borongc:android_overlay_css_transition
Feb 27, 2026
Merged

cobalt: Move VideoGeometrySetterService on gpu thread#8962
borongc merged 1 commit intoyoutube:mainfrom
borongc:android_overlay_css_transition

Conversation

@borongc
Copy link
Contributor

@borongc borongc commented Feb 4, 2026

Relocate the VideoGeometrySetterService from the browser process to
the GPU process. This change instantiates the service within the
CobaltContentGpuClient, allowing it to be managed directly on the GPU
thread.

This improves performance and reduces IPC overhead for video geometry
updates by co-locating the service closer to the GPU and compositing
operations. The StarboardRendererWrapper now directly subscribes to
video geometry changes from this local service.

Mojo communications:

  • Before: viz (gpu) --> browser thread --> StarboardRendererClient (media) --> StarboardRendererWrapper (gpu)
  • After: viz (gpu) --> StarboardRendererWrapper (gpu)

Note this is called nearly per UI frame update.

Issue: 405424096

@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2026

🤖 Gemini Suggested Commit Message


cobalt: Move VideoGeometrySetterService to GPU

Relocate the VideoGeometrySetterService from the browser process to
the GPU process. This change instantiates the service within the
CobaltContentGpuClient, allowing it to be managed directly on the GPU
thread.

This improves performance and reduces IPC overhead for video geometry
updates by co-locating the service closer to the GPU and compositing
operations. The StarboardRendererWrapper now directly subscribes to
video geometry changes from this local service.

Bug: 405424096

💡 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 force-pushed the android_overlay_css_transition branch 3 times, most recently from fefd10f to 4dd9666 Compare February 18, 2026 21:30
@borongc borongc marked this pull request as ready for review February 18, 2026 21:37
@borongc borongc requested review from a team as code owners February 18, 2026 21:37
@borongc borongc requested review from oxve and removed request for oxve February 18, 2026 21:37
Copy link
Contributor

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

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 successfully moves the VideoGeometrySetterService from the browser process to the GPU process, which should improve performance by reducing IPC overhead. The changes are logical and follow the description. I've found a few areas for improvement: a duplicate dependency, a simplification in a constructor, and a potential behavioral change in how video geometry is calculated that should be reviewed.

@borongc borongc force-pushed the android_overlay_css_transition branch 6 times, most recently from 3890379 to ff107d6 Compare February 19, 2026 19:32
Copy link
Contributor

@sideb0ard sideb0ard left a comment

Choose a reason for hiding this comment

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

This looks great. Do we have any measurement to show the difference in performance and IPC overhead?

@borongc
Copy link
Contributor Author

borongc commented Feb 23, 2026

This looks great. Do we have any measurement to show the difference in performance and IPC overhead?

Latency Breakdown

The "1ms savings" comes from the elimination of the cross-process IPC hop from the Compositor to the Browser.

End-to-End Latency Comparison

  • Before Commit: ~2.5 ms
    • Hop 1 (viz ➡️ Browser): ~1.0 ms to 1.5 ms (Standard Chromium IPC overhead)
    • Hop 2 (Browser ➡️ Media): 1.21 ms (Time waiting on Browser Main thread)
  • After Commit: 1.71 ms
    • Hop 1 (viz ➡️ GPU): 0 ms (Eliminated)
    • Hop 2 (GPU ➡️ Media): 1.71 ms (Direct cross-thread routing)

Jitter & Stability

  • Before Max Jitter: 20.22 ms (Updates frequently arrived >16.6ms late, missing frame windows).
  • After Max Jitter: 17.13 ms (Reduced by >3ms).

Conclusion

By moving the service to the GPU process, the architecture effectively saved ~1ms of average latency per frame. More importantly, it removed the dependency on the Browser UI thread, preventing frames from arriving late due to UI-related processing spikes.

Copy link
Contributor

@Awallky Awallky left a comment

Choose a reason for hiding this comment

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

Would it be possible to set up a cobalt-specific subclasses of content_gpu_client and gpu_service_factory?
It would make future rebases a bit easier in the future if we just subclass them instead of adding to the content layer.

@borongc
Copy link
Contributor Author

borongc commented Feb 26, 2026

Would it be possible to set up a cobalt-specific subclasses of content_gpu_client and gpu_service_factory?

Probably it's not easy as Chromium core code path has this function. Let me know if you think there is a better way to do this.

Relocate the VideoGeometrySetterService from the browser process to
the GPU process. This change instantiates the service within the
CobaltContentGpuClient, allowing it to be managed directly on the GPU
thread.

This improves performance and reduces IPC overhead for video geometry
updates by co-locating the service closer to the GPU and compositing
operations. The StarboardRendererWrapper now directly subscribes to
video geometry changes from this local service.

Mojo communications:
- Before: viz (gpu) --> browser thread --> StarboardRendererClient (media) --> StarboardRendererWrapper (gpu)
- After: viz (gpu) --> StarboardRendererWrapper (gpu)

Note this is called nearly per UI frame update.

Issue: 405424096
@borongc borongc force-pushed the android_overlay_css_transition branch from ff107d6 to 6b7eab9 Compare February 26, 2026 23:18
@borongc borongc requested a review from Awallky February 26, 2026 23:19
@borongc borongc merged commit d1376b1 into youtube:main Feb 27, 2026
618 of 619 checks passed
@borongc borongc deleted the android_overlay_css_transition branch February 27, 2026 02:01
@borongc borongc added cp-26.android Cherry Pick to the 26.android branch cp-26.eap Cherry pick to 26.eap branch labels Feb 27, 2026
cobalt-github-releaser-bot pushed a commit that referenced this pull request Feb 27, 2026
Relocate the VideoGeometrySetterService from the browser process to
the GPU process. This change instantiates the service within the
CobaltContentGpuClient, allowing it to be managed directly on the GPU
thread.

This improves performance and reduces IPC overhead for video geometry
updates by co-locating the service closer to the GPU and compositing
operations. The StarboardRendererWrapper now directly subscribes to
video geometry changes from this local service.

Mojo communications:
- Before: viz (gpu) --> browser thread --> StarboardRendererClient
(media) --> StarboardRendererWrapper (gpu)
- After: viz (gpu) --> StarboardRendererWrapper (gpu)

Note this is called nearly per UI frame update.

Issue: 405424096
(cherry picked from commit d1376b1)
cobalt-github-releaser-bot pushed a commit that referenced this pull request Feb 27, 2026
Relocate the VideoGeometrySetterService from the browser process to
the GPU process. This change instantiates the service within the
CobaltContentGpuClient, allowing it to be managed directly on the GPU
thread.

This improves performance and reduces IPC overhead for video geometry
updates by co-locating the service closer to the GPU and compositing
operations. The StarboardRendererWrapper now directly subscribes to
video geometry changes from this local service.

Mojo communications:
- Before: viz (gpu) --> browser thread --> StarboardRendererClient
(media) --> StarboardRendererWrapper (gpu)
- After: viz (gpu) --> StarboardRendererWrapper (gpu)

Note this is called nearly per UI frame update.

Issue: 405424096
(cherry picked from commit d1376b1)
borongc added a commit that referenced this pull request Feb 27, 2026
Relocate the VideoGeometrySetterService from the browser process to
the GPU process. This change instantiates the service within the
CobaltContentGpuClient, allowing it to be managed directly on the GPU
thread.

This improves performance and reduces IPC overhead for video geometry
updates by co-locating the service closer to the GPU and compositing
operations. The StarboardRendererWrapper now directly subscribes to
video geometry changes from this local service.

Mojo communications:
- Before: viz (gpu) --> browser thread --> StarboardRendererClient
(media) --> StarboardRendererWrapper (gpu)
- After: viz (gpu) --> StarboardRendererWrapper (gpu)

Note this is called nearly per UI frame update.

Issue: 405424096
(cherry picked from commit d1376b1)
borongc added a commit that referenced this pull request Feb 27, 2026
Relocate the VideoGeometrySetterService from the browser process to
the GPU process. This change instantiates the service within the
CobaltContentGpuClient, allowing it to be managed directly on the GPU
thread.

This improves performance and reduces IPC overhead for video geometry
updates by co-locating the service closer to the GPU and compositing
operations. The StarboardRendererWrapper now directly subscribes to
video geometry changes from this local service.

Mojo communications:
- Before: viz (gpu) --> browser thread --> StarboardRendererClient
(media) --> StarboardRendererWrapper (gpu)
- After: viz (gpu) --> StarboardRendererWrapper (gpu)

Note this is called nearly per UI frame update.

Issue: 405424096
(cherry picked from commit d1376b1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cp-26.android Cherry Pick to the 26.android branch cp-26.eap Cherry pick to 26.eap branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants