From aba50889f285bb0227ddad4133be920da0c9763e Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Wed, 26 Jul 2023 04:24:07 -0700 Subject: [PATCH] Snapshot to use key window size if possible Summary: Use the application key window bounds if possible. In the case where the application is not using the entire screen, like in Split View on an iPad, the running application is not using the entire screen thus the snapshot stretches to fill the screen size which is incorrect. Reviewed By: LukeDefeo Differential Revision: D47793033 fbshipit-source-id: d6c7932d35bad13752713772d078f94bad530b09 --- .../FlipperKitUIDebuggerPlugin/Utilities/UIDSnapshot.m | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Utilities/UIDSnapshot.m b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Utilities/UIDSnapshot.m index eaf28c2fa..a876c89c1 100644 --- a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Utilities/UIDSnapshot.m +++ b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Utilities/UIDSnapshot.m @@ -25,6 +25,16 @@ UIImage* UIDViewSnapshot(UIView* view) { UIImage* UIDApplicationSnapshot(UIApplication* application, NSArray* windows) { CGSize size = [UIScreen mainScreen].bounds.size; + + // Use the application key window bounds if possible. + // In the case where the application is not using the entire screen, + // like in Split View on an iPad, the running application is + // not using the entire screen thus the snapshot stretches to + // fill the screen size which is incorrect. + if (application.keyWindow) { + size = application.keyWindow.bounds.size; + } + UIGraphicsImageRenderer* renderer = [[UIGraphicsImageRenderer alloc] initWithSize:size];