fix: offscreen rendering does not paint after gpu process crashed (#41925)

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: zhangqi.67 <zhangqi.67@bytedance.com>
This commit is contained in:
trop[bot] 2024-04-22 17:04:39 -05:00 committed by GitHub
parent d800684d74
commit 8fd8757248
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 29 additions and 3 deletions

View file

@ -230,6 +230,7 @@ OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView(
ResizeRootLayer(false);
render_widget_host_->SetView(this);
render_widget_host_->render_frame_metadata_provider()->AddObserver(this);
if (content::GpuDataManager::GetInstance()->HardwareAccelerationEnabled()) {
video_consumer_ = std::make_unique<OffScreenVideoConsumer>(
@ -240,7 +241,21 @@ OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView(
}
}
void OffScreenRenderWidgetHostView::OnLocalSurfaceIdChanged(
const cc::RenderFrameMetadata& metadata) {
if (metadata.local_surface_id) {
bool changed = delegated_frame_host_allocator_.UpdateFromChild(
*metadata.local_surface_id);
if (changed) {
ResizeRootLayer(true);
}
}
}
OffScreenRenderWidgetHostView::~OffScreenRenderWidgetHostView() {
render_widget_host_->render_frame_metadata_provider()->RemoveObserver(this);
// Marking the DelegatedFrameHost as removed from the window hierarchy is
// necessary to remove all connections to its old ui::Compositor.
if (is_showing_)