google-ar / sceneform-android-sdk

Sceneform SDK for Android
https://developers.google.com/sceneform/develop/
Apache License 2.0
1.23k stars 604 forks source link

UnsatisfiedLinkError when ArSceneView.resume() is called #78

Closed drunkenplatypus closed 6 years ago

drunkenplatypus commented 6 years ago

I'm using the solarsystem example app on the Android Emulator (v27.3.4, Pixel 2 API 27, Android 8.1).

When the program calls arSceneView.resume() I am getting an UnsatisfiedLinkError when it is trying to execute System.loadLibrary("arsceneview_jni").

I analysed the APK and could see that libarsceneview_jni.so was included in the arm64-v8a lib directory, but it was not included in the x86 lib directory.

In this example app it seems to just ignore the fact it can't find it and continue. However on an app that I have made, this is the last error I can see before the app crashes.

My setup:

Android Studio 3.2 Canary 13 Build #AI-181.4445.78.32.4749738, built on April 27, 2018 JRE: 1.8.0_152-release-1136-b03 amd64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Linux 4.13.0-43-generic

Logcat of error

2018-06-06 10:17:51.137 18737-18737/com.example.ezio.ar_rf_demo E/ArSceneView: Error loading libarsceneview_jni.so java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.ezio.ar_rf_demo-zd2B2OglxcrOEBwzbiXNog==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.ezio.ar_rf_demo-zd2B2OglxcrOEBwzbiXNog==/lib/x86, /data/app/com.example.ezio.ar_rf_demo-zd2B2OglxcrOEBwzbiXNog==/base.apk!/lib/x86, /system/lib, /vendor/lib]]] couldn't find "libarsceneview_jni.so" at java.lang.Runtime.loadLibrary0(Runtime.java:1011) at java.lang.System.loadLibrary(System.java:1657) at com.google.ar.sceneform.ArSceneView.reportEngineType(Unknown Source:2) at com.google.ar.sceneform.ArSceneView.resume(Unknown Source:4) at com.example.ezio.ar_rf_demo.MainActivity.onResume(MainActivity.java:226) at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1355) at android.app.Activity.performResume(Activity.java:7117) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3556) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3621) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1638) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6494) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

dsternfeld7 commented 6 years ago

What are the abi filters from your gradle script?

From the sample gradle scripts:

        ndk {
            /*
             * Sceneform is available for the following ABIs: arm64-v8a, armv7a,
             * x86_64 and x86. This sample app enables arm64-v8a to run on
             * devices and x86 to run on the emulator. Your application should
             * list the ABIs most appropriate to minimize APK size (arm64-v8a recommended).
             */
            abiFilters 'arm64-v8a', 'x86'
        }
drunkenplatypus commented 6 years ago

I get the error using the solarsystem demo app, completely unmodified. So yes, they are the abiFilters I'm using.

EDIT: I should add that I am on Ubuntu 16.04.

jwmcglynn commented 6 years ago

@drunkenplatypus That's very strange. To help investigate, I think it would be helpful to get more information on your emulator.

Can you launch the emulator, reproduce the issue, then save a bug report in Extended controls ("..." on the Toolbar) > Bug Report panel, and then send the data my way?

Drewbie18 commented 6 years ago

@jwmcglynn I believe I am seeing this same issue, for me it occurs when 'hellosceneform' or the 'solarsystem' apps start on my AVD. Please note I have tried several times to generate a bug report but it keeps failing.

My setup: Android Studio 3.1.4 Build #AI-173.4907809, built on July 23, 2018 JRE: 1.8.0_152-release-1024-b02 amd64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Windows 10 10.0 Emulator: 27.3.9

AVD: Name: Pixel_XL_API_27 CPU/ABI: Google APIs Intel Atom (x86) Target: google_apis [Google APIs] (API level P) Skin: 1440x2560

