New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 889328 link

Starred by 4 users

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 2
Type: Feature



Sign in to add a comment

Use SurfaceControl for video overlays on Android.

Project Member Reported by khushals...@chromium.org, Sep 26

Issue description

This is the tracking bug for all work for using the new SurfaceControl API on Android for promoting videos to overlays.
 
Project Member

Comment 1 by bugdroid1@chromium.org, Oct 2

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6

commit bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6
Author: Khushal <khushalsagar@google.com>
Date: Tue Oct 02 21:02:35 2018

gpu: Add basic implementation for using SurfaceControl on Android.

This change adds the basic framework for using SurfaceControl to manage
the buffer queue for the DisplayCompositor on Android. This includes the
following additions.

1) Adding the ABI for loading functions for the SurfaceControl API at
runtime in base::android::SurfaceComposer. This allows us to create
transactions for presenting buffers parented to the ANativeWindow in the
GPU process.

2) Use GLOutputSurfaceBufferQueue to maintain a queue of buffers in the
viz display compositor that are sent as overlays to the GPU main thread.
This is used based on whether the GLSurface is marked surfaceless, set
by the ImageTransportSurfaceOverlayAndroid.

3) Add an implementation of GLSurface for Android which collects a list
of overlays to send to the framework and sends it in a single transaction
to ensure the updates are made atomically.

A few capabilities are missing in the implementation, for instance setting
a transform on the overlay, getting transaction acks for correctly
synchronizing reuse of buffers, as these are still a WIP on the NDK API.

R=ericrk@chromium.org, piman@chromium.org, yfriedman@chromium.org

Bug: 889328
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: I1634e379626ac7b2a08c96dccc6cd767c9dce154
Reviewed-on: https://chromium-review.googlesource.com/c/1250212
Reviewed-by: Eric Karl <ericrk@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Antoine Labour <piman@chromium.org>
Reviewed-by: Yaron Friedman <yfriedman@chromium.org>
Commit-Queue: Khushal <khushalsagar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595976}
[modify] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/base/android/scoped_hardware_buffer_handle.cc
[modify] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/base/android/scoped_hardware_buffer_handle.h
[modify] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/chrome/browser/about_flags.cc
[modify] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/chrome/browser/flag_descriptions.cc
[modify] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/chrome/browser/flag_descriptions.h
[modify] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/components/viz/service/BUILD.gn
[add] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/components/viz/service/display_embedder/gl_output_surface_buffer_queue_android.cc
[add] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/components/viz/service/display_embedder/gl_output_surface_buffer_queue_android.h
[modify] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/components/viz/service/display_embedder/gpu_display_provider.cc
[modify] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/components/viz/service/display_embedder/viz_process_context_provider.cc
[modify] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/components/viz/service/display_embedder/viz_process_context_provider.h
[modify] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/content/browser/gpu/compositor_util.cc
[modify] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/content/browser/gpu/compositor_util.h
[modify] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/content/browser/resources/gpu/info_view.js
[modify] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/content/public/browser/gpu_utils.cc
[modify] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/gpu/command_buffer/service/feature_info.cc
[modify] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/gpu/command_buffer/service/feature_info.h
[modify] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/gpu/config/gpu_blacklist.cc
[modify] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/gpu/config/gpu_feature_type.h
[modify] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/gpu/config/gpu_finch_features.cc
[modify] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/gpu/config/gpu_finch_features.h
[modify] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/gpu/config/gpu_preferences.h
[modify] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/gpu/config/gpu_switches.h
[modify] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/gpu/config/gpu_util.cc
[modify] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/gpu/ipc/common/gpu_preferences.mojom
[modify] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/gpu/ipc/common/gpu_preferences_struct_traits.h
[modify] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/gpu/ipc/service/gpu_memory_buffer_factory_android_hardware_buffer.cc
[modify] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/gpu/ipc/service/gpu_memory_buffer_factory_android_hardware_buffer.h
[modify] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/gpu/ipc/service/image_transport_surface_android.cc
[modify] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/tools/metrics/histograms/enums.xml
[modify] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/ui/gl/BUILD.gn
[add] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/ui/gl/android/android_surface_composer_compat.cc
[add] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/ui/gl/android/android_surface_composer_compat.h
[modify] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/ui/gl/gl_image.h
[modify] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/ui/gl/gl_image_ahardwarebuffer.cc
[modify] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/ui/gl/gl_image_ahardwarebuffer.h
[add] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/ui/gl/gl_surface_egl_surface_control.cc
[add] https://crrev.com/bb1963ac2c7fa633b72249990a6c8bc34f2fb0c6/ui/gl/gl_surface_egl_surface_control.h

Cc: sohanjg@chromium.org
Hi Khushal. Is there an explanation for the choice of SurfaceControl API for android video overlays ? Is it for supporting AImageReader?
The use of SurfaceControl is to allow synchronizing changes to the rest of web content (scrolling for example) with the overlay. Right now the main web content is updated by chrome's composition while the overlay is positioned in java by re-positioning the elements in the UI. SurfaceControl gives us a way to apply these changes atomically.
Oh thats exciting ! so embedded videos could be now promoted to overlays ?

