Bug 30843 - Crash when implementing LayoutInflater.Inflate and simply calling it's base
Summary: Crash when implementing LayoutInflater.Inflate and simply calling it's base
Status: RESOLVED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler ()
Version: 5.1
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2015-06-05 10:29 UTC by Jeremy Kolb
Modified: 2015-07-10 08:32 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Visual Studio Solution (16.99 KB, application/zip)
2015-06-05 10:29 UTC, Jeremy Kolb
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Jeremy Kolb 2015-06-05 10:29:20 UTC
Created attachment 11479 [details]
Visual Studio Solution

I'm implementing my own LayoutInflater (I've attached a project to demonstrate this):

public class MyLayoutInflater : LayoutInflater
    {
        private static readonly string[] ClassPrefixList =
        {
            "android.widget.",
            "android.webkit.",
            "android.app."
        };

        public MyLayoutInflater(Context context)
            : base(context)
        {}

        public MyLayoutInflater(LayoutInflater original, Context newContext)
            : base(original, newContext)
        {}

        public override LayoutInflater CloneInContext(Context newContext)
        {
            return new MyLayoutInflater(this, newContext);
        }

        // Uncomment this to produce crash.
        //public override View Inflate(XmlReader parser, ViewGroup root, bool attachToRoot)
        //{
        //    return base.Inflate(parser, root, attachToRoot);
        //}

        protected override View OnCreateView(View parent, string name, IAttributeSet attrs)
        {
            foreach (var prefix in ClassPrefixList)
            {
                try
                {
                    var view = CreateView(name, prefix, attrs);
                    if (view != null)
                        return view;
                }
                catch(ClassNotFoundException)
                { }
            }

            return base.OnCreateView(parent, name, attrs);
        }
    }

Everything works great until I override Inflate and call into it's base implementation.  Once that happens my app crashes:


