Add some more logs for diagnosing screenshot failures (flutter/engine#6156)

Fixes https://github.com/flutter/flutter/issues/21228
This commit is contained in:
Jason Simmons
2018-09-04 14:38:10 -07:00
committed by GitHub
parent 56307bb5d7
commit c8316af625

View File

@@ -173,6 +173,7 @@ static sk_sp<SkData> ScreenshotLayerTreeAsImage(
auto snapshot_surface =
CreateSnapshotSurface(surface_context, tree->frame_size());
if (snapshot_surface == nullptr) {
FML_LOG(ERROR) << "Screenshot: unable to create snapshot surface";
return nullptr;
}
@@ -193,16 +194,18 @@ static sk_sp<SkData> ScreenshotLayerTreeAsImage(
// Prepare an image from the surface, this image may potentially be on th GPU.
auto potentially_gpu_snapshot = snapshot_surface->makeImageSnapshot();
if (!potentially_gpu_snapshot) {
FML_LOG(ERROR) << "Screenshot: unable to make image screenshot";
return nullptr;
}
// Copy the GPU image snapshot into CPU memory.
auto cpu_snapshot = potentially_gpu_snapshot->makeRasterImage();
if (!cpu_snapshot) {
FML_LOG(ERROR) << "Screenshot: unable to make raster image";
return nullptr;
}
// If the caller want the pixels to be compressed, there is a Skia utilitiy to
// If the caller want the pixels to be compressed, there is a Skia utility to
// compress to PNG. Use that.
if (compressed) {
return cpu_snapshot->encodeToData();
@@ -211,6 +214,7 @@ static sk_sp<SkData> ScreenshotLayerTreeAsImage(
// Copy it into a bitmap and return the same.
SkPixmap pixmap;
if (!cpu_snapshot->peekPixels(&pixmap)) {
FML_LOG(ERROR) << "Screenshot: unable to obtain bitmap pixels";
return nullptr;
}
@@ -222,7 +226,7 @@ Rasterizer::Screenshot Rasterizer::ScreenshotLastLayerTree(
bool base64_encode) {
auto layer_tree = GetLastLayerTree();
if (layer_tree == nullptr) {
FML_DLOG(INFO) << "Last layer tree was null when screenshotting.";
FML_LOG(ERROR) << "Last layer tree was null when screenshotting.";
return {};
}
@@ -246,7 +250,7 @@ Rasterizer::Screenshot Rasterizer::ScreenshotLastLayerTree(
}
if (data == nullptr) {
FML_DLOG(INFO) << "Sceenshot data was null.";
FML_LOG(ERROR) << "Screenshot data was null.";
return {};
}