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

Issue 811967 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Jun 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 2
Type: Bug

Blocking:
issue 732555



Sign in to add a comment

Move Android BeginFrameSource to Viz Process

Project Member Reported by ericrk@chromium.org, Feb 13 2018

Issue description

Currently, Android connects to the Android system choreographer service to provide a BeginFrameSource. We need to move this logic to the Viz process (if the choreographer is available there), or forward this source from the browser process. 

See https://cs.chromium.org/chromium/src/ui/android/window_android.cc?rcl=a904c451f6d4fa29d618433ac051ada79290e9e4&l=27
 

Comment 1 by ericrk@chromium.org, Feb 13 2018

Note that Android currently registers/unregisters the BeginFrameSource on visibility changes. This will need to be updated as well: https://cs.chromium.org/chromium/src/content/browser/renderer_host/compositor_impl_android.cc?rcl=9f16a173c9f23cce777a78db5a278d21bf26258b&l=647
Cc: kylec...@chromium.org briander...@chromium.org
+brianderson suggested an alternative for the GPU process when I looked into BeginFrameSource + viz. We might want to use eglGetCompositorTimingANDROID() from the GPU process, although I think it's limited to newer versions of Android.

https://www.khronos.org/registry/EGL/extensions/ANDROID/EGL_ANDROID_get_frame_timestamps.txt


Cc: samans@chromium.org
Registering/Unregistering BeginFrameSource on visibility doesn't make sense to me. The expensive part of BeginFrameSource is the observers because that causes a timer to be scheduled.
fsamuel: Android doesn't use a timer, it's an OS signal for each OnBeginFrame(). Also the reason it's unregistered is because the viz::Display is destroyed when visibility changes to hidden anyways. The same code to recreate viz::Display and regregister BeginFrameSource gets used in all cases.
Cc: piman@chromium.org
Ohh yea, I vaguely remember this conversation. We supposedly do this to return/save resources? Do we actually know if this is still the case? Won't Display::SetVisible(false) accomplish the desired effect?
Labels: Android-OOPD-Finch
Fady suggested that BeginFrames and CompositorFrameSink can be different message pipes and on Android BeginFrames can come from the browser. I think this idea would work.
Owner: ericrk@chromium.org
Status: Assigned (was: Available)
Going to take a look at this.
Quick update:

It appears that the Choreographer service (which provides VSync / BeginFrame info on Android) can be run in the GPU process. There are two concerns in doing so:

#1 - Choreographer requires that the thread has a Java looper pumping it (not a native message loop). This should be a straightforward change.

#2 - There was concern that Choreographer would run on thread 0, so we'd need to move the Android GPU main thread to be thread 0 (it is currently a random thread we create later). It appears this isn't an issue. Per the docs "Each Looper thread has its own choreographer. Other threads can post callbacks to run on the choreographer but they will run on the Looper to which the choreographer belongs."

So only #1 needs to be addressed and we should be able to handle this in an ideal way. There might be some performance cost to running a Java looper, but hopefully this isn't major.
Project Member

Comment 10 by bugdroid1@chromium.org, Jun 12 2018

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

commit d6b04a16e2ee4091c1355debfaf5e76165a8e7c1
Author: Eric Karl <ericrk@chromium.org>
Date: Tue Jun 12 22:15:28 2018

Android OOP-D: Deliver BeginMainFrames over IPC

Currently, Android OOP-D uses a synthetic begin frame source. This
patch causes Android OOP-D to use the same Android OS driven BFS which
non-OOP-D uses, by sending the signals over an IPC to the Viz process.

A future CL will read this signal directly in the Viz process, but as
this is a riskier change, I wanted to land this first.

Bug:  811967 
Change-Id: I49ace83aa0a9f27ec18f1ca3527bed4666a9ebaa
Reviewed-on: https://chromium-review.googlesource.com/1093520
Commit-Queue: Eric Karl <ericrk@chromium.org>
Reviewed-by: Antoine Labour <piman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#566600}
[modify] https://crrev.com/d6b04a16e2ee4091c1355debfaf5e76165a8e7c1/content/browser/BUILD.gn
[modify] https://crrev.com/d6b04a16e2ee4091c1355debfaf5e76165a8e7c1/content/browser/compositor/external_begin_frame_controller_client_impl.cc
[modify] https://crrev.com/d6b04a16e2ee4091c1355debfaf5e76165a8e7c1/content/browser/compositor/external_begin_frame_controller_client_impl.h
[modify] https://crrev.com/d6b04a16e2ee4091c1355debfaf5e76165a8e7c1/content/browser/renderer_host/compositor_impl_android.cc
[modify] https://crrev.com/d6b04a16e2ee4091c1355debfaf5e76165a8e7c1/content/browser/renderer_host/compositor_impl_android.h
[modify] https://crrev.com/d6b04a16e2ee4091c1355debfaf5e76165a8e7c1/ui/compositor/compositor.h
[modify] https://crrev.com/d6b04a16e2ee4091c1355debfaf5e76165a8e7c1/ui/compositor/external_begin_frame_client.h