06-05 10:24:19.968 W/dalvikvm( 2918): JNI WARNING: DeleteLocalRef on non-local 0x1d200482 (type=2)
06-05 10:24:19.972 I/dalvikvm( 2918): "main" prio=5 tid=1 NATIVE
In mgmain JNI_OnLoad
06-05 10:24:19.972 I/dalvikvm( 2918):   | group="main" sCount=0 dsCount=0 obj=0xa4ca5bd8 self=0xb83fdeb0
06-05 10:24:19.972 I/dalvikvm( 2918):   | sysTid=2918 nice=0 sched=0/0 cgrp=apps handle=-1217298368
06-05 10:24:19.972 I/dalvikvm( 2918):   | state=R schedstat=( 256053240 1482606 155 ) utm=13 stm=12 core=3
06-05 10:24:19.972 I/dalvikvm( 2918):   #00  pc 000bd936  /system/lib/libdvm.so (dvmDumpNativeStack(DebugOutputTarget const*, int)+86)
06-05 10:24:19.972 I/dalvikvm( 2918):   #01  pc 00098513  /system/lib/libdvm.so (dvmDumpThreadEx(DebugOutputTarget const*, Thread*, bool)+1155)
06-05 10:24:19.972 I/dalvikvm( 2918):   #02  pc 00098806  /system/lib/libdvm.so (dvmDumpThread(Thread*, bool)+86)
06-05 10:24:19.972 I/dalvikvm( 2918):   #03  pc 0005f8bd  /system/lib/libdvm.so
06-05 10:24:19.972 I/dalvikvm( 2918):   #04  pc 000061b3  <unknown>
06-05 10:24:19.972 I/dalvikvm( 2918):   at md528da24db48cbf7863cb6149e3b7b7995.MyLayoutInflater.n_inflate(Native Method)
06-05 10:24:19.972 I/dalvikvm( 2918):   at java.lang.reflect.Method.inv06-05 10:24:19.972 I/dalvikvm( 2918):   at md528da24db48cbf7863cb6149e3b7b7995.MyLayoutInflater.inflate(MyLayoutInflater.java:46)
06-05 10:24:19.972 I/dalvikvm( 2918):   at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
06-05 10:24:19.972 I/dalvikvm( 2918):   at com.android.internal.widget.ActionBarView.<init>(ActionBarView.java:196)
06-05 10:24:19.972 I/dalvikvm( 2918):   at java.lang.reflect.Constructor.constructNative(Native Method)
06-05 10:24:19.972 I/dalvikvm( 2918):   at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
06-05 10:24:19.972 I/dalvikvm( 2918):   at android.view.LayoutInflater.createView(LayoutInflater.java:594)
06-05 10:24:19.972 I/dalvikvm( 2918):   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
06-05 10:24:19.972 I/dalvikvm( 2918):   at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
06-05 10:24:19.972 I/dalvikvm( 2918):   at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
06-05 10:24:19.972 I/dalvikvm( 2918):   at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
06-05 10:24:19.972 I/dalvikvm( 2918):   at md528da24db48cbf7863cb6149e3b7b7995.MyLayoutInflater.n_inflate(Native Method)
06-05 10:24:19.972 I/dalvikvm( 2918):   at md528da24db48cbf7863cb6149e3b7b7995.MyLayoutInflater.inflate(MyLayoutInflater.java:46)
06-05 10:24:19.972 I/dalvikvm( 2918):   at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
06-05 10:24:19.972 I/dalvikvm( 2918):   at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
06-05 10:24:19.972 I/dalvikvm( 2918):   at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:3022)
06-05 10:24:19.972 I/dalvikvm( 2918):   at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3085)
06-05 10:24:19.972 I/dalvikvm( 2918):   at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:286)
06-05 10:24:19.972 I/dalvikvm( 2918):   at android.app.Activity.setContentView(Activity.java:1929)
06-05 10:24:19.972 I/dalvikvm( 2918):   at md528da24db48cbf7863cb6149e3b7b7995.MainActivity.n_onCreate(Native Method)
06-05 10:24:19.972 I/dalvikvm( 2918):   at md528da24db48cbf7863cb6149e3b7b7995.MainActivity.onCreate(MainActivity.java:29)
06-05 10:24:19.972 I/dalvikvm( 2918):   at android.app.Activity.performCreate(Activity.java:5231)
06-05 10:24:19.972 I/dalvikvm( 2918):   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
06-05 10:24:19.972 I/dalvikvm( 2918):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
06-05 10:24:19.972 I/dalvikvm( 2918):   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
06-05 10:24:19.972 I/dalvikvm( 2918):   at android.app.ActivityThread.access$800(ActivityThread.java:135)
06-05 10:24:19.972 I/dalvikvm( 2918):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
06-05 10:24:19.972 I/dalvikvm( 2918):   at android.os.Handler.dispatchMessage(Handler.java:102)
06-05 10:24:19.972 I/dalvikvm( 2918):   at android.os.Looper.loop(Looper.java:136)
06-05 10:24:19.972 I/dalvikvm( 2918):   at android.app.ActivityThread.main(ActivityThread.java:5001)
06-05 10:24:19.972 I/dalvikvm( 2918):   at java.lang.reflect.Method.invokeNative(Native Method)
06-05 10:24:19.972 I/dalvikvm( 2918):   at java.lang.reflect.Method.invoke(Method.java:515)
06-05 10:24:19.972 I/dalvikvm( 2918):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
06-05 10:24:19.972 I/dalvikvm( 2918):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
06-05 10:24:19.972 I/dalvikvm( 2918):   at dalvik.system.NativeStart.main(Native Method)
06-05 10:24:19.972 I/dalvikvm( 2918): 
06-05 10:24:19.972 E/dalvikvm( 2918): VM aborting
06-05 10:24:19.972 F/libc    ( 2918): Fatal signal 6 (SIGABRT) at 0x00000b66 (code=-6), thread 2918 (mLayoutInflater)
Comment 1 Jonathan Pryor 2015-06-05 15:04:51 UTC

*** This bug has been marked as a duplicate of bug 28114 ***
Comment 2 Jeremy Kolb 2015-06-05 16:08:57 UTC
It says this was fixed in April but it's not in the latest stable?
Comment 3 Jonathan Pryor 2015-06-05 16:56:02 UTC
Correct. Sometimes I forget to raise a bug for backporting... :-(

This should be included in a release after Xamarin.Android 5.1.4.
Comment 4 Jeremy Kolb 2015-06-06 10:00:19 UTC
Sad!  Is there a workaround?
Comment 5 Jeremy Kolb 2015-07-09 23:29:22 UTC
Is this in 5.1.4.16?
Comment 6 Jonathan Pryor 2015-07-10 08:32:44 UTC
@jkolb: It will be in 5.1.5.