fuselibs
fuselibs copied to clipboard
InterApp.launchUri() fatal crash on Android
Fuse 1.4.0 build 14778, macOS. Testing on a Nexus 5 with Android 6, likely other versions affected too.
When there is no handler for a particular URI-scheme available on an Android device, the call to InterApp.launchUri() results in a fatal crash.
A repro (don't forget "Fuse.Launcher" in .unoproj):
<App>
<JavaScript>
var InterApp = require("FuseJS/InterApp");
var url = encodeURI('whatsapp://send?text=crash');
InterApp.launchUri(url);
</JavaScript>
</App>
We get this in logs when fuse preview -tandroid:
$ fuse preview -tandroid
Fuse 1.4.0 (build 14778)
Configuring (1.4 s)
Compiling syntax tree (1.1 s)
Generating code and dataFontconfig warning: no <cachedir> elements found. Check configuration.
Fontconfig warning: adding <cachedir>~/Library/Caches/com.xamarin.fontconfig</cachedir>
Fontconfig warning: adding <cachedir prefix="xdg">fontconfig</cachedir>
(4.9 s)
Building Android app
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
(1:2)
Build completed in 69.64 seconds
Installing APK on 1 device(s)
Launching activity 'TestApp'
Running logcat on 030601a3210ad107
11-28 15:52:30.825 8222 8222 I art : Late-enabling -Xcheck:jni
11-28 15:52:30.825 779 2074 I ActivityManager: Start proc 8222:com.test.app/u0a832 for activity com.test.app/.TestApp
11-28 15:52:30.865 8222 8222 D TestApp : SDK: 23
11-28 15:52:30.929 8222 8222 I Adreno-EGL: <qeglDrvAPI_eglInitialize:379>: QUALCOMM Build: 10/21/15, 369a2ea, I96aee987eb
11-28 15:52:31.284 8222 8265 D OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
11-28 15:52:31.336 8222 8265 I OpenGLRenderer: Initialized EGL, version 1.4
11-28 15:52:37.598 8222 8318 W System.err: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=whatsapp://send?text=crash }
11-28 15:52:37.599 8222 8318 W System.err: at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1798)
11-28 15:52:37.600 8222 8318 W System.err: at android.app.Instrumentation.execStartActivity(Instrumentation.java:1512)
11-28 15:52:37.600 8222 8318 W System.err: at android.app.Activity.startActivityForResult(Activity.java:3930)
11-28 15:52:37.600 8222 8318 W System.err: at android.app.Activity.startActivityForResult(Activity.java:3890)
11-28 15:52:37.600 8222 8318 W System.err: at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:842)
11-28 15:52:37.600 8222 8318 W System.err: at android.app.Activity.startActivity(Activity.java:4213)
11-28 15:52:37.600 8222 8318 W System.err: at android.app.Activity.startActivity(Activity.java:4181)
11-28 15:52:37.600 8222 8318 W System.err: at com.foreign.Fuse.Android.Bindings.AndroidDeviceInterop.LaunchIntent326(AndroidDeviceInterop.java:42)
11-28 15:52:37.600 8222 8318 W System.err: at com.Bindings.ExternedBlockHost.LaunchIntent326(ExternedBlockHost.java:1518)
11-28 15:52:37.600 8222 8318 F libc : Fatal signal 11 (SIGSEGV), code 1, fault addr 0x7 in tid 8318 (Thread-584)
11-28 15:52:37.704 196 196 F DEBUG : pid: 8222, tid: 8318, name: Thread-584 >>> com.test.app <<<
11-28 15:52:38.320 210 210 I Zygote : Process 8222 exited due to signal (11)
11-28 15:52:38.329 779 1655 I ActivityManager: Process com.test.app (pid 8222) has died
11-28 15:52:38.329 779 1655 D ActivityManager: cleanUpApplicationRecord -- 8222
11-28 15:52:38.389 779 1832 W InputMethodManagerService: Got RemoteException sending setActive(false) notification to pid 8222 uid 10832
Process com.test.app terminated.
When debugging in Android Studio after fuse build -tandroid -d:

A wild guess, and probably not the right solution, but perhaps some safeguarding around this line could avoid the crash: https://github.com/fusetools/fuselibs-public/blob/master/Source/Fuse.Android/AndroidInterop.uno#L28
The forum thread InterApp cause a crash if target app is not installed posted by [email protected] was linked to this issue.
This seems to go from a simple error to a fatal crash due to our bad V8 build :/
I suspect that something like this makes the bad owie go away:
diff --git a/Source/Fuse.Android/AndroidInterop.uno b/Source/Fuse.Android/AndroidInterop.uno
index 94b4713101..76f4f771bf 100644
--- a/Source/Fuse.Android/AndroidInterop.uno
+++ b/Source/Fuse.Android/AndroidInterop.uno
@@ -25,7 +25,16 @@ namespace Fuse.Android.Bindings
pendingIntent.setClassName(packageName, className);
Activity a = com.fuse.Activity.getRootActivity();
- a.startActivity(pendingIntent);
+ try
+ {
+ a.startActivity(pendingIntent);
+ }
+ catch (ActivityNotFoundException e)
+ {
+ e.printStackTrace();
+ return null;
+ }
+
return pendingIntent;
@}
@cbaggers: You're our resident ☕️ expert, what do you think about a change like that? I see little reason to propagate the exception out to the user...