Project Member

Comment 11 by bugdroid1@chromium.org, Jun 21 2018

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

commit b2ce0204f34f426de59e14e25edc96269aacea50
Author: Eric Karl <ericrk@chromium.org>
Date: Thu Jun 21 18:36:29 2018

Android OOP-D: Use JavaHandlerThread for Display Compositor

Android OOP-D requires running a Java Choreographer based
BeginFrameSource on the display compositor thread. In order to do this,
this thread must have a Java looper.

This CL adds a looper by converting this thread from a base::Thread
to a base::android::JavaHandlerThread on Android. As we also want to
be able to specify a thread priority for this thread, this patch adds
thread priority support to the JavaHandlerThread class.

Bug:  811967 
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel
Change-Id: I12d39edd5925f33629e91ad17eaf575ed49b0296
Reviewed-on: https://chromium-review.googlesource.com/1109020
Reviewed-by: Khushal <khushalsagar@chromium.org>
Reviewed-by: Yaron Friedman <yfriedman@chromium.org>
Commit-Queue: Eric Karl <ericrk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569333}
[modify] https://crrev.com/b2ce0204f34f426de59e14e25edc96269aacea50/base/android/java/src/org/chromium/base/JavaHandlerThread.java
[modify] https://crrev.com/b2ce0204f34f426de59e14e25edc96269aacea50/base/android/java_handler_thread.cc
[modify] https://crrev.com/b2ce0204f34f426de59e14e25edc96269aacea50/base/android/java_handler_thread.h
[modify] https://crrev.com/b2ce0204f34f426de59e14e25edc96269aacea50/base/test/android/java/src/org/chromium/base/JavaHandlerThreadHelpers.java
[modify] https://crrev.com/b2ce0204f34f426de59e14e25edc96269aacea50/components/viz/service/main/viz_main_impl.cc
[modify] https://crrev.com/b2ce0204f34f426de59e14e25edc96269aacea50/components/viz/service/main/viz_main_impl.h
[modify] https://crrev.com/b2ce0204f34f426de59e14e25edc96269aacea50/content/public/android/java/src/org/chromium/content/browser/LauncherThread.java

Project Member

Comment 12 by bugdroid1@chromium.org, Jun 22 2018

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

commit 59c094f97e16f24039d7c044d4a4ec26b14c2100
Author: Eric Karl <ericrk@chromium.org>
Date: Fri Jun 22 23:08:01 2018

Android OOP-D: ExternalBeginFrame{ControllerImpl => SourceMojo}

Make ExternalBeginFrameControllerImpl implement ExternalBeginFrameSource
directly, and rename to ExternalBeginFrameSourceMojo.

This allows GpuDisplayProvider and RootCompositorFrameSink to deal with
an ExternalBeginFrameSource directly, allowing for alternative
implementations to be dropped in in the future.

To allow this, Display assignment is moved from RootCompositorFrameSink
and a new DisplayObserver callback is added to handle cleanup/lifetime.

Bug:  811967 
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel
Change-Id: I3e1475ebe6338eef4bbee5d98a06a4215c254485
Reviewed-on: https://chromium-review.googlesource.com/1109027
Commit-Queue: Eric Karl <ericrk@chromium.org>
Reviewed-by: danakj <danakj@chromium.org>
Reviewed-by: kylechar <kylechar@chromium.org>
Reviewed-by: Saman Sami <samans@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569823}
[modify] https://crrev.com/59c094f97e16f24039d7c044d4a4ec26b14c2100/components/viz/common/frame_sinks/begin_frame_source.cc
[modify] https://crrev.com/59c094f97e16f24039d7c044d4a4ec26b14c2100/components/viz/common/frame_sinks/begin_frame_source.h
[modify] https://crrev.com/59c094f97e16f24039d7c044d4a4ec26b14c2100/components/viz/service/BUILD.gn
[modify] https://crrev.com/59c094f97e16f24039d7c044d4a4ec26b14c2100/components/viz/service/display/display.cc
[modify] https://crrev.com/59c094f97e16f24039d7c044d4a4ec26b14c2100/components/viz/service/display/display.h
[modify] https://crrev.com/59c094f97e16f24039d7c044d4a4ec26b14c2100/components/viz/service/display_embedder/DEPS
[modify] https://crrev.com/59c094f97e16f24039d7c044d4a4ec26b14c2100/components/viz/service/display_embedder/display_provider.h
[delete] https://crrev.com/fe3eaf210ae31aa6a657d9d879cfd24016d55c82/components/viz/service/display_embedder/external_begin_frame_controller_impl.cc
[modify] https://crrev.com/59c094f97e16f24039d7c044d4a4ec26b14c2100/components/viz/service/display_embedder/gpu_display_provider.cc
[modify] https://crrev.com/59c094f97e16f24039d7c044d4a4ec26b14c2100/components/viz/service/display_embedder/gpu_display_provider.h
[add] https://crrev.com/59c094f97e16f24039d7c044d4a4ec26b14c2100/components/viz/service/frame_sinks/external_begin_frame_source_mojo.cc
[rename] https://crrev.com/59c094f97e16f24039d7c044d4a4ec26b14c2100/components/viz/service/frame_sinks/external_begin_frame_source_mojo.h
[modify] https://crrev.com/59c094f97e16f24039d7c044d4a4ec26b14c2100/components/viz/service/frame_sinks/frame_sink_manager_impl.cc
[modify] https://crrev.com/59c094f97e16f24039d7c044d4a4ec26b14c2100/components/viz/service/frame_sinks/root_compositor_frame_sink_impl.cc
[modify] https://crrev.com/59c094f97e16f24039d7c044d4a4ec26b14c2100/components/viz/service/frame_sinks/root_compositor_frame_sink_impl.h
[modify] https://crrev.com/59c094f97e16f24039d7c044d4a4ec26b14c2100/components/viz/test/test_display_provider.cc
[modify] https://crrev.com/59c094f97e16f24039d7c044d4a4ec26b14c2100/components/viz/test/test_display_provider.h
[modify] https://crrev.com/59c094f97e16f24039d7c044d4a4ec26b14c2100/content/browser/compositor/gpu_process_transport_factory.cc

