jpudysz / react-native-unistyles

Level up your React Native StyleSheet
https://unistyl.es
MIT License
1.4k stars 39 forks source link

[2.3.0] java.lang.UnsatisfiedLinkError #151

Closed efstathiosntonas closed 6 months ago

efstathiosntonas commented 7 months ago

Description

It only appeared once in a huge user base and it happened on MainActivity#onResume() on Android 13 Samsung S20 FE 5G:

java.lang.UnsatisfiedLinkError: No implementation found for void com.unistyles.UnistylesModule.nativeOnOrientationChange(int, int) (tried Java_com_unistyles_UnistylesModule_nativeOnOrientationChange and Java_com_unistyles_UnistylesModule_nativeOnOrientationChange__II) - is the library loaded, e.g. System.loadLibrary?
        at com.unistyles.UnistylesModule.nativeOnOrientationChange(UnistylesModule.kt:-2)
        at com.unistyles.UnistylesModule.onConfigChange$lambda$0(UnistylesModule.kt:51)
        at com.unistyles.UnistylesModule.$r8$lambda$Y5cS3iwg3AGCEcfvPfDYHsquXR0(Unknown)
        at com.unistyles.UnistylesModule$$ExternalSyntheticLambda0.run(Unknown:4)
        at android.os.Handler.handleCallback(Handler.java:942)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
        at android.os.Looper.loopOnce(Looper.java:226)
        at android.os.Looper.loop(Looper.java:313)
        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:234)
        at java.lang.Thread.run(Thread.java:1012)

Steps to reproduce

  1. Can't reproduce it

Snack or a link to a repository (optional)

No response

Unistyles version

2.3.0

React Native version

0.73.4

Platforms

Android

Engine

Hermes

Architecture

Paper (old)

jpudysz commented 7 months ago

Hey @efstathiosntonas, I appreciate your report.

Although you haven't provided reproducible steps and the error is both cryptic and nonsensical, I actually have one idea why it may happen. I will address it in the next release (this week) with a potential fix.

efstathiosntonas commented 7 months ago

Thanks for looking into this Jacek. Truth is I cannot reproduce it, I'm not doing anything fancy in unistyles setup and it's working as a charm.

It happened only in 1 Android device/user among thousands of them in a timespan of 1 month.

jpudysz commented 7 months ago

I see. I also didn't encounter any errors in Sentry. I hope version 2.4.0 will resolve this. I will keep the issue open until the next release.

efstathiosntonas commented 7 months ago

Today the crashes counter increased to 4, not that it will help much but the error changed slightly:

java.lang.UnsatisfiedLinkError: No implementation found for void com.unistyles.UnistylesModule.nativeOnOrientationChange(int, int) (tried Java_com_unistyles_UnistylesModule_nativeOnOrientationChange and Java_com_unistyles_UnistylesModule_nativeOnOrientationChange__II)
        at com.unistyles.UnistylesModule.nativeOnOrientationChange(UnistylesModule.kt:-2)
        at com.unistyles.UnistylesModule.onConfigChange$lambda$0(UnistylesModule.kt:51)
        at com.unistyles.UnistylesModule.$r8$lambda$Y5cS3iwg3AGCEcfvPfDYHsquXR0(Unknown)
        at com.unistyles.UnistylesModule$$ExternalSyntheticLambda0.run(Unknown:4)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
        at android.os.Looper.loop(Looper.java:223)
        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:234)
        at java.lang.Thread.run(Thread.java:923)
jpudysz commented 7 months ago

I already have a fix on the branch πŸ™

efstathiosntonas commented 6 months ago

@jpudysz hi, sorry for asking but is there an eta for this fix? I'm about to ship an update πŸ˜“

jpudysz commented 6 months ago

Yeah, sorry I had to fully test Android. I will be able to ship this evening / tomorrow morning CET time as I'm almost ready

efstathiosntonas commented 6 months ago

perfect, thanks @jpudysz, keep it up!

