facebook / SoLoader

Native code loader for Android
Apache License 2.0
1.32k stars 176 forks source link

Native crashes on Android 12 #84

Closed NickFitton closed 2 years ago

NickFitton commented 2 years ago

Summary

I am seeing crashes on the Google Play Console for the following devices:

All of these crashes are on android 12. I do not have one of these devices to test and provide a sample app, but I suspect a standard npx react-native init Repro could reproduce this on an android device.

Versions

Crash header

java.io.FileNotFoundException
com.facebook.soloader.FileLocker.<init>

Stacktrace

java.lang.RuntimeException: 
  at android.app.ActivityThread.handleBindApplication (ActivityThread.java:6730)
  at android.app.ActivityThread.access$1500 (ActivityThread.java:247)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2053)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  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 (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:548)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1003)
Caused by: java.lang.RuntimeException: 
  at com.facebook.soloader.SoLoader.init (SoLoader.java:219)
  at com.ovo.energy.MainApplication.onCreate (MainApplication.java:76)
  at android.app.Instrumentation.callApplicationOnCreate (Instrumentation.java:1211)
  at android.app.ActivityThread.handleBindApplication (ActivityThread.java:6725)
Caused by: java.io.FileNotFoundException: 
  at libcore.io.IoBridge.open (IoBridge.java:575)
  at java.io.FileOutputStream.<init> (FileOutputStream.java:236)
  at java.io.FileOutputStream.<init> (FileOutputStream.java:186)
  at com.facebook.soloader.FileLocker.<init> (FileLocker.java:36)
  at com.facebook.soloader.FileLocker.lock (FileLocker.java:32)
  at com.facebook.soloader.UnpackingSoSource.prepare (UnpackingSoSource.java:430)
  at com.facebook.soloader.SoLoader.initSoSources (SoLoader.java:327)
  at com.facebook.soloader.SoLoader.init (SoLoader.java:207)
  at com.facebook.soloader.SoLoader.init (SoLoader.java:189)
  at com.facebook.soloader.SoLoader.init (SoLoader.java:217)
Caused by: android.system.ErrnoException: 
  at libcore.io.Linux.open (Native Method)
  at libcore.io.ForwardingOs.open (ForwardingOs.java:567)
  at libcore.io.BlockGuardOs.open (BlockGuardOs.java:273)
  at libcore.io.ForwardingOs.open (ForwardingOs.java:567)
  at android.app.ActivityThread$AndroidOs.open (ActivityThread.java:7725)
  at libcore.io.IoBridge.open (IoBridge.java:561)

Other Notes

I cannot reproduce this on an android emulator. We have found that if the user re-installs the app the error can magically resolve.

NickFitton commented 2 years ago

Found this this error occurs when a user restores a back up from a device to an android 12 device. Re-installing solves the issue. SoLoader isn't the issue, just the first library to start poking files!

simpleton commented 2 years ago

@NickFitton, thanks for reporting.

a user restores a back up from a device to an android 12 device

can you describe what is this action? is this a migration from old device to new Android 12 device?

NickFitton commented 2 years ago

Hey! Exactly right, a user of an android device can restore existing data from a previous phone via google, we've found that this can cause what seems to be permission issues. The error seemed to be caused by SoLoader as it's the first lib in our app to touch files.