Fix native OOM crash caused by ImageManipulator failure falling back to massive raw sensor capture

This commit is contained in:
2026-05-31 16:30:44 +02:00
parent c940286850
commit 2cf7ce38db
2 changed files with 18 additions and 5 deletions
+5 -2
View File
@@ -309,12 +309,15 @@ export default function CameraScreen({
const manipResult = await ImageManipulator.manipulateAsync( const manipResult = await ImageManipulator.manipulateAsync(
capturedUri, capturedUri,
actions, actions,
{ compress: 0.9, format: ImageManipulator.SaveFormat.JPEG } { compress: 0.9, format: 'jpeg' as any }
); );
capturedUri = manipResult.uri; capturedUri = manipResult.uri;
console.log('Successfully manipulated and cropped image'); console.log('Successfully manipulated and cropped image');
} catch (manipError) { } 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 // Auto-save individual photo to gallery
+12 -2
View File
@@ -185,7 +185,15 @@ export default function PreviewScreen({
// ── Capture the final image ── // ── Capture the final image ──
const captureComposite = async () => { const captureComposite = async () => {
try {
if (viewShotRef.current) {
return await viewShotRef.current.capture();
}
return currentPhoto; return currentPhoto;
} catch (e) {
console.error('Failed to capture composite:', e);
return currentPhoto;
}
}; };
// Triggers the view capture and the print job // Triggers the view capture and the print job
@@ -356,7 +364,9 @@ export default function PreviewScreen({
activeOpacity={1} activeOpacity={1}
onPress={handleCanvasPress} onPress={handleCanvasPress}
> >
<View <ViewShot
ref={viewShotRef}
options={{ format: 'jpg', quality: 0.95 }}
style={styles.viewShotContainer} style={styles.viewShotContainer}
> >
{renderCollageView()} {renderCollageView()}
@@ -384,7 +394,7 @@ export default function PreviewScreen({
onUpdate={handleStickerUpdate} onUpdate={handleStickerUpdate}
/> />
))} ))}
</View> </ViewShot>
{/* Sticker Tray (outside ViewShot — not captured) */} {/* Sticker Tray (outside ViewShot — not captured) */}
{showStickerTray && ( {showStickerTray && (