Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Crash in iOS release build when using SkiaFrameProcessor #3004

Open
5 tasks done
fnKode opened this issue Jun 17, 2024 · 3 comments
Open
5 tasks done

🐛 Crash in iOS release build when using SkiaFrameProcessor #3004

fnKode opened this issue Jun 17, 2024 · 3 comments
Labels
🐛 bug Something isn't working

Comments

@fnKode
Copy link

fnKode commented Jun 17, 2024

What's happening?

I'm trying to use the Skia frame processor to draw a rectangle in the camera preview. However, my app crashes when I try to open the camera.

This only happens if I create a release build of my app and then download it via TestFlight. Everything works fine if I build directly to my device and then run the app using Expo.

Also, this issue seems to only occur when I'm using the SkiaFrameProcessor. If I change to useFrameProcessor and remove the Skia related code, then the app works fine.

Reproduceable Code

"react-native-worklets-core": "^1.3.3"
"@shopify/react-native-skia": "1.3.4"
"react-native-vision-camera": "4.3.2"

export default function App() {
    const device = useCameraDevice("back");
    const { hasPermission, requestPermission } = useCameraPermission();

    const frameProcessor = useSkiaFrameProcessor(frame => {
        "worklet";
        frame.render();
        const rect = Skia.XYWHRect(frame.width / 2, frame.height / 2, 150, 150);
        const paint = Skia.Paint();
        paint.setColor(Skia.Color("red"));
        frame.drawRect(rect, paint);
    }, []);

    if (!hasPermission) {
        requestPermission();
        return <Text>No permission</Text>;
    }
    if (device == null) return <Text>No device</Text>;

    return (
        <Camera
            style={{ flex: 1 }}
            device={device}
            isActive
            frameProcessor={frameProcessor}
            onError={e => console.error(e)}
            outputOrientation="portrait"
        />
    );
}

Relevant log output

Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Subtype: KERN_PROTECTION_FAILURE at 0x000000016b677ff0
Exception Codes: 0x0000000000000002, 0x000000016b677ff0
VM Region Info: 0x16b677ff0 is in 0x16b674000-0x16b678000;  bytes after start: 16368  bytes before end: 15
      REGION TYPE                 START - END      [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      Stack                    16b5ec000-16b674000 [  544K] rw-/rwx SM=PRV  thread 19
--->  STACK GUARD              16b674000-16b678000 [   16K] ---/rwx SM=NUL  stack guard for thread 5
      Stack                    16b678000-16b700000 [  544K] rw-/rwx SM=PRV  thread 5
Termination Reason: SIGNAL 10 Bus error: 10
Terminating Process: exc handler [905]

Triggered by Thread:  5



Thread 5 name:
Thread 5 Crashed:
0   JavaScriptCore                	0x00000001b0a15e1c JSC::initialize() + 8 (InitializeThreading.cpp:68)
1   JavaScriptCore                	0x00000001b0023f60 JSStringCreateWithUTF8CString + 40 (JSStringRef.cpp:45)
2   MyApp                 	0x00000001050709fc 0x104ad4000 + 5884412
3   MyApp                 	0x00000001053284c0 0x104ad4000 + 8733888
4   MyApp                 	0x000000010533e9bc 0x104ad4000 + 8825276
5   MyApp                 	0x00000001053467dc 0x104ad4000 + 8857564
6   MyApp                 	0x00000001053459c4 0x104ad4000 + 8853956
7   MyApp                 	0x000000010533e928 0x104ad4000 + 8825128
8   MyApp                 	0x00000001053467dc 0x104ad4000 + 8857564
9   MyApp                 	0x00000001053459c4 0x104ad4000 + 8853956
10  MyApp                 	0x000000010533e928 0x104ad4000 + 8825128
11  MyApp                 	0x00000001053467dc 0x104ad4000 + 8857564
12  MyApp                 	0x00000001053459c4 0x104ad4000 + 8853956
13  MyApp                 	0x000000010533e928 0x104ad4000 + 8825128
14  MyApp                 	0x00000001053467dc 0x104ad4000 + 8857564
15  MyApp                 	0x00000001053459c4 0x104ad4000 + 8853956
16  MyApp                 	0x000000010533e928 0x104ad4000 + 8825128
17  MyApp                 	0x00000001053467dc 0x104ad4000 + 8857564
18  MyApp                 	0x00000001053459c4 0x104ad4000 + 8853956
19  MyApp                 	0x000000010533e928 0x104ad4000 + 8825128
20  MyApp                 	0x00000001053467dc 0x104ad4000 + 8857564
... repeats for 500 lines

Camera Device

{
    "hasTorch": true,
    "minZoom": 1,
    "minFocusDistance": 12,
    "sensorOrientation": "landscape-left",
    "hardwareLevel": "full",
    "maxExposure": 8,
    "supportsLowLightBoost": false,
    "physicalDevices": [
      "wide-angle-camera"
    ],
    "supportsFocus": true,
    "supportsRawCapture": false,
    "neutralZoom": 1,
    "maxZoom": 16,
    "hasFlash": true,
    "minExposure": -8,
    "name": "Back Camera",
    "formats": [],
    "isMultiCam": false,
    "position": "back"
  }

Device

iPad mini (6th generation) (iOS 17.5.1)

VisionCamera Version

4.3.2

Can you reproduce this issue in the VisionCamera Example app?

I didn't try (⚠️ your issue might get ignored & closed if you don't try this)

Additional information

@fnKode fnKode added the 🐛 bug Something isn't working label Jun 17, 2024
Copy link

maintenance-hans bot commented Jun 17, 2024

Guten Tag, Hans here.

Note

New features, bugfixes, updates and other improvements are all handled mostly by @mrousavy in his free time.
To support @mrousavy, please consider 💖 sponsoring him on GitHub 💖.
Sponsored issues will be prioritized.

@razr130
Copy link

razr130 commented Jun 19, 2024

Is there any updated on this issue?

@HaakonSvane
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
3 participants