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

Try..catch - exceptions are not catched when AOT is enabled #3480

Open
jpiechowiak opened this issue Aug 12, 2019 · 3 comments
Open

Try..catch - exceptions are not catched when AOT is enabled #3480

jpiechowiak opened this issue Aug 12, 2019 · 3 comments

Comments

@jpiechowiak
Copy link

jpiechowiak commented Aug 12, 2019

Steps to Reproduce

  1. Create sample project using following snippet of code
  2. Compile it using Visual Studio Build Tools with parameters:
    /p:AotAssemblies=true /p:EnableLLVM=true
  3. Test it on devices with Android 5 or 6 for instance on Samsung Galaxy S5, (SM-G900F), Android 6.0.1
public static bool HasNotchInScreen(Context context)
{
    bool retValue = false;

    try
    {
        ClassLoader cl = context.ClassLoader;
        Class hwNotchSizeUtil = cl.LoadClass("com.huawei.android.util.HwNotchSizeUtil");
        Method method = hwNotchSizeUtil.GetMethod("hasNotchInScreen");
        retValue = (bool)method.Invoke(hwNotchSizeUtil);
    }
    catch (Java.Lang.Exception)
    {
        System.Diagnostics.Debug.WriteLine("HasNotchInScreen Exception");
    }
    catch (System.Exception)
    {
        System.Diagnostics.Debug.WriteLine("HasNotchInScreen Exception");
    }

    return retValue;
}

Problem occurs not on every device, usually on older ones. Error occurred for example on following devices:
samsung SM-N7505
samsung SM-G900F
samsung SM-N910F
samsung SM-J510FQ
samsung SM-J120H
samsung SM-J320H
samsung SM-N900
samsung SM-N910C
condor PGN518
HUAWEI HUAWEI TIT-U02
samsung SM-J510H

all of them used architecture armv7l
We've had this part of code from one year. Problem occured after migration to Visual Studio 2019.

Expected Behavior

Exceptions should be handled

Actual Behavior

Catch block is ignored, application is crashing

Version Information

Visual Studio 16.2.0
Xamarin.Android.SDK 9.4.0.51

This is very important to us, because we've very large and complex application and without AOT is very slow.

@jpiechowiak
Copy link
Author

Additionaly on devices with Android 5 with turned on AOT compilation, we've also issues with Chromecast. Following exception is throwed:

E/mono    (13515): Unhandled Exception:
E/mono    (13515): Java.Lang.RuntimeException: com.google.android.gms.dynamite.DynamiteModule$zzc: Remote load failed. No local fallback found. ---> Java.Lang.Exception: Remote load failed. No local fallback found. ---> Java.Lang.Exception: Failed to get module context
E/mono    (13515):    --- End of inner exception stack trace ---
E/mono    (13515):    --- End of inner exception stack trace ---
E/mono    (13515):   at Java.Interop.JniEnvironment+StaticMethods.CallStaticObjectMethod (Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00069] in <18b287025c0644a4a51271e4c539f666>:0
E/mono    (13515):   at Android.Runtime.JNIEnv.CallStaticObjectMethod (System.IntPtr jclass, System.IntPtr jmethod, Android.Runtime.JValue* parms) <0xa0659760 + 0x00087> in <8b44fe2d76bb47ce80bbcbdfaf5460ea>:0
E/mono    (13515):   at Android.Gms.Cast.Framework.CastContext.GetSharedInstance (Android.Content.Context context) <0x9e1c7194 + 0x000bf> in <52e689e7b3894cf687d7517697e2ce87>:0
E/mono    (13515):   --- End of managed Java.Lang.RuntimeException stack trace ---
E/mono    (13515): java.lang.RuntimeException: com.google.android.gms.dynamite.DynamiteModule$zzc: Remote load failed. No local fallback found.
E/mono    (13515):      at com.google.android.gms.internal.zzavl.zzbp(Unknown Source)
E/mono    (13515):      at com.google.android.gms.internal.zzavl.zza(Unknown Source)
E/mono    (13515):      at com.google.android.gms.cast.framework.CastContext.<init>(Unknown Source)
E/mono    (13515):      at com.google.android.gms.cast.framework.CastContext.getSharedInstance(Unknown Source)
E/mono    (13515):      at com.tentime.app.MainActivity.n_onCreate(Native Method)
E/mono    (13515):      at com.tentime.app.MainActivity.onCreate(MainActivity.java:31)
E/mono    (13515):      at android.app.Activity.performCreate(Activity.java:5990)
E/mono    (13515):      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
E/mono    (13515):      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2332)
E/mono    (13515):      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2442)
E/mono    (13515):      at android.app.ActivityThread.access$800(ActivityThread.java:156)
E/mono    (13515):      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1351)
E/mono    (13515):      at android.os.Handler.dispatchMessage(Handler.java:102)
E/mono    (13515):      at android.os.Looper.loop(Looper.java:211)
E/mono    (13515):      at android.app.ActivityThread.main(ActivityThread.java:5371)
E/mono    (13515):      at java.lang.reflect.Method.invoke(Native Method)
E/mono    (13515):      at java.lang.reflect.Method.invoke(Method.java:372)
E/mono    (13515):      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:945)
E/mono    (13515):      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:740)
E/mono    (13515): Caused by: com.google.android.gms.dynamite.DynamiteModule$zzc: Remote load failed. No local fallback found.
E/mono    (13515):      at com.google.android.gms.dynamite.DynamiteModule.zza(Unknown Source)
E/mono    (13515):      ... 19 more
E/mono    (13515): Caused by: com.google.android.gms.dynamite.DynamiteModule$zzc: Failed to get module context
E/mono    (13515):      at com.google.android.gms.dynamite.DynamiteModule.zzc(Unknown Source)
E/mono    (13515):      at com.google.android.gms.dynamite.DynamiteModule.zza(Unknown Source)
E/mono    (13515):      ... 20 more

@jpiechowiak
Copy link
Author

@jonathanpeppers @joj @jonpryor
Any chance for fix or some news in this?
We tried Startup Tracing instead, but it is significantly slower than normal AOT in our case.

@tranb3r
Copy link

tranb3r commented Sep 10, 2019

Any progress on this issue ?

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

2 participants