Stack Trace example: 8-12 02:38:20.022 5580-5580/com.google.ar.sceneform.samples.hellosceneform E/ArSceneView: Error loading libarsceneview_jni.so java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.google.ar.sceneform.samples.hellosceneform-utWO-3I3wyY8wQChVlL1fA==/base.apk"],nativeLibraryDirectories=[/data/app/com.google.ar.sceneform.samples.hellosceneform-utWO-3I3wyY8wQChVlL1fA==/lib/x86, /data/app/com.google.ar.sceneform.samples.hellosceneform-utWO-3I3wyY8wQChVlL1fA==/base.apk!/lib/x86, /system/lib]]] couldn't find "libarsceneview_jni.so" at java.lang.Runtime.loadLibrary0(Runtime.java:1012) at java.lang.System.loadLibrary(System.java:1657) at com.google.ar.sceneform.ArSceneView.reportEngineType(Unknown Source:2) at com.google.ar.sceneform.ArSceneView.resume(Unknown Source:4) at com.google.ar.sceneform.ux.BaseArFragment.start(BaseArFragment.java:453) at com.google.ar.sceneform.ux.BaseArFragment.onResume(BaseArFragment.java:299) at android.support.v4.app.Fragment.performResume(Fragment.java:2390) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1474) at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1759) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1827) at android.support.v4.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3244) at android.support.v4.app.FragmentManagerImpl.dispatchResume(FragmentManager.java:3212) at android.support.v4.app.FragmentController.dispatchResume(FragmentController.java:217) at android.support.v4.app.FragmentActivity.onResumeFragments(FragmentActivity.java:509) at android.support.v4.app.FragmentActivity.onPostResume(FragmentActivity.java:498) at android.support.v7.app.AppCompatActivity.onPostResume(AppCompatActivity.java:171) at android.app.Activity.performResume(Activity.java:7293) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3727) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3787) at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:51) at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:146) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:75) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1786) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6656) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)

claywilkinson commented 6 years ago

@drunkenplatypus - Thanks for the issue report. As you noticed, it is a problem loading a library in the emulator (or x86 devices), and other than creating an exception in the log file, it does not affect the performance or functionality of Sceneform. It's on the list to fix in a future release.

soshial commented 5 years ago

Same stacktrace might be caused by different problem:

Screenshot 2019-09-27 at 15 06 57

VERY IMPORTANT. If you have such fatal crashes, it means you forgot to update BOTH implementation AND classpath versions! (This issue is about the case with no crash)

2019-09-27 15:05:41.024 libc: Fatal signal 6 (SIGABRT), code -6 in tid 28022

2019-09-27 15:05:41.294 28879-28879/? A/DEBUG: 2019-09-27 15:05:41.294 28879-28879/? A/DEBUG: Build fingerprint: 'samsung/a3y17ltexc/a3y17lte:8.0.0/R16NW/A320FLXXS4CSG5:user/release-keys' 2019-09-27 15:05:41.294 28879-28879/? A/DEBUG: Revision: '4' 2019-09-27 15:05:41.294 28879-28879/? A/DEBUG: ABI: 'arm' 2019-09-27 15:05:41.294 28879-28879/? A/DEBUG: pid: 28022, tid: 28022, name: ... 2019-09-27 15:05:41.294 28879-28879/? A/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr -------- 2019-09-27 15:05:41.294 28879-28879/? A/DEBUG: r0 00000000 r1 00006d76 r2 00000006 r3 00000008 2019-09-27 15:05:41.294 28879-28879/? A/DEBUG: r4 00006d76 r5 00006d76 r6 ffb5fda0 r7 0000010c 2019-09-27 15:05:41.294 28879-28879/? A/DEBUG: r8 00000056 r9 c16da98d sl 00000000 fp ffb5ff6c 2019-09-27 15:05:41.294 28879-28879/? A/DEBUG: ip 00000000 sp ffb5fd90 lr ecf354c7 pc ecf66748 cpsr 200e0010 2019-09-27 15:05:41.297 28879-28879/? A/DEBUG: backtrace: 2019-09-27 15:05:41.297 28879-28879/? A/DEBUG: #00 pc 0004b748 /system/lib/libc.so (tgkill+12) 2019-09-27 15:05:41.297 28879-28879/? A/DEBUG: #01 pc 0001a4c3 /system/lib/libc.so (abort+54) 2019-09-27 15:05:41.297 28879-28879/? A/DEBUG: #02 pc 000571f1 /data/app/com.<...>.debug-HdcYqzh22fveHQHBcYioVw==/lib/arm/libfilament-jni.so