Some time back i was trying to promote content quads/tiles in Android to overlays of course for power saving reasons, that can be a possibility now ?
But arent the number of overlay still limited ?
Yes, that's the primary aim. We can promote embedded videos to overlays.

It also opens the possibility of using overlays for tiles. The limit on the number of overlays, depending on the device, might end up meaning that the framework itself has to fallback to GPU composition but at least the decision can be deferred until the end of the pipeline in the framework. And we'd expect it to be no worse than a composition in chrome with a single overlay sent to the framework.

But to begin with we're targeting video overlays which should definitely be a win and should keep us within the overlay limit for a larger number of devices. And setting up the groundwork to try it for other cases with a lot of dynamic content (like canvas) and potentially tile quads.
Cc: marissaw@google.com
With https://chromium-review.googlesource.com/c/chromium/src/+/1258383, the overall framework should be in place. Making a note of a few things for follow up patches:

1) Plumbing is needed to choose the correct the format/usage for secure media when creating the AImageReader. Digging up so far makes it look like a combination of AIMAGE_FORMAT_PRIVATE and AHARDWAREBUFFER_USAGE_PROTECTED_CONTENT should work but still need to validate with the plumbing.

2) Need to make sure AVDACodecImage works. This includes plumbing to disable java overlays and pulling out the AHardwareBuffer from it similar to CodecImage.

3) We shouldn't be binding the texture in ImageReaderTextureOwner when we're using overlays. This will need a public API on TextureOwner for doing this only when the image can't be overlayed.

4) The framework is adding an additional solid color layer in the HwC when using video overlay, presumably because we mark the main surface translucent when a video underlay is present. Using OverlayStrategySingleOnTop avoids it because in that case the video overlay is placed on top of the main overlay avoiding anything to be marked translucent.
The curious part is that this is dependent on the PixelFormat we choose for the surface in java. Using PixelFormat.Opaque, which we use by default, adds it but PixelFromat.Translucent does not.
The easiest thing most likely is to use PixelFromat.Translucent with SurfaceControl but also good to understand this better first.

Project Member

Comment 7 by bugdroid1@chromium.org, Oct 9

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/a55414af4fda5ae7f62781925783ee6728d0c341

commit a55414af4fda5ae7f62781925783ee6728d0c341
Author: Khushal <khushalsagar@google.com>
Date: Tue Oct 09 17:13:53 2018

gpu: Use SurfaceControl for media overlays on Android.

This change adds the ability to use overlays on SurfaceControl for video
quads. The strategy is as follows:

1) In AndroidVideoSurfaceChooser, make sure we always use TextureOwner
and not the path for java overlays. Using a TextureOwner backed by an
AImageReader means we can defer the decision to promote this buffer to
an overlay to the display compositor.

2) The OverlayCandidateValidator used by the OutputSurface should now
be able to promote any candidate if its marked overlayable.

3) When acquiring the buffer from the AImageReader for the current
video frame, make sure to forward the fence provided by the reader.
The release of this buffer back to the reader is also deferred until
the next frame is acked by the framework.

BUG:889328
R=ericrk@chromium.org, liberato@chromium.org, piman@chromium.org

Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: Ia44ea8256ca762bab51eb4a874bd1887b3aa756d
Reviewed-on: https://chromium-review.googlesource.com/c/1258383
Reviewed-by: Frank Liberato <liberato@chromium.org>
Reviewed-by: Antoine Labour <piman@chromium.org>
Commit-Queue: Khushal <khushalsagar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#597958}
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/components/viz/service/display/overlay_strategy_underlay.cc
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/components/viz/service/display_embedder/gl_output_surface_buffer_queue_android.cc
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/content/gpu/gpu_child_thread.cc
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/content/gpu/gpu_service_factory.cc
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/content/gpu/gpu_service_factory.h
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/gpu/config/gpu_util.cc
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/media/gpu/BUILD.gn
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/media/gpu/android/android_video_decode_accelerator.cc
[add] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/media/gpu/android/android_video_surface_chooser.cc
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/media/gpu/android/android_video_surface_chooser.h
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/media/gpu/android/android_video_surface_chooser_impl.cc
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/media/gpu/android/android_video_surface_chooser_impl_unittest.cc
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/media/gpu/android/codec_image.cc
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/media/gpu/android/codec_image.h
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/media/gpu/android/codec_image_unittest.cc
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/media/gpu/android/image_reader_gl_owner.cc
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/media/gpu/android/image_reader_gl_owner.h
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/media/gpu/android/media_codec_video_decoder.cc
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/media/gpu/android/media_codec_video_decoder.h
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/media/gpu/android/media_codec_video_decoder_unittest.cc
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/media/gpu/android/mock_texture_owner.h
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/media/gpu/android/surface_chooser_helper.cc
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/media/gpu/android/surface_chooser_helper.h
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/media/gpu/android/surface_chooser_helper_unittest.cc
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/media/gpu/android/surface_texture_gl_owner.cc
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/media/gpu/android/surface_texture_gl_owner.h
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/media/gpu/android/texture_owner.h
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/media/gpu/android/video_frame_factory.h
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/media/gpu/android/video_frame_factory_impl.cc
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/media/gpu/android/video_frame_factory_impl.h
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/media/mojo/services/gpu_mojo_media_client.cc
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/media/mojo/services/gpu_mojo_media_client.h
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/media/mojo/services/media_service_factory.cc
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/media/mojo/services/media_service_factory.h
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/ui/gl/gl_image.cc
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/ui/gl/gl_image.h
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/ui/gl/gl_image_ahardwarebuffer.cc
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/ui/gl/gl_image_ahardwarebuffer.h
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/ui/gl/gl_surface_egl_surface_control.cc
[modify] https://crrev.com/a55414af4fda5ae7f62781925783ee6728d0c341/ui/gl/gl_surface_egl_surface_control.h

