Shopify / react-native-skia

High-performance React Native Graphics using Skia
https://shopify.github.io/react-native-skia
MIT License
6.98k stars 451 forks source link

Failed to create window surface native crash on android #2754

Open TomAtterton opened 3 hours ago

TomAtterton commented 3 hours ago

Ever since updating to version 1.5.5, the app now crashes on my Android device (Pixel 6).

2024-11-20 12:28:32.798 15830-15913 unknown:Vi...rtyUpdater com.tomatterton.advent               W  Could not find generated setter for class com.shopify.reactnative.skia.SkiaPictureViewManager
2024-11-20 12:28:32.799 15830-15913 unknown:Vi...rtyUpdater com.tomatterton.advent               W  Could not find generated setter for class com.shopify.reactnative.skia.SkiaDomViewManager
2024-11-20 12:28:34.435 15830-15912 nativeloader            com.tomatterton.advent               D  Load /data/app/~~ADlBVr7mg6_yR7xnb4EKGA==/com.tomatterton.advent-W3v2hwIrfKrYYZHLB_-bNQ==/base.apk!/lib/arm64-v8a/librnskia.so using ns clns-6 from class loader (caller=/data/app/~~ADlBVr7mg6_yR7xnb4EKGA==/com.tomatterton.advent-W3v2hwIrfKrYYZHLB_-bNQ==/base.apk!classes7.dex): ok
2024-11-20 12:28:38.867 15830-15830 SkiaView                com.tomatterton.advent               I  Create SurfaceTexture
2024-11-20 12:28:38.867 15830-15830 SkiaView                com.tomatterton.advent               I  onSurfaceTextureAvailable 0/0
2024-11-20 12:28:38.902 15830-15830 SkiaView                com.tomatterton.advent               I  onLayout 1080/2400
2024-11-20 12:28:38.902 15830-15830 SkiaView                com.tomatterton.advent               I  onSurfaceTextureSizeChanged 1080/2400
2024-11-20 12:28:38.902 15830-15830 RNSkia                  com.tomatterton.advent               I  EGL Error: Bad Alloc (12291) in /Users/tomatterton/Projects/advent-app/node_modules/@shopify/react-native-skia/android/cpp/rnskia-android/gl/Display.h:89
2024-11-20 12:28:38.903 15830-15830 unknown:ReactNative     com.tomatterton.advent               E  Exception in native call java.lang.RuntimeException: Failed to create window surface
    at com.shopify.reactnative.skia.SkiaDomView.surfaceSizeChanged(Native Method)
    at com.shopify.reactnative.skia.SkiaBaseView.onSurfaceTextureSizeChanged(SkiaBaseView.java:67)
    at android.view.TextureView.onSizeChanged(TextureView.java:453)
    at android.view.View.sizeChange(View.java:25350)
    at android.view.View.setFrame(View.java:25302)
    at android.view.View.layout(View.java:25153)
    at com.shopify.reactnative.skia.SkiaBaseView.onLayout(SkiaBaseView.java:52)
    at android.view.View.layout(View.java:25159)
    at android.view.ViewGroup.layout(ViewGroup.java:6460)
    at com.facebook.react.uimanager.NativeViewHierarchyManager.updateLayout(NativeViewHierarchyManager.java:265)
    at com.facebook.react.uimanager.NativeViewHierarchyManager.updateLayout(NativeViewHierarchyManager.java:233)
    at com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManagerBase.updateLayout(ReanimatedNativeHierarchyManagerBase.java:15)
    at com.facebook.react.uimanager.UIViewOperationQueue$UpdateLayoutOperation.execute(UIViewOperationQueue.java:145)
    at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:879)
    at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:992)
    at com.facebook.react.uimanager.UIViewOperationQueue.-$$Nest$mflushPendingBatches(Unknown Source:0)
    at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:1052)
    at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.kt:22)
    at com.facebook.react.modules.core.ReactChoreographer.frameCallback$lambda$1(ReactChoreographer.kt:60)
    at com.facebook.react.modules.core.ReactChoreographer.$r8$lambda$nSkFhrr5T7rop_XKwzlLov4NLLw(Unknown Source:0)
    at com.facebook.react.modules.core.ReactChoreographer$$ExternalSyntheticLambda0.doFrame(D8$$SyntheticClass:0)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1404)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1415)
    at android.view.Choreographer.doCallbacks(Choreographer.java:1015)
    at android.view.Choreographer.doFrame(Choreographer.java:941)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1389)
    at android.os.Handler.handleCallback(Handler.java:959)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loopOnce(Looper.java:232)
    at android.os.Looper.loop(Looper.java:317)
    at android.app.ActivityThread.main(ActivityThread.java:8592)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:878)
android": {
  "compileSdkVersion": 35,
  "targetSdkVersion": 35,
  "minSdkVersion": 24,
  "buildToolsVersion": "35.0.0",
  "newArchEnabled": false,
  "packagingOptions": {
    "pickFirst": ["**/libreactnative.so"]
  }
}

The only interaction with Skia in my project is with my package: react-native-snowfall. Running the example on the latest version seems to work fine, so Iā€™m confused about what could have caused the issue in my project.

wcandillon commented 3 hours ago

Can you try v1.5.6 and also share with me the project on which you run the example? I tried the example with minSdk 24 on the example app and it worked (trying in release mode now)

wcandillon commented 2 hours ago

I would also be curious to know if this happens on the simulator as well.

TomAtterton commented 2 hours ago

@wcandillon invited you to the project šŸ‘šŸ»

it does run on emulator without crashing interesting ! Pixel 4 api 32

wcandillon commented 2 hours ago

ok this is great to know because I use a Pixel 4, should I get a Pixel 6 or can I even get or newer pixel model?

TomAtterton commented 2 hours ago

I am using a Pixel 6 with android 14 that's only device I have on hand

wcandillon commented 1 hour ago

The app looks so beautiful, unfortunately it looks like the crash is not reproducible on the Pixel 6 emulator. (I ordered a physical pixel 8 device).