jpudysz commented 6 months ago

Thanks @efstathiosntonas for being patient, this release will be huge!

efstathiosntonas commented 6 months ago

yeah, one more reason to ask before shipping the update haha!

jpudysz commented 6 months ago

I've just released v2.4.0-rc.2. Mobile/Web/SSR/macOS are tested and implemented there. I just need to align windows code. You can give it a try.

jpudysz commented 6 months ago

Released #149

jpudysz commented 6 months ago

@efstathiosntonas any update about the crashes?

efstathiosntonas commented 6 months ago

@jpudysz hi, all good on 2.4.0, let's close this! Thank you ❀️

professorkolik commented 1 month ago

I'm able to reproduce it with latest version 2.9.0 It happens after interacting with TextInput and goBack in react navigation

UnsatisfiedLinkError: No implementation found for void com.unistyles.UnistylesModule.nativeOnOrientationChange(com.unistyles.Screen, com.unistyles.Insets, com.unistyles.Dimensions, com.unistyles.Dimensions) (tried Java_com_unistyles_UnistylesModule_nativeOnOrientationChange and Java_com_unistyles_UnistylesModule_nativeOnOrientationChange__Lcom_unistyles_Screen_2Lcom_unistyles_Insets_2Lcom_unistyles_Dimensions_2Lcom_unistyles_Dimensions_2) - is the library loaded, e.g. System.loadLibrary?

jpudysz commented 1 month ago

Is this Android with ProGuard ?

professorkolik commented 1 month ago

ProGuard is disabled, in debug buildType, Android 34 (Pixel 7) - Emulator

react-native: 0.74.3
react-native-unistyles: 2.9.0
"@react-navigation/native": "^6.1.18",
"@react-navigation/native-stack": "^6.11.0"

UPD

It seems it's not related to react-navigation directly It happens when I close the keyboard

I will try to make a reproducible app tomorrow

jpudysz commented 1 month ago

Can you build a small repro?

professorkolik commented 1 month ago

@jpudysz We found what was the problem To give some context

We had to initialise unistyles in the App as well otherwise it was crashing on Android on keyboard hide

jpudysz commented 1 month ago

Got it, thanks for letting me know πŸ™πŸΌ

gmantuanrosa commented 3 weeks ago

@jpudysz I can't build a small repro but I could reproduce the issue. I'm using Android Native + React Native with Unistyles for some screens, also I am just setting up Unistyles as the doc says.

1 - Have a theme file 2 - Have an unistyles file at root level 3 - Import unistyles on App.

My Android App doesn't have any other orientation so I force portrait mode for all activities, including React Native Activity, by adding this property on the manifest:

android:screenOrientation="portrait"

What I did to reproduce the issue was: 1 - Open a React Native screen that contains an input text that opens a keyboard; 2 - Open the Keyboard; 3 - Close the keyboard by pressing on the button to close it or just loosing focus of the input text (Crash).

My release .apk has -keep class com.unistyles.** { *; } on the proguard-rules.pro file so I don't know how can I solve it.

"react-native-unistyles": "^2.9.1",
"react": "18.2.0",
"react-native": "0.74.5",

If you give me more time I can try to recreate a close scenario to what i have here...

jpudysz commented 3 weeks ago

I'm happy to help, but I can't afford to spend a few hours looking for the problem. A repro is needed. I use Unistyles every day in several projects and have never encountered this issue (also, I'm not using ProGuard).

gmantuanrosa commented 3 weeks ago

@jpudysz Thanks for the quick reply!!

I could find the issue and despite me being the issue as well, I had one small entry point registered for the screen that is crashing (I don't share all screens on a single app registry).

That entry point didn't have the import for unistyles even though I am not using it on any of that screens (they are legacy and use styled-components). By adding the import on that entry point the crash was fixed πŸ˜„

jpudysz commented 3 weeks ago

That's why repros are critical πŸ˜„ I'm happy that you've found the root cause!