From 2cf7ce38db5c7eb34d5cc4241af2a08836e3c784 Mon Sep 17 00:00:00 2001 From: orfelorfel23 Date: Sun, 31 May 2026 16:30:44 +0200 Subject: [PATCH] Fix native OOM crash caused by ImageManipulator failure falling back to massive raw sensor capture --- src/screens/CameraScreen.tsx | 7 +++++-- src/screens/PreviewScreen.tsx | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/screens/CameraScreen.tsx b/src/screens/CameraScreen.tsx index 62fbdc1a..e006c30b 100644 --- a/src/screens/CameraScreen.tsx +++ b/src/screens/CameraScreen.tsx @@ -309,12 +309,15 @@ export default function CameraScreen({ const manipResult = await ImageManipulator.manipulateAsync( capturedUri, actions, - { compress: 0.9, format: ImageManipulator.SaveFormat.JPEG } + { compress: 0.9, format: 'jpeg' as any } ); capturedUri = manipResult.uri; console.log('Successfully manipulated and cropped image'); } catch (manipError) { - console.error('Failed to manipulate image, proceeding with original:', manipError); + console.error('Failed to manipulate image, preventing OOM crash!', manipError); + alert('Fehler bei der Bildverarbeitung! Das Bild ist zu groß oder das Format wird nicht unterstützt.'); + onCancel(); + return; // Abort here so we don't send a 16MB raw image to PreviewScreen } // Auto-save individual photo to gallery diff --git a/src/screens/PreviewScreen.tsx b/src/screens/PreviewScreen.tsx index 41441e47..02a5b13a 100644 --- a/src/screens/PreviewScreen.tsx +++ b/src/screens/PreviewScreen.tsx @@ -185,7 +185,15 @@ export default function PreviewScreen({ // ── Capture the final image ── const captureComposite = async () => { - return currentPhoto; + try { + if (viewShotRef.current) { + return await viewShotRef.current.capture(); + } + return currentPhoto; + } catch (e) { + console.error('Failed to capture composite:', e); + return currentPhoto; + } }; // Triggers the view capture and the print job @@ -356,7 +364,9 @@ export default function PreviewScreen({ activeOpacity={1} onPress={handleCanvasPress} > - {renderCollageView()} @@ -384,7 +394,7 @@ export default function PreviewScreen({ onUpdate={handleStickerUpdate} /> ))} - + {/* Sticker Tray (outside ViewShot — not captured) */} {showStickerTray && (