Commit 7969d894 authored by Yi Xu's avatar Yi Xu Committed by Commit Bot

Fix crash in Hibernate

As the ResourceProvider::snapshot() may return a nullptr, the subsequent calls
cause chrome to crash. Add checks before calling snapshot().

Bug: 991385

Change-Id: Ia00189a991afdbe8aff25d037cf02d78af376989
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1760276
Commit-Queue: Yi Xu <yiyix@chromium.org>
Reviewed-by: default avatarFernando Serboncini <fserb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#689146}
parent e5894810
......@@ -240,6 +240,10 @@ void Canvas2DLayerBridge::Hibernate() {
copy_paint.setBlendMode(SkBlendMode::kSrc);
scoped_refptr<StaticBitmapImage> snapshot =
resource_host_->ResourceProvider()->Snapshot();
if (!snapshot) {
logger_->ReportHibernationEvent(kHibernationAbortedDueSnapshotFailure);
return;
}
temp_hibernation_surface->getCanvas()->drawImage(
snapshot->PaintImageForCurrentFrame().GetSkImage(), 0, 0, &copy_paint);
hibernation_image_ = temp_hibernation_surface->makeImageSnapshot();
......
......@@ -146,11 +146,12 @@ class PLATFORM_EXPORT Canvas2DLayerBridge : public cc::TextureLayerClient {
kHibernationAbortedDueGpuContextLoss = 4,
kHibernationAbortedDueToSwitchToUnacceleratedRendering = 5,
kHibernationAbortedDueToAllocationFailure = 6,
kHibernationEndedNormally = 7,
kHibernationEndedWithSwitchToBackgroundRendering = 8,
kHibernationEndedWithFallbackToSW = 9,
kHibernationEndedWithTeardown = 10,
kHibernationAbortedBecauseNoSurface = 11,
kHibernationAbortedDueSnapshotFailure = 7,
kHibernationEndedNormally = 8,
kHibernationEndedWithSwitchToBackgroundRendering = 9,
kHibernationEndedWithFallbackToSW = 10,
kHibernationEndedWithTeardown = 11,
kHibernationAbortedBecauseNoSurface = 12,
kMaxValue = kHibernationAbortedBecauseNoSurface,
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment