|
|
Created:
4 years ago by Eric Seckler Modified:
4 years ago CC:
chromium-reviews, yusukes+watch_chromium.org, shuchen+watch_chromium.org, jam, nona+watch_chromium.org, darin-cc_chromium.org, James Su, sunnyps, danakj, enne (OOO), brianderson, Sami Target Ref:
refs/pending/heads/master Project:
chromium Visibility:
Public. |
Description[android] Make RWHVAndroid a BeginFrameObserver.
Instead of directly observing the Window's vsyncs, RWHVAndroid now
observes a BeginFrameSource provided by the DelegatedFrameHost (clank)
or WindowAndroid (webview). To enable this, the BeginFrameSource
originally provided by CompositorImpl moves into WindowAndroid.
The patch also makes some changes to the BeginFrameSource's observer
iteration that are necessary to support
SynchronousBrowserCompositorFilter.
BUG=401336, 675289
Committed: https://crrev.com/1a6bd5037fc10e45646715d675e63146d23fc28d
Committed: https://crrev.com/8c15fc3eb477cc05d742736cee65b6ea7e1c5f84
Cr-Original-Commit-Position: refs/heads/master@{#439072}
Cr-Commit-Position: refs/heads/master@{#439877}
Patch Set 1 : . #
Total comments: 30
Patch Set 2 : Address Bo's comments. #Patch Set 3 : Address Bo's comments pt2. #
Total comments: 2
Patch Set 4 : Fix ordering in Add/ClearBeginFrameRequest. #Patch Set 5 : fix crbug.com/675289 #
Total comments: 3
Patch Set 6 : fix comment #Patch Set 7 : add todo #Patch Set 8 : rebase #Messages
Total messages: 88 (55 generated)
The CQ bit was checked by eseckler@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: cast_shell_android on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/cast_shell_a...)
The CQ bit was checked by eseckler@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_android_rel_ng on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/linux_androi...)
The CQ bit was checked by eseckler@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
eseckler@chromium.org changed reviewers: + boliu@chromium.org
Bo, Do you want to have a first go at this? :)
Patchset #1 (id:1) has been deleted
Patchset #1 (id:20001) has been deleted
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
https://codereview.chromium.org/2564403002/diff/40001/content/browser/android... File content/browser/android/synchronous_compositor_browser_filter.cc (right): https://codereview.chromium.org/2564403002/diff/40001/content/browser/android... content/browser/android/synchronous_compositor_browser_filter.cc:220: static cc::BeginFrameArgs args; static is overkill https://codereview.chromium.org/2564403002/diff/40001/content/browser/rendere... File content/browser/renderer_host/render_widget_host_view_android.cc (right): https://codereview.chromium.org/2564403002/diff/40001/content/browser/rendere... content/browser/renderer_host/render_widget_host_view_android.cc:857: // the current vsync phase. I think previous comment is fine. RWHVA could already be observing begin frames, in which case the missed frame won't help. Also looking at https://codereview.chromium.org/1879833002 when the MISSED frame behavior was added, it was more for the browser compositor rather than the renderer one. https://codereview.chromium.org/2564403002/diff/40001/content/browser/rendere... content/browser/renderer_host/render_widget_host_view_android.cc:1444: DCHECK(this); hmm? https://codereview.chromium.org/2564403002/diff/40001/content/browser/rendere... content/browser/renderer_host/render_widget_host_view_android.cc:1453: DCHECK(windowAndroid); So windowAndroid pointer can change throughout the lifetime of the RWHVA, and the start/stopObservingWindowAndroid calls roughly corresponds to when the window android is set/unset For the webview case, I think this is still handled correctly. What's not clear for me is for chrome after begin frame is unified, will the begin frame source ever change, even when the windowAndroid changes? And does the begin frame call still go through windowAndroid? If not, then technically, this DCHECK isn't really valid for chrome anymore. If yes, then will need to ensure that sequence still works correctly https://codereview.chromium.org/2564403002/diff/40001/content/browser/rendere... content/browser/renderer_host/render_widget_host_view_android.cc:1520: DCHECK_EQ(nullptr, begin_frame_source_); nit: DCHECK(!begin_frame_source_)? https://codereview.chromium.org/2564403002/diff/40001/content/browser/rendere... content/browser/renderer_host/render_widget_host_view_android.cc:1910: if (observing_root_window_) { this should not be needed, this still comes from the attached WindowAndroid, so this should always be true here, hopefully does this not hold anymore? that could indicate a bug (that I'm not seeing..) https://codereview.chromium.org/2564403002/diff/40001/ui/android/window_andro... File ui/android/window_android.cc (right): https://codereview.chromium.org/2564403002/diff/40001/ui/android/window_andro... ui/android/window_android.cc:57: DCHECK(observers_.find(obs) == observers_.end()); nit: use base::ContainsKey? more readable https://codereview.chromium.org/2564403002/diff/40001/ui/android/window_andro... ui/android/window_android.cc:63: // Send a MISSED BeginFrame if possible and necessary. If an observer is added any reason this is needed? https://codereview.chromium.org/2564403002/diff/40001/ui/android/window_andro... ui/android/window_android.cc:84: DCHECK(observers_.find(obs) != observers_.end()); ditto ContainsKey https://codereview.chromium.org/2564403002/diff/40001/ui/android/window_andro... ui/android/window_android.cc:110: while (observer_was_notified) { any reason we don't keep using base::ObserverList and keep getting this behavior for free? https://codereview.chromium.org/2564403002/diff/40001/ui/android/window_andro... File ui/android/window_android.h (right): https://codereview.chromium.org/2564403002/diff/40001/ui/android/window_andro... ui/android/window_android.h:69: void SetNeedsBeginFrames(bool needs_begin_frames); private, and friend WindowBeginFrameSource?
Patchset #2 (id:60001) has been deleted
Thanks, Bo! https://codereview.chromium.org/2564403002/diff/40001/content/browser/android... File content/browser/android/synchronous_compositor_browser_filter.cc (right): https://codereview.chromium.org/2564403002/diff/40001/content/browser/android... content/browser/android/synchronous_compositor_browser_filter.cc:220: static cc::BeginFrameArgs args; On 2016/12/12 21:41:48, boliu wrote: > static is overkill hmm, this returns a reference - don't think I can return a reference to a local var without the compiler complaining? https://codereview.chromium.org/2564403002/diff/40001/content/browser/rendere... File content/browser/renderer_host/render_widget_host_view_android.cc (right): https://codereview.chromium.org/2564403002/diff/40001/content/browser/rendere... content/browser/renderer_host/render_widget_host_view_android.cc:857: // the current vsync phase. On 2016/12/12 21:41:48, boliu wrote: > I think previous comment is fine. > > RWHVA could already be observing begin frames, in which case the missed frame > won't help. Also looking at https://codereview.chromium.org/1879833002 when the > MISSED frame behavior was added, it was more for the browser compositor rather > than the renderer one. Ok, reverted. We probably don't want to get rid of missed frames entirely, see below. https://codereview.chromium.org/2564403002/diff/40001/content/browser/rendere... content/browser/renderer_host/render_widget_host_view_android.cc:1444: DCHECK(this); On 2016/12/12 21:41:48, boliu wrote: > hmm? thanks, was debugging here.. removed :) https://codereview.chromium.org/2564403002/diff/40001/content/browser/rendere... content/browser/renderer_host/render_widget_host_view_android.cc:1453: DCHECK(windowAndroid); On 2016/12/12 21:41:48, boliu wrote: > So windowAndroid pointer can change throughout the lifetime of the RWHVA, and > the start/stopObservingWindowAndroid calls roughly corresponds to when the > window android is set/unset > > For the webview case, I think this is still handled correctly. > > What's not clear for me is for chrome after begin frame is unified, will the > begin frame source ever change, even when the windowAndroid changes? And does > the begin frame call still go through windowAndroid? > > If not, then technically, this DCHECK isn't really valid for chrome anymore. > > If yes, then will need to ensure that sequence still works correctly In android-chrome, there's a direct relationship between a WindowAndroid and cc::Display (one CompositorImpl instance, which owns cc::Display, per WindowAndroid). The cc::Display receives the WindowAndroid's BFS, and registers it at SurfaceManager, which then distributes it to SurfaceFactoryClients, one of which is DelegatedFrameHostAndroid. Thus, in chrome: - The BFS of RWHVAndroid changes when WindowAndroid changes. - The BFS provided by WindowAndroid feeds both the browser compositor (cc::Display) and (possibly multiple) RWHVAndroid. Irrespective of this, I'm not sure if the behavior you saw in crbug.com/639868 may still occur - and whether this check is still needed. In tests, the DCHECK(windowAndroid) isn't hit - but it probably didn't earlier either. https://codereview.chromium.org/2564403002/diff/40001/content/browser/rendere... content/browser/renderer_host/render_widget_host_view_android.cc:1520: DCHECK_EQ(nullptr, begin_frame_source_); On 2016/12/12 21:41:48, boliu wrote: > nit: DCHECK(!begin_frame_source_)? Done. https://codereview.chromium.org/2564403002/diff/40001/content/browser/rendere... content/browser/renderer_host/render_widget_host_view_android.cc:1910: if (observing_root_window_) { On 2016/12/12 21:41:48, boliu wrote: > this should not be needed, this still comes from the attached WindowAndroid, so > this should always be true here, hopefully > > does this not hold anymore? that could indicate a bug (that I'm not seeing..) I think this was a preexisting bug. What you say amounts to |view_.GetWindowAndroid()| not being null. But we only observe the window if it is actually showing. Thus, there are valid cases for |observing_root_window_| to be false here. (And since Register/UnregisterFrameSinkHierarchy is coupled to Start/StopObservingRootWindow, we should only RegisterFrameSinkHierarchy here if |observing_root_window_| is true.) Previously, this wouldn't have made much of a difference, I suppose. But now, we receive the BFS from |delegated_frame_host_| if we RegisterFrameSinkHierarchy(). As a result, we wouldn't necessarily de-register it later because StopObservingRootWindow() might early-out because |!observing_root_window_|, which might leave our pointer dangling (and if I recall correctly, this happened in some tests). I can remove this again and see which (if any) tests fail if that's of interest to you. https://codereview.chromium.org/2564403002/diff/40001/ui/android/window_andro... File ui/android/window_android.cc (right): https://codereview.chromium.org/2564403002/diff/40001/ui/android/window_andro... ui/android/window_android.cc:57: DCHECK(observers_.find(obs) == observers_.end()); On 2016/12/12 21:41:48, boliu wrote: > nit: use base::ContainsKey? more readable Done. https://codereview.chromium.org/2564403002/diff/40001/ui/android/window_andro... ui/android/window_android.cc:63: // Send a MISSED BeginFrame if possible and necessary. If an observer is added On 2016/12/12 21:41:48, boliu wrote: > any reason this is needed? I'm somewhat new to BeginFrames myself, so brianderson@ might correct me here. Since this source also feeds the DisplayScheduler, I don't think we can get rid of missed BeginFrames. Here an attempt at an explanation :) One note on background of (missed) BeginFrames vs. vsyncs: WindowAndroidObservers don't remove themselves when they aren't interested in BeginFrames, while BeginFrameObservers do. Thus, with WindowAndroidObservers, even if just one observer requests a vsync, all observers will be notified of it through OnVSync(). With BeginFrameObservers, this is not the case: Only those that are interested will receive it. Some observers may awake during a vsync interval (i.e. decide that they need a BeginFrame afterall) -- and for those, receiving a MISSED BeginFrame might be advantageous. In the android-chrome case, I think one such BeginFrameObserver is the DisplayScheduler: It may go idle (remove itself as observer) when a BeginFrame doesn't lead to a DrawAndSwap. Later, it will awake again (add itself as observer) when damage to a surface is detected. It'll then receive a MISSED BeginFrame for the currently active BeginFrame and (likely) DrawAndSwap the surface damage during that BeginFrame's deadline. If it didn't receive the missed BeginFrame, it'd have to wait until the next BeginFrame's deadline. https://codereview.chromium.org/2564403002/diff/40001/ui/android/window_andro... ui/android/window_android.cc:84: DCHECK(observers_.find(obs) != observers_.end()); On 2016/12/12 21:41:48, boliu wrote: > ditto ContainsKey Done. https://codereview.chromium.org/2564403002/diff/40001/ui/android/window_andro... ui/android/window_android.cc:110: while (observer_was_notified) { On 2016/12/12 21:41:48, boliu wrote: > any reason we don't keep using base::ObserverList and keep getting this behavior > for free? For two (rather subjective) reasons: 1) This makes it explicit that SyncCompBrowserFilter is supported. 2) We get an immediate feedback about whether |observers_| is empty during RemoveObserver() -- which we wouldn't get with base::ObserverList. That said, I think we could also use base::ObserverList and solve 1) by adding a comment somewhere. 2) by checking after observer iteration in OnVSync() whether the list became empty during the iteration. WDYT? https://codereview.chromium.org/2564403002/diff/40001/ui/android/window_andro... File ui/android/window_android.h (right): https://codereview.chromium.org/2564403002/diff/40001/ui/android/window_andro... ui/android/window_android.h:69: void SetNeedsBeginFrames(bool needs_begin_frames); On 2016/12/12 21:41:48, boliu wrote: > private, and friend WindowBeginFrameSource? Done.
haven't looked at new code yet, just replying to comments https://codereview.chromium.org/2564403002/diff/40001/content/browser/android... File content/browser/android/synchronous_compositor_browser_filter.cc (right): https://codereview.chromium.org/2564403002/diff/40001/content/browser/android... content/browser/android/synchronous_compositor_browser_filter.cc:220: static cc::BeginFrameArgs args; On 2016/12/13 10:03:55, Eric Seckler wrote: > On 2016/12/12 21:41:48, boliu wrote: > > static is overkill > > hmm, this returns a reference - don't think I can return a reference to a local > var without the compiler complaining? Doh, yeah, ok. But then I think this causes a static initializer, which is supposed to be banned (I'm not sure if there are bots on android that checks this though) Just use a member variable https://codereview.chromium.org/2564403002/diff/40001/content/browser/rendere... File content/browser/renderer_host/render_widget_host_view_android.cc (right): https://codereview.chromium.org/2564403002/diff/40001/content/browser/rendere... content/browser/renderer_host/render_widget_host_view_android.cc:1453: DCHECK(windowAndroid); On 2016/12/13 10:03:56, Eric Seckler wrote: > On 2016/12/12 21:41:48, boliu wrote: > > So windowAndroid pointer can change throughout the lifetime of the RWHVA, and > > the start/stopObservingWindowAndroid calls roughly corresponds to when the > > window android is set/unset > > > > For the webview case, I think this is still handled correctly. > > > > What's not clear for me is for chrome after begin frame is unified, will the > > begin frame source ever change, even when the windowAndroid changes? And does > > the begin frame call still go through windowAndroid? > > > > If not, then technically, this DCHECK isn't really valid for chrome anymore. > > > > If yes, then will need to ensure that sequence still works correctly > > In android-chrome, there's a direct relationship between a WindowAndroid and > cc::Display (one CompositorImpl instance, which owns cc::Display, per > WindowAndroid). The cc::Display receives the WindowAndroid's BFS, and registers > it at SurfaceManager, which then distributes it to SurfaceFactoryClients, one of > which is DelegatedFrameHostAndroid. > > Thus, in chrome: > - The BFS of RWHVAndroid changes when WindowAndroid changes. > - The BFS provided by WindowAndroid feeds both the browser compositor > (cc::Display) and (possibly multiple) RWHVAndroid. > > Irrespective of this, I'm not sure if the behavior you saw in crbug.com/639868 > may still occur - and whether this check is still needed. In tests, the > DCHECK(windowAndroid) isn't hit - but it probably didn't earlier either. And it looks like RegisterFrameSinkHierarchy->RegisterSurfaceFactoryClient is where this whole BFS path is hooked up. Ok, just remove getting the window android here then. It's definitely not going to prevent any crash anymore afaict. https://codereview.chromium.org/2564403002/diff/40001/content/browser/rendere... content/browser/renderer_host/render_widget_host_view_android.cc:1910: if (observing_root_window_) { On 2016/12/13 10:03:56, Eric Seckler wrote: > On 2016/12/12 21:41:48, boliu wrote: > > this should not be needed, this still comes from the attached WindowAndroid, > so > > this should always be true here, hopefully > > > > does this not hold anymore? that could indicate a bug (that I'm not seeing..) > > I think this was a preexisting bug. What you say amounts to > |view_.GetWindowAndroid()| not being null. But we only observe the window if it > is actually showing. Thus, there are valid cases for |observing_root_window_| to > be false here. (And since Register/UnregisterFrameSinkHierarchy is coupled to > Start/StopObservingRootWindow, we should only RegisterFrameSinkHierarchy here if > |observing_root_window_| is true.) > > Previously, this wouldn't have made much of a difference, I suppose. But now, we > receive the BFS from |delegated_frame_host_| if we RegisterFrameSinkHierarchy(). > As a result, we wouldn't necessarily de-register it later because > StopObservingRootWindow() might early-out because |!observing_root_window_|, > which might leave our pointer dangling (and if I recall correctly, this happened > in some tests). > > I can remove this again and see which (if any) tests fail if that's of interest > to you. Keep it. Your analysis looks correct to me https://codereview.chromium.org/2564403002/diff/40001/ui/android/window_andro... File ui/android/window_android.cc (right): https://codereview.chromium.org/2564403002/diff/40001/ui/android/window_andro... ui/android/window_android.cc:63: // Send a MISSED BeginFrame if possible and necessary. If an observer is added On 2016/12/13 10:03:56, Eric Seckler wrote: > On 2016/12/12 21:41:48, boliu wrote: > > any reason this is needed? > > I'm somewhat new to BeginFrames myself, so brianderson@ might correct me here. > Since this source also feeds the DisplayScheduler, I don't think we can get rid > of missed BeginFrames. Here an attempt at an explanation :) > > One note on background of (missed) BeginFrames vs. vsyncs: > WindowAndroidObservers don't remove themselves when they aren't interested in > BeginFrames, while BeginFrameObservers do. Thus, with WindowAndroidObservers, > even if just one observer requests a vsync, all observers will be notified of it > through OnVSync(). With BeginFrameObservers, this is not the case: Only those > that are interested will receive it. > > Some observers may awake during a vsync interval (i.e. decide that they need a > BeginFrame afterall) -- and for those, receiving a MISSED BeginFrame might be > advantageous. > > In the android-chrome case, I think one such BeginFrameObserver is the > DisplayScheduler: It may go idle (remove itself as observer) when a BeginFrame > doesn't lead to a DrawAndSwap. Later, it will awake again (add itself as > observer) when damage to a surface is detected. It'll then receive a MISSED > BeginFrame for the currently active BeginFrame and (likely) DrawAndSwap the > surface damage during that BeginFrame's deadline. If it didn't receive the > missed BeginFrame, it'd have to wait until the next BeginFrame's deadline. Sorry, typed that comment before I realized this code was moved from CompositorImpl.. No justification needed :p https://codereview.chromium.org/2564403002/diff/40001/ui/android/window_andro... ui/android/window_android.cc:110: while (observer_was_notified) { On 2016/12/13 10:03:56, Eric Seckler wrote: > On 2016/12/12 21:41:48, boliu wrote: > > any reason we don't keep using base::ObserverList and keep getting this > behavior > > for free? > > For two (rather subjective) reasons: > 1) This makes it explicit that SyncCompBrowserFilter is supported. > 2) We get an immediate feedback about whether |observers_| is empty during > RemoveObserver() -- which we wouldn't get with base::ObserverList. > > That said, I think we could also use base::ObserverList and solve > 1) by adding a comment somewhere. > 2) by checking after observer iteration in OnVSync() whether the list became > empty during the iteration. Or you can just keep a count of the number of observers inserted. Then you can remove this complexity. Can still keep a comment about the requirement for AddObserver and iteration behavior. I guess ObserverList is implemented as a sparse array, so getting the number of things is actually expensive.. > > WDYT?
The CQ bit was checked by eseckler@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_android_rel_ng on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/linux_androi...)
https://codereview.chromium.org/2564403002/diff/40001/content/browser/android... File content/browser/android/synchronous_compositor_browser_filter.cc (right): https://codereview.chromium.org/2564403002/diff/40001/content/browser/android... content/browser/android/synchronous_compositor_browser_filter.cc:220: static cc::BeginFrameArgs args; On 2016/12/13 18:07:47, boliu wrote: > On 2016/12/13 10:03:55, Eric Seckler wrote: > > On 2016/12/12 21:41:48, boliu wrote: > > > static is overkill > > > > hmm, this returns a reference - don't think I can return a reference to a > local > > var without the compiler complaining? > > Doh, yeah, ok. > > But then I think this causes a static initializer, which is supposed to be > banned (I'm not sure if there are bots on android that checks this though) > > Just use a member variable Don't think it would cause a static initializer - static in function scope should be initialized at first invocation. Anyway, replaced by a member variable since this seems to be irritating :) https://codereview.chromium.org/2564403002/diff/40001/content/browser/rendere... File content/browser/renderer_host/render_widget_host_view_android.cc (right): https://codereview.chromium.org/2564403002/diff/40001/content/browser/rendere... content/browser/renderer_host/render_widget_host_view_android.cc:1453: DCHECK(windowAndroid); On 2016/12/13 18:07:47, boliu wrote: > On 2016/12/13 10:03:56, Eric Seckler wrote: > > On 2016/12/12 21:41:48, boliu wrote: > > > So windowAndroid pointer can change throughout the lifetime of the RWHVA, > and > > > the start/stopObservingWindowAndroid calls roughly corresponds to when the > > > window android is set/unset > > > > > > For the webview case, I think this is still handled correctly. > > > > > > What's not clear for me is for chrome after begin frame is unified, will the > > > begin frame source ever change, even when the windowAndroid changes? And > does > > > the begin frame call still go through windowAndroid? > > > > > > If not, then technically, this DCHECK isn't really valid for chrome anymore. > > > > > > If yes, then will need to ensure that sequence still works correctly > > > > In android-chrome, there's a direct relationship between a WindowAndroid and > > cc::Display (one CompositorImpl instance, which owns cc::Display, per > > WindowAndroid). The cc::Display receives the WindowAndroid's BFS, and > registers > > it at SurfaceManager, which then distributes it to SurfaceFactoryClients, one > of > > which is DelegatedFrameHostAndroid. > > > > Thus, in chrome: > > - The BFS of RWHVAndroid changes when WindowAndroid changes. > > - The BFS provided by WindowAndroid feeds both the browser compositor > > (cc::Display) and (possibly multiple) RWHVAndroid. > > > > Irrespective of this, I'm not sure if the behavior you saw in crbug.com/639868 > > may still occur - and whether this check is still needed. In tests, the > > DCHECK(windowAndroid) isn't hit - but it probably didn't earlier either. > > And it looks like RegisterFrameSinkHierarchy->RegisterSurfaceFactoryClient is > where this whole BFS path is hooked up. > > Ok, just remove getting the window android here then. It's definitely not going > to prevent any crash anymore afaict. Ok, got rid of it. https://codereview.chromium.org/2564403002/diff/40001/ui/android/window_andro... File ui/android/window_android.cc (right): https://codereview.chromium.org/2564403002/diff/40001/ui/android/window_andro... ui/android/window_android.cc:110: while (observer_was_notified) { On 2016/12/13 18:07:47, boliu wrote: > On 2016/12/13 10:03:56, Eric Seckler wrote: > > On 2016/12/12 21:41:48, boliu wrote: > > > any reason we don't keep using base::ObserverList and keep getting this > > behavior > > > for free? > > > > For two (rather subjective) reasons: > > 1) This makes it explicit that SyncCompBrowserFilter is supported. > > 2) We get an immediate feedback about whether |observers_| is empty during > > RemoveObserver() -- which we wouldn't get with base::ObserverList. > > > > That said, I think we could also use base::ObserverList and solve > > 1) by adding a comment somewhere. > > 2) by checking after observer iteration in OnVSync() whether the list became > > empty during the iteration. > > Or you can just keep a count of the number of observers inserted. Then you can > remove this complexity. Can still keep a comment about the requirement for > AddObserver and iteration behavior. > > I guess ObserverList is implemented as a sparse array, so getting the number of > things is actually expensive.. > > > > > WDYT? > Sounds good, done.
lgtm % last comment https://codereview.chromium.org/2564403002/diff/100001/content/browser/render... File content/browser/renderer_host/render_widget_host_view_android.cc (right): https://codereview.chromium.org/2564403002/diff/100001/content/browser/render... content/browser/renderer_host/render_widget_host_view_android.cc:1451: if (source && requests && !outstanding_begin_frame_requests_) one subtle thing, since AddObserver can directly call observer methods, need to move the outstanding_begin_frame_requests_ = requests; to before AddObserver so something like bool should_add_observer = requests && !outstanding_begin_frame_requests_ outstanding_begin_frame_requests_ = requests; if (source && should_add_observer) AddObserver And then, for good measure, do the same in ClearBeginFrameRequest just to match the style.
The CQ bit was checked by eseckler@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
eseckler@chromium.org changed reviewers: + tedchoc@chromium.org
+tedchoc for ui/android/ Thanks! https://codereview.chromium.org/2564403002/diff/100001/content/browser/render... File content/browser/renderer_host/render_widget_host_view_android.cc (right): https://codereview.chromium.org/2564403002/diff/100001/content/browser/render... content/browser/renderer_host/render_widget_host_view_android.cc:1451: if (source && requests && !outstanding_begin_frame_requests_) On 2016/12/14 18:59:47, boliu wrote: > one subtle thing, since AddObserver can directly call observer methods, need to > move the outstanding_begin_frame_requests_ = requests; to before AddObserver > > so something like > bool should_add_observer = requests && !outstanding_begin_frame_requests_ > outstanding_begin_frame_requests_ = requests; > if (source && should_add_observer) > AddObserver > > > And then, for good measure, do the same in ClearBeginFrameRequest just to match > the style. Good catch, thanks! Done :)
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
On 2016/12/15 11:40:22, Eric Seckler wrote: > +tedchoc for ui/android/ > > Thanks! > > https://codereview.chromium.org/2564403002/diff/100001/content/browser/render... > File content/browser/renderer_host/render_widget_host_view_android.cc (right): > > https://codereview.chromium.org/2564403002/diff/100001/content/browser/render... > content/browser/renderer_host/render_widget_host_view_android.cc:1451: if > (source && requests && !outstanding_begin_frame_requests_) > On 2016/12/14 18:59:47, boliu wrote: > > one subtle thing, since AddObserver can directly call observer methods, need > to > > move the outstanding_begin_frame_requests_ = requests; to before AddObserver > > > > so something like > > bool should_add_observer = requests && !outstanding_begin_frame_requests_ > > outstanding_begin_frame_requests_ = requests; > > if (source && should_add_observer) > > AddObserver > > > > > > And then, for good measure, do the same in ClearBeginFrameRequest just to > match > > the style. > > Good catch, thanks! Done :) lgtm
The CQ bit was checked by eseckler@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from boliu@chromium.org Link to the patchset: https://codereview.chromium.org/2564403002/#ps120001 (title: "Fix ordering in Add/ClearBeginFrameRequest.")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: chromium_presubmit on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromium_presub...)
eseckler@chromium.org changed reviewers: + brianderson@chromium.org
Brian, could you rubber-stamp the new dependency on '+cc/scheduler/begin_frame_source.h' From ui/android/DEPS? Thanks :)
lgtm
The CQ bit was checked by eseckler@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
CQ is committing da patch. Bot data: {"patchset_id": 120001, "attempt_start_ts": 1481879050317510, "parent_rev": "1233c3b7a536783760a918d7d1756cb8d67a9a94", "commit_rev": "d3149dd85e8d4cf6acd5357d0e9aa5940d268a7a"}
Message was sent while issue was closed.
Description was changed from ========== [android] Make RWHVAndroid a BeginFrameObserver. Instead of directly observing the Window's vsyncs, RWHVAndroid now observes a BeginFrameSource provided by the DelegatedFrameHost (clank) or WindowAndroid (webview). To enable this, the BeginFrameSource originally provided by CompositorImpl moves into WindowAndroid. The patch also makes some changes to the BeginFrameSource's observer iteration that are necessary to support SynchronousBrowserCompositorFilter. BUG=401336 ========== to ========== [android] Make RWHVAndroid a BeginFrameObserver. Instead of directly observing the Window's vsyncs, RWHVAndroid now observes a BeginFrameSource provided by the DelegatedFrameHost (clank) or WindowAndroid (webview). To enable this, the BeginFrameSource originally provided by CompositorImpl moves into WindowAndroid. The patch also makes some changes to the BeginFrameSource's observer iteration that are necessary to support SynchronousBrowserCompositorFilter. BUG=401336 Review-Url: https://codereview.chromium.org/2564403002 ==========
Message was sent while issue was closed.
Committed patchset #4 (id:120001)
Message was sent while issue was closed.
Description was changed from ========== [android] Make RWHVAndroid a BeginFrameObserver. Instead of directly observing the Window's vsyncs, RWHVAndroid now observes a BeginFrameSource provided by the DelegatedFrameHost (clank) or WindowAndroid (webview). To enable this, the BeginFrameSource originally provided by CompositorImpl moves into WindowAndroid. The patch also makes some changes to the BeginFrameSource's observer iteration that are necessary to support SynchronousBrowserCompositorFilter. BUG=401336 Review-Url: https://codereview.chromium.org/2564403002 ========== to ========== [android] Make RWHVAndroid a BeginFrameObserver. Instead of directly observing the Window's vsyncs, RWHVAndroid now observes a BeginFrameSource provided by the DelegatedFrameHost (clank) or WindowAndroid (webview). To enable this, the BeginFrameSource originally provided by CompositorImpl moves into WindowAndroid. The patch also makes some changes to the BeginFrameSource's observer iteration that are necessary to support SynchronousBrowserCompositorFilter. BUG=401336 Committed: https://crrev.com/1a6bd5037fc10e45646715d675e63146d23fc28d Cr-Commit-Position: refs/heads/master@{#439072} ==========
Message was sent while issue was closed.
Patchset 4 (id:??) landed as https://crrev.com/1a6bd5037fc10e45646715d675e63146d23fc28d Cr-Commit-Position: refs/heads/master@{#439072}
Message was sent while issue was closed.
A revert of this CL (patchset #4 id:120001) has been created in https://codereview.chromium.org/2585993002/ by rnephew@chromium.org. The reason for reverting is: Expected failure of telemetry_perf_unittests crbug.com/675289 .
Message was sent while issue was closed.
Description was changed from ========== [android] Make RWHVAndroid a BeginFrameObserver. Instead of directly observing the Window's vsyncs, RWHVAndroid now observes a BeginFrameSource provided by the DelegatedFrameHost (clank) or WindowAndroid (webview). To enable this, the BeginFrameSource originally provided by CompositorImpl moves into WindowAndroid. The patch also makes some changes to the BeginFrameSource's observer iteration that are necessary to support SynchronousBrowserCompositorFilter. BUG=401336 Committed: https://crrev.com/1a6bd5037fc10e45646715d675e63146d23fc28d Cr-Commit-Position: refs/heads/master@{#439072} ========== to ========== [android] Make RWHVAndroid a BeginFrameObserver. Instead of directly observing the Window's vsyncs, RWHVAndroid now observes a BeginFrameSource provided by the DelegatedFrameHost (clank) or WindowAndroid (webview). To enable this, the BeginFrameSource originally provided by CompositorImpl moves into WindowAndroid. The patch also makes some changes to the BeginFrameSource's observer iteration that are necessary to support SynchronousBrowserCompositorFilter. BUG=401336 Committed: https://crrev.com/1a6bd5037fc10e45646715d675e63146d23fc28d Cr-Commit-Position: refs/heads/master@{#439072} ==========
Patchset #5 (id:140001) has been deleted
Patchset #5 (id:160001) has been deleted
The CQ bit was checked by eseckler@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
Patchset #5 (id:180001) has been deleted
The CQ bit was checked by eseckler@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Bo, can you have another look at changes in RWHVA and WindowAndroid please - Regression is fixed. Thanks! :)
Description was changed from ========== [android] Make RWHVAndroid a BeginFrameObserver. Instead of directly observing the Window's vsyncs, RWHVAndroid now observes a BeginFrameSource provided by the DelegatedFrameHost (clank) or WindowAndroid (webview). To enable this, the BeginFrameSource originally provided by CompositorImpl moves into WindowAndroid. The patch also makes some changes to the BeginFrameSource's observer iteration that are necessary to support SynchronousBrowserCompositorFilter. BUG=401336 Committed: https://crrev.com/1a6bd5037fc10e45646715d675e63146d23fc28d Cr-Commit-Position: refs/heads/master@{#439072} ========== to ========== [android] Make RWHVAndroid a BeginFrameObserver. Instead of directly observing the Window's vsyncs, RWHVAndroid now observes a BeginFrameSource provided by the DelegatedFrameHost (clank) or WindowAndroid (webview). To enable this, the BeginFrameSource originally provided by CompositorImpl moves into WindowAndroid. The patch also makes some changes to the BeginFrameSource's observer iteration that are necessary to support SynchronousBrowserCompositorFilter. BUG=401336, 675289 Committed: https://crrev.com/1a6bd5037fc10e45646715d675e63146d23fc28d Cr-Commit-Position: refs/heads/master@{#439072} ==========
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
skyostil@chromium.org changed reviewers: + skyostil@chromium.org
The fix lgtm FWIW.
https://codereview.chromium.org/2564403002/diff/200001/content/browser/render... File content/browser/renderer_host/render_widget_host_view_android.cc (right): https://codereview.chromium.org/2564403002/diff/200001/content/browser/render... content/browser/renderer_host/render_widget_host_view_android.cc:1926: // can lead to |begin_frame_source_->AddObserver()| and OnBeginFrame(). how does moving last_begin_frame_args_ up fix this exactly? That the FlushInput gets the right args? instead of the complicated thing in window_android, how about this fix: Only call Add/RemoveObserver at the *end* of this method. This way, it would be impossible to toggle back and forth between states
https://codereview.chromium.org/2564403002/diff/200001/content/browser/render... File content/browser/renderer_host/render_widget_host_view_android.cc (right): https://codereview.chromium.org/2564403002/diff/200001/content/browser/render... content/browser/renderer_host/render_widget_host_view_android.cc:1926: // can lead to |begin_frame_source_->AddObserver()| and OnBeginFrame(). On 2016/12/20 16:13:50, boliu wrote: > how does moving last_begin_frame_args_ up fix this exactly? That the FlushInput > gets the right args? It prevents the BeginFrameSource from sending us the same args again: During AddObserver(), it checks if our last_begin_frame_args_ are older than its latest ones. If they are older, it sends us a missed BeginFrame. The reason we were getting stuck is that we called (RemoveObserver() and then) AddObserver() before updating our last_begin_frame_args_, indicating to the BeginFrameSource that we did not yet receive/handle its latest BeginFrameArgs. > instead of the complicated thing in window_android, how about this fix: > Only call Add/RemoveObserver at the *end* of this method. This way, it would be > impossible to toggle back and forth between states I have two reservations against this and would rather like to keep the check in WindowAndroid. Note though that this is a different issue only tangentially related to crbug.com/675289, which I discovered during debugging. (Sorry, should have made this clear I guess :)) The problem there is that we might send the same BeginFrameArgs to an observer twice during OnVSync(), which is forbidden as noted in the comment of BeginFrameObserver::OnBeginFrame(). The RWHVA is only one BeginFrameObserver, so changing it to not exhibit the forbidden behavior doesn't really solve it, I think. There's no contract forbidding other observers to remove/add themselves during iteration. (WindowBeginFrameSource is exposed widely through the compositor.) Regarding RWHVA: If possible, I'd like to avoid moving Add/RemoveObserver out of the Add/ClearBeginFrameRequest methods - since otherwise we'd have to check if we need to AddObserver() in all callsites of AddBeginFrameRequest().
On 2016/12/20 16:35:07, Eric Seckler wrote: > The problem there is that we might send the same BeginFrameArgs to an observer > twice during OnVSync(), which is forbidden as noted in the comment of > BeginFrameObserver::OnBeginFrame(). Btw, all other BeginFrameSource implementations avoid this by iterating on a copy of their current observers_ set. We can't easily do this because of SynchronousCompositorBrowserFilter :-/ If we're looking for a cleaner approach in WindowBeginFrameSource, I'd rather suggest that we get rid of SynchronousCompositorBrowserFilter's exploitation of impl-details of the observer iteration behavior :) Though maybe we can do this as a follow-up and then replace the base::ObserverList in WindowBeginFrameSource?
https://codereview.chromium.org/2564403002/diff/200001/content/browser/render... File content/browser/renderer_host/render_widget_host_view_android.cc (right): https://codereview.chromium.org/2564403002/diff/200001/content/browser/render... content/browser/renderer_host/render_widget_host_view_android.cc:1926: // can lead to |begin_frame_source_->AddObserver()| and OnBeginFrame(). On 2016/12/20 16:35:07, Eric Seckler wrote: > On 2016/12/20 16:13:50, boliu wrote: > > how does moving last_begin_frame_args_ up fix this exactly? That the > FlushInput > > gets the right args? > It prevents the BeginFrameSource from sending us the same args again: During > AddObserver(), it checks if our last_begin_frame_args_ are older than its latest > ones. If they are older, it sends us a missed BeginFrame. > > The reason we were getting stuck is that we called (RemoveObserver() and then) > AddObserver() before updating our last_begin_frame_args_, indicating to the > BeginFrameSource that we did not yet receive/handle its latest BeginFrameArgs. oh, then do say that in the comment, that updating last begin frame args will prevent infinite recursion. also don't need the bug number I guess, since it will be fixed > > > instead of the complicated thing in window_android, how about this fix: > > Only call Add/RemoveObserver at the *end* of this method. This way, it would > be > > impossible to toggle back and forth between states > I have two reservations against this and would rather like to keep the check in > WindowAndroid. Note though that this is a different issue only tangentially > related to crbug.com/675289, which I discovered during debugging. (Sorry, should > have made this clear I guess :)) > > The problem there is that we might send the same BeginFrameArgs to an observer > twice during OnVSync(), which is forbidden as noted in the comment of > BeginFrameObserver::OnBeginFrame(). > > The RWHVA is only one BeginFrameObserver, so changing it to not exhibit the > forbidden behavior doesn't really solve it, I think. There's no contract > forbidding other observers to remove/add themselves during iteration. > (WindowBeginFrameSource is exposed widely through the compositor.) > > Regarding RWHVA: If possible, I'd like to avoid moving Add/RemoveObserver out of > the Add/ClearBeginFrameRequest methods - since otherwise we'd have to check if > we need to AddObserver() in all callsites of AddBeginFrameRequest(). how about actually comparing LastBeginFrameArgs then, rather than keeping the set? But then probably should implement LastUsedBeginFrameArgs properly in synchronous_compositor_browser_filter
On 2016/12/20 16:56:09, boliu wrote: > oh, then do say that in the comment, that updating last begin frame args will > prevent infinite recursion. also don't need the bug number I guess, since it > will be fixed Updated the comment to mention recursion explictly :) > how about actually comparing LastBeginFrameArgs then, rather than keeping the > set? I agree, the set isn't particularly nice - but I don't see a good way around it: Sadly, whether the observer uses the args (and updates LastBeginFrameArgs) is independent of this. That is, even if the observer decides not to use the args (and doesn't update LastBeginFrameArgs), we shouldn't be sending the same args to it twice.
On 2016/12/20 16:52:46, Eric Seckler wrote: > On 2016/12/20 16:35:07, Eric Seckler wrote: > > The problem there is that we might send the same BeginFrameArgs to an observer > > twice during OnVSync(), which is forbidden as noted in the comment of > > BeginFrameObserver::OnBeginFrame(). > > Btw, all other BeginFrameSource implementations avoid this by iterating on a > copy of their current observers_ set. We can't easily do this because of > SynchronousCompositorBrowserFilter :-/ > > If we're looking for a cleaner approach in WindowBeginFrameSource, I'd rather > suggest that we get rid of SynchronousCompositorBrowserFilter's exploitation of > impl-details of the observer iteration behavior :) Though maybe we can do this > as a follow-up and then replace the base::ObserverList in > WindowBeginFrameSource? Apparently I did not see this in my last reply.. Yeah, I was gonna suggest exactly that. Add a TODO in WindowAndroid in this CL though.
On 2016/12/20 17:35:48, boliu wrote: > On 2016/12/20 16:52:46, Eric Seckler wrote: > > On 2016/12/20 16:35:07, Eric Seckler wrote: > > > The problem there is that we might send the same BeginFrameArgs to an > observer > > > twice during OnVSync(), which is forbidden as noted in the comment of > > > BeginFrameObserver::OnBeginFrame(). > > > > Btw, all other BeginFrameSource implementations avoid this by iterating on a > > copy of their current observers_ set. We can't easily do this because of > > SynchronousCompositorBrowserFilter :-/ > > > > If we're looking for a cleaner approach in WindowBeginFrameSource, I'd rather > > suggest that we get rid of SynchronousCompositorBrowserFilter's exploitation > of > > impl-details of the observer iteration behavior :) Though maybe we can do this > > as a follow-up and then replace the base::ObserverList in > > WindowBeginFrameSource? > > Apparently I did not see this in my last reply.. > > Yeah, I was gonna suggest exactly that. Add a TODO in WindowAndroid in this CL > though.
On 2016/12/20 17:35:48, boliu wrote: > On 2016/12/20 16:52:46, Eric Seckler wrote: > > On 2016/12/20 16:35:07, Eric Seckler wrote: > > > The problem there is that we might send the same BeginFrameArgs to an > observer > > > twice during OnVSync(), which is forbidden as noted in the comment of > > > BeginFrameObserver::OnBeginFrame(). > > > > Btw, all other BeginFrameSource implementations avoid this by iterating on a > > copy of their current observers_ set. We can't easily do this because of > > SynchronousCompositorBrowserFilter :-/ > > > > If we're looking for a cleaner approach in WindowBeginFrameSource, I'd rather > > suggest that we get rid of SynchronousCompositorBrowserFilter's exploitation > of > > impl-details of the observer iteration behavior :) Though maybe we can do this > > as a follow-up and then replace the base::ObserverList in > > WindowBeginFrameSource? > > Apparently I did not see this in my last reply.. > > Yeah, I was gonna suggest exactly that. Add a TODO in WindowAndroid in this CL > though. Done :)
lgtm
On 2016/12/20 17:43:35, boliu wrote: > lgtm Thanks again, Bo! :)
The CQ bit was checked by eseckler@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from tedchoc@chromium.org, brianderson@chromium.org, skyostil@chromium.org Link to the patchset: https://codereview.chromium.org/2564403002/#ps240001 (title: "add todo")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Failed to apply patch for content/browser/renderer_host/render_widget_host_view_android.cc: While running git apply --index -p1; error: patch failed: content/browser/renderer_host/render_widget_host_view_android.cc:798 error: content/browser/renderer_host/render_widget_host_view_android.cc: patch does not apply Patch: content/browser/renderer_host/render_widget_host_view_android.cc Index: content/browser/renderer_host/render_widget_host_view_android.cc diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc index 08885281bf791989e0ea5321f566ba61adb0212a..ed7ca1e0373c621aace834ff809c274f2ce410c6 100644 --- a/content/browser/renderer_host/render_widget_host_view_android.cc +++ b/content/browser/renderer_host/render_widget_host_view_android.cc @@ -77,7 +77,6 @@ #include "third_party/khronos/GLES2/gl2.h" #include "third_party/khronos/GLES2/gl2ext.h" #include "third_party/skia/include/core/SkCanvas.h" -#include "ui/android/delegated_frame_host_android.h" #include "ui/android/window_android.h" #include "ui/android/window_android_compositor.h" #include "ui/base/layout.h" @@ -432,7 +431,8 @@ RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid( RenderWidgetHostImpl* widget_host, ContentViewCoreImpl* content_view_core) : host_(widget_host), - outstanding_vsync_requests_(0), + begin_frame_source_(nullptr), + outstanding_begin_frame_requests_(0), is_showing_(!widget_host->is_hidden()), is_window_visible_(true), is_window_activity_started_(true), @@ -456,9 +456,7 @@ RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid( view_.SetLayer(cc::Layer::Create()); if (using_browser_compositor_) { delegated_frame_host_.reset(new ui::DelegatedFrameHostAndroid( - &view_, cached_background_color_, - base::Bind(&RenderWidgetHostViewAndroid::ReturnResources, - weak_ptr_factory_.GetWeakPtr()))); + &view_, cached_background_color_, this)); } host_->SetView(this); @@ -798,9 +796,9 @@ void RenderWidgetHostViewAndroid::SetNeedsBeginFrames(bool needs_begin_frames) { TRACE_EVENT1("cc", "RenderWidgetHostViewAndroid::SetNeedsBeginFrames", "needs_begin_frames", needs_begin_frames); if (needs_begin_frames) - RequestVSyncUpdate(PERSISTENT_BEGIN_FRAME); + AddBeginFrameRequest(PERSISTENT_BEGIN_FRAME); else - outstanding_vsync_requests_ &= ~PERSISTENT_BEGIN_FRAME; + ClearBeginFrameRequest(PERSISTENT_BEGIN_FRAME); } void RenderWidgetHostViewAndroid::OnStartContentIntent( @@ -854,7 +852,7 @@ bool RenderWidgetHostViewAndroid::OnTouchEvent( // that BeginFrame requests made during ACTION_MOVE dispatch will be honored // in the same vsync phase. if (observing_root_window_ && result.moved_beyond_slop_region) - RequestVSyncUpdate(BEGIN_FRAME); + AddBeginFrameRequest(BEGIN_FRAME); return true; } @@ -1385,9 +1383,9 @@ void RenderWidgetHostViewAndroid::ShowInternal() { host_->WasShown(ui::LatencyInfo()); - if (content_view_core_) { + if (content_view_core_ && view_.GetWindowAndroid()) { StartObservingRootWindow(); - RequestVSyncUpdate(BEGIN_FRAME); + AddBeginFrameRequest(BEGIN_FRAME); } } @@ -1430,29 +1428,43 @@ void RenderWidgetHostViewAndroid::HideInternal() { host_->WasHidden(); } -void RenderWidgetHostViewAndroid::RequestVSyncUpdate(uint32_t requests) { - bool should_request_vsync = !outstanding_vsync_requests_ && requests; - outstanding_vsync_requests_ |= requests; - - // Note that if we're not currently observing the root window, outstanding - // vsync requests will be pushed if/when we resume observing in - // |StartObservingRootWindow()|. - if (observing_root_window_ && should_request_vsync) { - ui::WindowAndroid* windowAndroid = view_.GetWindowAndroid(); - DCHECK(windowAndroid); - // TODO(boliu): This check should be redundant with - // |observing_root_window_| check above. However we are receiving trickle - // of crash reports (crbug.com/639868) with no root cause. Should - // investigate more when time allows what corner case is missed. - if (windowAndroid) - windowAndroid->RequestVSyncUpdate(); - } +void RenderWidgetHostViewAndroid::SetBeginFrameSource( + cc::BeginFrameSource* begin_frame_source) { + if (begin_frame_source_ == begin_frame_source) + return; + + if (begin_frame_source_ && outstanding_begin_frame_requests_) + begin_frame_source_->RemoveObserver(this); + begin_frame_source_ = begin_frame_source; + if (begin_frame_source_ && outstanding_begin_frame_requests_) + begin_frame_source_->AddObserver(this); +} + +void RenderWidgetHostViewAndroid::AddBeginFrameRequest( + BeginFrameRequestType request) { + uint32_t prior_requests = outstanding_begin_frame_requests_; + outstanding_begin_frame_requests_ = prior_requests | request; + + // Note that if we don't currently have a BeginFrameSource, outstanding begin + // frame requests will be pushed if/when we get one during + // |StartObservingRootWindow()| or when the DelegatedFrameHostAndroid sets it. + cc::BeginFrameSource* source = begin_frame_source_; + if (source && outstanding_begin_frame_requests_ && !prior_requests) + source->AddObserver(this); +} + +void RenderWidgetHostViewAndroid::ClearBeginFrameRequest( + BeginFrameRequestType request) { + uint32_t prior_requests = outstanding_begin_frame_requests_; + outstanding_begin_frame_requests_ = prior_requests & ~request; + + cc::BeginFrameSource* source = begin_frame_source_; + if (source && !outstanding_begin_frame_requests_ && prior_requests) + source->RemoveObserver(this); } void RenderWidgetHostViewAndroid::StartObservingRootWindow() { DCHECK(content_view_core_); - // TODO(yusufo): This will need to have a better fallback for cases where - // setContentViewCore is called with a valid ContentViewCore without a window. DCHECK(view_.GetWindowAndroid()); DCHECK(is_showing_); if (observing_root_window_) @@ -1462,11 +1474,9 @@ void RenderWidgetHostViewAndroid::StartObservingRootWindow() { if (host_) host_->Send(new ViewMsg_SetBeginFramePaused(host_->GetRoutingID(), false)); view_.GetWindowAndroid()->AddObserver(this); - - // Clear existing vsync requests to allow a request to the new window. - uint32_t outstanding_vsync_requests = outstanding_vsync_requests_; - outstanding_vsync_requests_ = 0; - RequestVSyncUpdate(outstanding_vsync_requests); + // When using browser compositor, DelegatedFrameHostAndroid provides the BFS. + if (!using_browser_compositor_) + SetBeginFrameSource(view_.GetWindowAndroid()->GetBeginFrameSource()); ui::WindowAndroidCompositor* compositor = view_.GetWindowAndroid()->GetCompositor(); @@ -1492,26 +1502,25 @@ void RenderWidgetHostViewAndroid::StopObservingRootWindow() { if (host_) host_->Send(new ViewMsg_SetBeginFramePaused(host_->GetRoutingID(), true)); view_.GetWindowAndroid()->RemoveObserver(this); + if (!using_browser_compositor_) + SetBeginFrameSource(nullptr); // If the DFH has already been destroyed, it will have cleaned itself up. // This happens in some WebView cases. if (delegated_frame_host_) delegated_frame_host_->UnregisterFrameSinkHierarchy(); + DCHECK(!begin_frame_source_); } -void RenderWidgetHostViewAndroid::SendBeginFrame(base::TimeTicks frame_time, - base::TimeDelta vsync_period) { +void RenderWidgetHostViewAndroid::SendBeginFrame(cc::BeginFrameArgs args) { TRACE_EVENT1("cc", "RenderWidgetHostViewAndroid::SendBeginFrame", - "frame_time_us", frame_time.ToInternalValue()); + "frame_time_us", args.frame_time.ToInternalValue()); // Synchronous compositor does not use deadline-based scheduling. // TODO(brianderson): Replace this hardcoded deadline after Android - // switches to Surfaces and the Browser's commit isn't in the critcal path. - base::TimeTicks deadline = - sync_compositor_ ? base::TimeTicks() : frame_time + (vsync_period * 0.6); - host_->Send(new ViewMsg_BeginFrame( - host_->GetRoutingID(), - cc::BeginFrameArgs::Create(BEGINFRAME_FROM_HERE, frame_time, deadline, - vsync_period, cc::BeginFrameArgs::NORMAL))); + // switches to Surfaces and the Browser's commit isn't in the critical path. + args.deadline = sync_compositor_ ? base::TimeTicks() + : args.frame_time + (args.interval * 0.6); + host_->Send(new ViewMsg_BeginFrame(host_->GetRoutingID(), args)); if (sync_compositor_) sync_compositor_->DidSendBeginFrame(view_.GetWindowAndroid()); } @@ -1625,7 +1634,7 @@ InputEventAckState RenderWidgetHostViewAndroid::FilterInputEvent( void RenderWidgetHostViewAndroid::OnSetNeedsFlushInput() { TRACE_EVENT0("input", "RenderWidgetHostViewAndroid::OnSetNeedsFlushInput"); - RequestVSyncUpdate(FLUSH_INPUT); + AddBeginFrameRequest(FLUSH_INPUT); } BrowserAccessibilityManager* @@ -1807,7 +1816,7 @@ void RenderWidgetHostViewAndroid::SetContentViewCore( return; } - if (is_showing_) + if (is_showing_ && view_.GetWindowAndroid()) StartObservingRootWindow(); if (resize) @@ -1883,10 +1892,12 @@ void RenderWidgetHostViewAndroid::OnDetachedFromWindow() { void RenderWidgetHostViewAndroid::OnAttachCompositor() { DCHECK(content_view_core_); CreateOverscrollControllerIfPossible(); - ui::WindowAndroidCompositor* compositor = - view_.GetWindowAndroid()->GetCompositor(); - delegated_frame_host_->RegisterFrameSinkHierarchy( - compositor->GetFrameSinkId()); + if (observing_root_window_) { + ui::WindowAndroidCompositor* compositor = + view_.GetWindowAndroid()->GetCompositor(); + delegated_frame_host_->RegisterFrameSinkHierarchy( + compositor->GetFrameSinkId()); + } } void RenderWidgetHostViewAndroid::OnDetachCompositor() { @@ -1897… (message too large)
The CQ bit was checked by eseckler@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from tedchoc@chromium.org, brianderson@chromium.org, skyostil@chromium.org, boliu@chromium.org Link to the patchset: https://codereview.chromium.org/2564403002/#ps250001 (title: "rebase")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
CQ is committing da patch. Bot data: {"patchset_id": 250001, "attempt_start_ts": 1482261206136920, "parent_rev": "7cf588ab111bf146c9ab7a3d16efcecf9901ef4c", "commit_rev": "b1270640d88a21e686b29c305ae64149a9bf8ab5"}
Message was sent while issue was closed.
Description was changed from ========== [android] Make RWHVAndroid a BeginFrameObserver. Instead of directly observing the Window's vsyncs, RWHVAndroid now observes a BeginFrameSource provided by the DelegatedFrameHost (clank) or WindowAndroid (webview). To enable this, the BeginFrameSource originally provided by CompositorImpl moves into WindowAndroid. The patch also makes some changes to the BeginFrameSource's observer iteration that are necessary to support SynchronousBrowserCompositorFilter. BUG=401336, 675289 Committed: https://crrev.com/1a6bd5037fc10e45646715d675e63146d23fc28d Cr-Commit-Position: refs/heads/master@{#439072} ========== to ========== [android] Make RWHVAndroid a BeginFrameObserver. Instead of directly observing the Window's vsyncs, RWHVAndroid now observes a BeginFrameSource provided by the DelegatedFrameHost (clank) or WindowAndroid (webview). To enable this, the BeginFrameSource originally provided by CompositorImpl moves into WindowAndroid. The patch also makes some changes to the BeginFrameSource's observer iteration that are necessary to support SynchronousBrowserCompositorFilter. BUG=401336, 675289 Committed: https://crrev.com/1a6bd5037fc10e45646715d675e63146d23fc28d Cr-Commit-Position: refs/heads/master@{#439072} Review-Url: https://codereview.chromium.org/2564403002 ==========
Message was sent while issue was closed.
Committed patchset #8 (id:250001)
Message was sent while issue was closed.
Description was changed from ========== [android] Make RWHVAndroid a BeginFrameObserver. Instead of directly observing the Window's vsyncs, RWHVAndroid now observes a BeginFrameSource provided by the DelegatedFrameHost (clank) or WindowAndroid (webview). To enable this, the BeginFrameSource originally provided by CompositorImpl moves into WindowAndroid. The patch also makes some changes to the BeginFrameSource's observer iteration that are necessary to support SynchronousBrowserCompositorFilter. BUG=401336, 675289 Committed: https://crrev.com/1a6bd5037fc10e45646715d675e63146d23fc28d Cr-Commit-Position: refs/heads/master@{#439072} Review-Url: https://codereview.chromium.org/2564403002 ========== to ========== [android] Make RWHVAndroid a BeginFrameObserver. Instead of directly observing the Window's vsyncs, RWHVAndroid now observes a BeginFrameSource provided by the DelegatedFrameHost (clank) or WindowAndroid (webview). To enable this, the BeginFrameSource originally provided by CompositorImpl moves into WindowAndroid. The patch also makes some changes to the BeginFrameSource's observer iteration that are necessary to support SynchronousBrowserCompositorFilter. BUG=401336, 675289 Committed: https://crrev.com/1a6bd5037fc10e45646715d675e63146d23fc28d Committed: https://crrev.com/8c15fc3eb477cc05d742736cee65b6ea7e1c5f84 Cr-Original-Commit-Position: refs/heads/master@{#439072} Cr-Commit-Position: refs/heads/master@{#439877} ==========
Message was sent while issue was closed.
Patchset 8 (id:??) landed as https://crrev.com/8c15fc3eb477cc05d742736cee65b6ea7e1c5f84 Cr-Commit-Position: refs/heads/master@{#439877} |