What's the status of this? Is this done or is there more work to do?
Project Member

Comment 14 by bugdroid1@chromium.org, Jun 26 2018

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

commit b139512f34e1fa9777475d7642d63a8e59dcba47
Author: Eric Karl <ericrk@chromium.org>
Date: Tue Jun 26 20:15:41 2018

Android OOP-D: Add ExternalBeginFrameSourceAndroid

Provides an Android Choreographer based ExternalBeginFrameSource
implementation. Allows the Viz process to produce frames in the same
manner as previously done in the Browser process.

Removes the IPC-based ExternalBeginFrameSource from CompositorImpl.

Bug:  811967 
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel
Change-Id: Ibf65969e2a6ddd0a9892aac99aea329ae99b94a5
Reviewed-on: https://chromium-review.googlesource.com/1109198
Reviewed-by: Khushal <khushalsagar@chromium.org>
Reviewed-by: Saman Sami <samans@chromium.org>
Reviewed-by: agrieve <agrieve@chromium.org>
Commit-Queue: Eric Karl <ericrk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#570510}
[modify] https://crrev.com/b139512f34e1fa9777475d7642d63a8e59dcba47/chrome/BUILD.gn
[modify] https://crrev.com/b139512f34e1fa9777475d7642d63a8e59dcba47/chrome/android/BUILD.gn
[modify] https://crrev.com/b139512f34e1fa9777475d7642d63a8e59dcba47/components/viz/BUILD.gn
[modify] https://crrev.com/b139512f34e1fa9777475d7642d63a8e59dcba47/components/viz/service/BUILD.gn
[modify] https://crrev.com/b139512f34e1fa9777475d7642d63a8e59dcba47/components/viz/service/DEPS
[modify] https://crrev.com/b139512f34e1fa9777475d7642d63a8e59dcba47/components/viz/service/frame_sinks/DEPS
[add] https://crrev.com/b139512f34e1fa9777475d7642d63a8e59dcba47/components/viz/service/frame_sinks/external_begin_frame_source_android.cc
[add] https://crrev.com/b139512f34e1fa9777475d7642d63a8e59dcba47/components/viz/service/frame_sinks/external_begin_frame_source_android.h
[add] https://crrev.com/b139512f34e1fa9777475d7642d63a8e59dcba47/components/viz/service/frame_sinks/external_begin_frame_source_android_unittest.cc
[modify] https://crrev.com/b139512f34e1fa9777475d7642d63a8e59dcba47/components/viz/service/frame_sinks/frame_sink_manager_impl.cc
[add] https://crrev.com/b139512f34e1fa9777475d7642d63a8e59dcba47/components/viz/service/java/src/org/chromium/components/viz/service/frame_sinks/ExternalBeginFrameSourceAndroid.java
[modify] https://crrev.com/b139512f34e1fa9777475d7642d63a8e59dcba47/components/viz/service/main/viz_main_impl.cc
[modify] https://crrev.com/b139512f34e1fa9777475d7642d63a8e59dcba47/content/browser/renderer_host/compositor_impl_android.cc
[modify] https://crrev.com/b139512f34e1fa9777475d7642d63a8e59dcba47/content/browser/renderer_host/compositor_impl_android.h
[modify] https://crrev.com/b139512f34e1fa9777475d7642d63a8e59dcba47/content/test/BUILD.gn

Status: Fixed (was: Assigned)
Re #13 - now it's done :D

Sign in to add a comment