Skip to content

Commit

Permalink
[ios] Suspend/Unsuspend compositor in BrowserCompositorIOS
Browse files Browse the repository at this point in the history
This CL adds private methods below to BrowserCompositorIOS to manage
compositor when it’s created and destroyed.

void Suspend();
void Unsuspend();
void InvalidateSurface();

Like BrowserCompositorMac, it calls Suspend() and Unsuspend() to
control CompositorLock when the compositor is created.
It also adds InvalidateSurface() to reset surface information when
the compositor is destroyed.

In this CL, RenderWidgetHostViewPresentationFeedbackBrowserTest.Show
is enabled.

Bug: 1413706, 1467641
Change-Id: Id800de340fb892348519f2420679f3b856ae503b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4935970
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: Julie Jeongeun Kim <jkim@igalia.com>
Reviewed-by: Ian Vollick <vollick@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1209799}
  • Loading branch information
jkim-julie authored and Chromium LUCI CQ committed Oct 14, 2023
1 parent be96f7b commit b9b30ca
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 4 deletions.
5 changes: 5 additions & 0 deletions content/browser/renderer_host/browser_compositor_ios.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ class CONTENT_EXPORT BrowserCompositorIOS : public DelegatedFrameHostClient,
float scale_factor,
const gfx::DisplayColorSpaces& display_color_spaces);

void InvalidateSurface();
void Suspend();
void Unsuspend();

// Weak pointer to the layer supplied and reset via SetParentUiLayer. |this|
// is an observer of |parent_ui_layer_|, to ensure that |parent_ui_layer_|
// always be valid when non-null. The UpdateState function will re-parent
Expand Down Expand Up @@ -190,6 +194,7 @@ class CONTENT_EXPORT BrowserCompositorIOS : public DelegatedFrameHostClient,
gfx::Size size_pixels_;
float scale_factor_ = 1.f;
gfx::DisplayColorSpaces display_color_spaces_;
std::unique_ptr<ui::CompositorLock> compositor_suspended_lock_;

base::WeakPtrFactory<BrowserCompositorIOS> weak_factory_;
};
Expand Down
20 changes: 20 additions & 0 deletions content/browser/renderer_host/browser_compositor_ios.mm
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@
if (state_ == HasOwnCompositor) {
compositor_->SetRootLayer(nullptr);
compositor_.reset();
InvalidateSurface();
}

// The compositor is now detached. If this is the target state, we're done.
Expand All @@ -249,12 +250,14 @@
context_factory->AllocateFrameSinkId(), context_factory,
base::SingleThreadTaskRunner::GetCurrentDefault(),
ui::IsPixelCanvasRecordingEnabled());
Suspend();
display::ScreenInfo current = client_->GetCurrentScreenInfo();
UpdateSurface(dfh_size_pixels_, current.device_scale_factor,
current.display_color_spaces);
compositor_->SetRootLayer(root_layer_.get());
compositor_->SetBackgroundColor(background_color_);
compositor_->SetAcceleratedWidget(accelerated_widget_);
Unsuspend();
state_ = HasOwnCompositor;
}
DCHECK_EQ(state_, new_state);
Expand Down Expand Up @@ -433,4 +436,21 @@
}
}

void BrowserCompositorIOS::InvalidateSurface() {
size_pixels_ = gfx::Size();
scale_factor_ = 1.f;
local_surface_id_allocator_.Invalidate();
}

void BrowserCompositorIOS::Suspend() {
DCHECK(compositor_);
// Requests a compositor lock without a timeout.
compositor_suspended_lock_ =
compositor_->GetCompositorLock(nullptr, base::TimeDelta());
}

void BrowserCompositorIOS::Unsuspend() {
compositor_suspended_lock_ = nullptr;
}

} // namespace content
14 changes: 12 additions & 2 deletions content/browser/renderer_host/render_widget_host_view_ios.mm
Original file line number Diff line number Diff line change
Expand Up @@ -570,8 +570,18 @@ - (void)updateView:(UIScrollView*)view {
RequestSuccessfulPresentationTimeFromHostOrDelegate(
blink::mojom::RecordContentToVisibleTimeRequestPtr
visible_time_request) {
host()->RequestSuccessfulPresentationTimeForNextFrame(
std::move(visible_time_request));
// No state transition here so don't use
// has_saved_frame_before_state_transition.
if (browser_compositor_->GetDelegatedFrameHost()->HasSavedFrame()) {
// If the frame for the renderer is already available, then the
// tab-switching time is the presentation time for the browser-compositor.
browser_compositor_->GetDelegatedFrameHost()
->RequestSuccessfulPresentationTimeForNextFrame(
std::move(visible_time_request));
} else {
host()->RequestSuccessfulPresentationTimeForNextFrame(
std::move(visible_time_request));
}
}
void RenderWidgetHostViewIOS::
CancelSuccessfulPresentationTimeRequestForHostAndDelegate() {
Expand Down
2 changes: 0 additions & 2 deletions testing/buildbot/filters/ios.content_browsertests.filter
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@
-RenderWidgetHostSitePerProcessTest.BrowserClosesSelectPopup
-RenderWidgetHostTouchEmulatorBrowserTest.TouchEmulatorPinchWithGestureFling
-RenderWidgetHostViewChildFrameBrowserTest.VisualPropertiesPropagation_RootWindowSegments
-RenderWidgetHostViewPresentationFeedbackBrowserTest.Show
-RenderWidgetHostViewPresentationFeedbackBrowserTest.ShowWhileCapturing
-SRC_ClearKey/EncryptedMediaTest.Playback_VideoOnly_WebM_VP9Profile2/0
-ScrollBehaviorBrowserTest.InstantScriptScrollAdjustsSmoothWheelScroll
-ScrollBehaviorBrowserTest.SmoothWheelScrollCompletesWithScriptedMirror
Expand Down

0 comments on commit b9b30ca

Please sign in to comment.