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:
parent
d800684d74
commit
8fd8757248
2 changed files with 29 additions and 3 deletions
|
@ -230,6 +230,7 @@ OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView(
|
||||||
|
|
||||||
ResizeRootLayer(false);
|
ResizeRootLayer(false);
|
||||||
render_widget_host_->SetView(this);
|
render_widget_host_->SetView(this);
|
||||||
|
render_widget_host_->render_frame_metadata_provider()->AddObserver(this);
|
||||||
|
|
||||||
if (content::GpuDataManager::GetInstance()->HardwareAccelerationEnabled()) {
|
if (content::GpuDataManager::GetInstance()->HardwareAccelerationEnabled()) {
|
||||||
video_consumer_ = std::make_unique<OffScreenVideoConsumer>(
|
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() {
|
OffScreenRenderWidgetHostView::~OffScreenRenderWidgetHostView() {
|
||||||
|
render_widget_host_->render_frame_metadata_provider()->RemoveObserver(this);
|
||||||
|
|
||||||
// Marking the DelegatedFrameHost as removed from the window hierarchy is
|
// Marking the DelegatedFrameHost as removed from the window hierarchy is
|
||||||
// necessary to remove all connections to its old ui::Compositor.
|
// necessary to remove all connections to its old ui::Compositor.
|
||||||
if (is_showing_)
|
if (is_showing_)
|
||||||
|
|
|
@ -59,9 +59,11 @@ typedef base::RepeatingCallback<void(const gfx::Rect&, const SkBitmap&)>
|
||||||
OnPaintCallback;
|
OnPaintCallback;
|
||||||
typedef base::RepeatingCallback<void(const gfx::Rect&)> OnPopupPaintCallback;
|
typedef base::RepeatingCallback<void(const gfx::Rect&)> OnPopupPaintCallback;
|
||||||
|
|
||||||
class OffScreenRenderWidgetHostView : public content::RenderWidgetHostViewBase,
|
class OffScreenRenderWidgetHostView
|
||||||
public ui::CompositorDelegate,
|
: public content::RenderWidgetHostViewBase,
|
||||||
public OffscreenViewProxyObserver {
|
public content::RenderFrameMetadataProvider::Observer,
|
||||||
|
public ui::CompositorDelegate,
|
||||||
|
public OffscreenViewProxyObserver {
|
||||||
public:
|
public:
|
||||||
OffScreenRenderWidgetHostView(bool transparent,
|
OffScreenRenderWidgetHostView(bool transparent,
|
||||||
bool painting,
|
bool painting,
|
||||||
|
@ -175,6 +177,15 @@ class OffScreenRenderWidgetHostView : public content::RenderWidgetHostViewBase,
|
||||||
RenderWidgetHostViewBase* target_view,
|
RenderWidgetHostViewBase* target_view,
|
||||||
gfx::PointF* transformed_point) override;
|
gfx::PointF* transformed_point) override;
|
||||||
|
|
||||||
|
// RenderFrameMetadataProvider::Observer:
|
||||||
|
void OnRenderFrameMetadataChangedBeforeActivation(
|
||||||
|
const cc::RenderFrameMetadata& metadata) override {}
|
||||||
|
void OnRenderFrameMetadataChangedAfterActivation(
|
||||||
|
base::TimeTicks activation_time) override {}
|
||||||
|
void OnRenderFrameSubmission() override {}
|
||||||
|
void OnLocalSurfaceIdChanged(
|
||||||
|
const cc::RenderFrameMetadata& metadata) override;
|
||||||
|
|
||||||
// ui::CompositorDelegate:
|
// ui::CompositorDelegate:
|
||||||
bool IsOffscreen() const override;
|
bool IsOffscreen() const override;
|
||||||
std::unique_ptr<viz::HostDisplayClient> CreateHostDisplayClient(
|
std::unique_ptr<viz::HostDisplayClient> CreateHostDisplayClient(
|
||||||
|
|
Loading…
Reference in a new issue