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

Failed to create window surface native crash on android #2754

Closed
TomAtterton opened this issue Nov 20, 2024 · 16 comments
Closed

Failed to create window surface native crash on android #2754

TomAtterton opened this issue Nov 20, 2024 · 16 comments

Comments

@TomAtterton
Copy link

TomAtterton commented Nov 20, 2024

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
Copy link
Contributor

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
Copy link
Contributor

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

@TomAtterton
Copy link
Author

@wcandillon invited you to the project 👍🏻

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

@wcandillon
Copy link
Contributor

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
Copy link
Author

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

@wcandillon
Copy link
Contributor

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).

@bluekyu
Copy link
Contributor

bluekyu commented Nov 21, 2024

I also had same issue since v1.5.5. It worked until v1.5.4.
My device is Pixel 7 & Android 15.

@antonandreyev
Copy link

Confirm it happens with 1.5.6 as well

@wcandillon
Copy link
Contributor

@TomAtterton you seem to be able to reproduce the issue locally, could I provide you a test package from #2759 and get some feedback? Anyone would be willing to test a potential fix for it?

@tsnguyenducphuong
Copy link

Hi William,

I am willing to test the potential fix.
I got the same issue using 1.5.6:
Crashed on my Samsung A51, Android 14 and got crashed report from Google Play for Pixel 7 Android 13 and Pixel 6 Android 12.

Best regards,
Phuong

Reproducible code:

    var surface = Skia.Surface.MakeOffscreen(width,height);
    var canvas = surface.getCanvas();

Error message:

Exception java.lang.RuntimeException: Failed to create window surface
at com.shopify.reactnative.skia.SkiaDomView.surfaceSizeChanged
at com.shopify.reactnative.skia.SkiaBaseView.onSurfaceTextureSizeChanged (SkiaBaseView.java:67)
at android.view.TextureView.onSizeChanged (TextureView.java:381)
at android.view.View.sizeChange (View.java:23332)
at android.view.View.setFrame (View.java:23284)
at android.view.View.layout (View.java:23141)
at com.shopify.reactnative.skia.SkiaBaseView.onLayout (SkiaBaseView.java:52)
at android.view.View.layout (View.java:23144)
at android.view.ViewGroup.layout (ViewGroup.java:6412)
at com.facebook.react.uimanager.NativeViewHierarchyManager.updateLayout (NativeViewHierarchyManager.java:254)
at com.facebook.react.uimanager.NativeViewHierarchyManager.updateLayout (NativeViewHierarchyManager.java:222)
at com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager.updateLayout (ReanimatedNativeHierarchyManager.java:283)
at com.facebook.react.uimanager.UIViewOperationQueue$UpdateLayoutOperation.execute (UIViewOperationQueue.java:135)
at com.facebook.react.uimanager.UIViewOperationQueue$1.run (UIViewOperationQueue.java:910)
at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches (UIViewOperationQueue.java:1023)
at com.facebook.react.uimanager.UIViewOperationQueue.-$$Nest$mflushPendingBatches (Unknown Source)
at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded (UIViewOperationQueue.java:1083)
at com.facebook.react.uimanager.GuardedFrameCallback.doFrame (GuardedFrameCallback.java:29)
at com.facebook.react.modules.core.ReactChoreographer$1.doFrame (ReactChoreographer.java:89)
at android.view.Choreographer$CallbackRecord.run (Choreographer.java:1035)
at android.view.Choreographer.doCallbacks (Choreographer.java:845)
at android.view.Choreographer.doFrame (Choreographer.java:775)
at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:1022)
at android.os.Handler.handleCallback (Handler.java:938)
at android.os.Handler.dispatchMessage (Handler.java:99)
at androidx.test.espresso.base.Interrogator.loopAndInterrogate (Interrogator.java:10)
at androidx.test.espresso.base.UiControllerImpl.loopUntil (UiControllerImpl.java:7)
at androidx.test.espresso.base.UiControllerImpl.loopUntil (UiControllerImpl.java:1)
at androidx.test.espresso.base.UiControllerImpl.loopMainThreadForAtLeast (UiControllerImpl.java:7)
at androidx.test.espresso.action.Tap$1.sendTap (Tap.java:4)
at androidx.test.espresso.action.GeneralClickAction.perform (GeneralClickAction.java:4)
at androidx.test.espresso.ViewInteraction$SingleExecutionViewAction.perform (ViewInteraction.java:2)
at androidx.test.espresso.ViewInteraction.doPerform (ViewInteraction.java:23)
at androidx.test.espresso.ViewInteraction.-$$Nest$mdoPerform (Unknown Source)
at androidx.test.espresso.ViewInteraction$1.call (ViewInteraction.java:6)
at androidx.test.espresso.ViewInteraction$1.call (ViewInteraction.java:1)
at java.util.concurrent.FutureTask.run (FutureTask.java:266)
at android.os.Handler.handleCallback (Handler.java:938)
at android.os.Handler.dispatchMessage (Handler.java:99)
at android.os.Looper.loopOnce (Looper.java:201)
at android.os.Looper.loop (Looper.java:288)
at android.app.ActivityThread.main (ActivityThread.java:7839)
at java.lang.reflect.Method.invoke
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1003)

@wcandillon
Copy link
Contributor

@wcandillon
Copy link
Contributor

v1.5.7 is published, I would love to get a read on whether it is improving Android stability?

@tsnguyenducphuong
Copy link

Thanks @wcandillon
I use 1.5.7 and it works fine now on my Android 14 phone

@wcandillon
Copy link
Contributor

closing based on #1982 (comment)

@TomCorvus
Copy link

I confirm that it works on 1.5.7, thank you @wcandillon!

@TomAtterton
Copy link
Author

@wcandillon just tested and it works for me too 🥳 Thanks for picking this up so quickly <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants