From 77d7ec2efbea5cfe1c119237dec509de326677af Mon Sep 17 00:00:00 2001 From: Pascal Hartig Date: Fri, 3 Dec 2021 03:28:42 -0800 Subject: [PATCH] Guard against screenshot capture failure Summary: Bit off an odd one but according to the crash report in T107008330, the screenshot can sometimes be not a real buffer. This may not actually fix things but should give us some more insights into what's up. Changelog: Better handling of screenshot taking in navigation Reviewed By: mweststrate Differential Revision: D32797863 fbshipit-source-id: 6d16ccb82fb8258591f9bc5f79c00811b18b9c51 --- desktop/plugins/public/navigation/plugin.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/desktop/plugins/public/navigation/plugin.tsx b/desktop/plugins/public/navigation/plugin.tsx index 4412ee7f4..6551e37ab 100644 --- a/desktop/plugins/public/navigation/plugin.tsx +++ b/desktop/plugins/public/navigation/plugin.tsx @@ -74,6 +74,12 @@ export function plugin(client: PluginClient) { }); const screenshot: Buffer = await client.device.screenshot(); + if (screenshot.byteLength === 0) { + console.warn( + '[navigation] Could not retrieve valid screenshot from the device.', + ); + return; + } const blobURL = URL.createObjectURL(bufferToBlob(screenshot)); // this process is async, make sure we update the correct one.. const navigationEventIndex = navigationEvents