soshial commented 5 years ago

The UnsatisfiedLinkError exception happens if I: 1) open initially AR fragment 2) replace it with another fragment 3) and then return back to AR fragment

supportFragmentManager.beginTransaction().replace(R.id.treasure_hunt_fragment, arFragment).commit()
// after button click
supportFragmentManager.beginTransaction().replace(R.id.treasure_hunt_fragment, supportMapFragment).commit()
// after another button click
supportFragmentManager.beginTransaction().replace(R.id.treasure_hunt_fragment, arFragment).commit()
chnouman commented 5 years ago

Also facing the same issue.

chnouman commented 5 years ago

@soshial buddy have you found any workaround for this?

FannyWF commented 5 years ago

@soshial i occured the same question, did u find any resolved methods?

adeelturk commented 5 years ago

what u have found so far is that error we are recieving is Error loading libarsceneview_jni.so but if we analyze apk the file " libarsceneview_jni " is not there because its renamed to libarsceneview-jni.so so i dont know how can we fix on our side but it seems like the cause of this error

adeelturk commented 5 years ago

@claywilkinson could you please look into it either i am wrong or right..

jwmcglynn commented 5 years ago

@tpsiaki Could you comment on libarsceneview_jni name change above?

@adeelturk libarsceneview may be optional, can you try adding a try/catch around the onResume call? BaseArFragment is open-source in the sceneformux package: https://github.com/google-ar/sceneform-android-sdk/blob/master/sceneformux/ux/src/main/java/com/google/ar/sceneform/ux/BaseArFragment.java

adeelturk commented 5 years ago

ok i will but when i downgraded my library veriosn to 1.11 same source code is working so i dont think its optional at least not in my case

adeelturk commented 5 years ago

i want to draw a 3d object on marker , all i found is that its working propely in 1.9 only but that version is missing with a method to setFocusMode and i want this method because if i try to read marker on a paper without focus it doesnt work so i am kinda stuck here

tpsiaki commented 5 years ago

@adeelturk the callstack listed above showing a problem loading libsceneview_jni is due to a problem we have in Sceneform with being overly chatty in our logs when we hit a certain failure case, but it's not fatal. If you're seeing a crash in your app, there should be a different fatal callstack that will show up in adb logcat.

For example, the above report from @soshial also listed this callstack, but the fatal callstack was related to having a mismatch in the version of the sceneform plugin library and the sceneform ux library (which results in a Filament material version mismatch, and in the case of the 1.11 to 1.12 versions, a fatal crash).

soshial commented 5 years ago

@tpsiaki I have version 1.12.0 set in both places:

ext.sceneform_version = "1.12.0"
implementation "com.google.ar.sceneform.ux:sceneform-ux:$sceneform_version"
classpath "com.google.ar.sceneform:plugin:$sceneform_version"

I have this log just before UnsatisfiedLinkError exception:

Screenshot 2019-10-14 at 17 54 22

Then goes UnsatisfiedLinkError exception:

Screenshot 2019-10-14 at 17 56 54

The device is Samsung Galaxy A3 (2017).

tpsiaki commented 5 years ago

@soshial if you search for "FATAL" in your log are there any errors/callstacks after the UnsatisfiedLinkError libarsceneview_jni log? I would expect the fatal issue to be after (perhaps long after in the logs) that UnsatisfiedLinkError.

soshial commented 5 years ago

No FATAL keyword on both Samsung Galaxy A3 and Google Pixel 3. The latter had this log: Screenshot 2019-10-14 at 18 27 38

Looks like on both devices Camera app messages about some problems.

Here are my libs: Screenshot 2019-10-14 at 18 33 56

chnouman commented 5 years ago

@soshial change 1.12.0 to 1.11.0. works for me. As you can see in 1.12.0 there is no significant fix or new feature provided.