Also need to make sure to use rgb565 for low end devices.
Project Member

Comment 9 by bugdroid1@chromium.org, Nov 28

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/5c21ea63ff279462beeff9b24048d4a055ba4f59

commit 5c21ea63ff279462beeff9b24048d4a055ba4f59
Author: Khushal <khushalsagar@chromium.org>
Date: Wed Nov 28 21:20:15 2018

gl/android: Update SurfaceControl impl based on NDK updates.

Update the SurfaceControl ABI based on NDK changes and hook up
transaction acks from the framework for GLSurface swap acks.

Change-Id: I7919bbe97cc621c1912657ed4c1894ede8308fab
Bug: 889328
Reviewed-on: https://chromium-review.googlesource.com/c/1347792
Reviewed-by: Eric Karl <ericrk@chromium.org>
Reviewed-by: Antoine Labour <piman@chromium.org>
Commit-Queue: Khushal <khushalsagar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611870}
[modify] https://crrev.com/5c21ea63ff279462beeff9b24048d4a055ba4f59/components/viz/service/display_embedder/gl_output_surface_buffer_queue_android.cc
[modify] https://crrev.com/5c21ea63ff279462beeff9b24048d4a055ba4f59/gpu/config/gpu_util.cc
[modify] https://crrev.com/5c21ea63ff279462beeff9b24048d4a055ba4f59/gpu/ipc/service/image_transport_surface_android.cc
[modify] https://crrev.com/5c21ea63ff279462beeff9b24048d4a055ba4f59/ui/gl/BUILD.gn
[delete] https://crrev.com/87bfbed5e3e107c5a97af66b67e9aabaf6aa9863/ui/gl/android/android_surface_composer_compat.cc
[delete] https://crrev.com/87bfbed5e3e107c5a97af66b67e9aabaf6aa9863/ui/gl/android/android_surface_composer_compat.h
[add] https://crrev.com/5c21ea63ff279462beeff9b24048d4a055ba4f59/ui/gl/android/android_surface_control_compat.cc
[add] https://crrev.com/5c21ea63ff279462beeff9b24048d4a055ba4f59/ui/gl/android/android_surface_control_compat.h
[modify] https://crrev.com/5c21ea63ff279462beeff9b24048d4a055ba4f59/ui/gl/gl_surface_egl_surface_control.cc
[modify] https://crrev.com/5c21ea63ff279462beeff9b24048d4a055ba4f59/ui/gl/gl_surface_egl_surface_control.h

Project Member

Comment 10 by bugdroid1@chromium.org, Jan 18 (4 days ago)

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/0bdd33988643df3ba2c772fca2f930f34c4f51c7

commit 0bdd33988643df3ba2c772fca2f930f34c4f51c7
Author: Khushal <khushalsagar@chromium.org>
Date: Fri Jan 18 18:57:21 2019

ui/gl [android]: Update NDK ABI for SurfaceControl.

Update NDK ABI used for SurfaceControl based on internal updates. The
non-mechanical changes are:

1) Support overlay transforms now that the NDK API supports it.
2) Use present fences returned in transaction callbacks for
synchronizing resource reuse with the framework.

R=piman@chromium.org

Bug: 889328
Change-Id: I78afef841cd08711b2581c1b818ca581176291d5
Reviewed-on: https://chromium-review.googlesource.com/c/1419255
Reviewed-by: Antoine Labour <piman@chromium.org>
Commit-Queue: Khushal <khushalsagar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#624220}
[modify] https://crrev.com/0bdd33988643df3ba2c772fca2f930f34c4f51c7/components/viz/service/display_embedder/gl_output_surface_buffer_queue_android.cc
[modify] https://crrev.com/0bdd33988643df3ba2c772fca2f930f34c4f51c7/ui/gl/android/android_surface_control_compat.cc
[modify] https://crrev.com/0bdd33988643df3ba2c772fca2f930f34c4f51c7/ui/gl/android/android_surface_control_compat.h
[modify] https://crrev.com/0bdd33988643df3ba2c772fca2f930f34c4f51c7/ui/gl/gl_surface_egl_surface_control.cc
[modify] https://crrev.com/0bdd33988643df3ba2c772fca2f930f34c4f51c7/ui/gl/gl_surface_egl_surface_control.h

Sign in to add a comment