Strange error while saving an instance of a box in a wrapper Java object

I store an instance of the current custom cell renderer as a property of an object that inherits from Java.Lang.Object:

EnclosedCellRenderer _thisWrapped;

public CellThreadNativeRenderer() { // constructor of the cell custom renderer
    _thisWrapped = new EnclosedCellRenderer { Renderer = this };
}

class EnclosedCellRenderer : Java.Lang.Object {
    public CellThreadNativeRenderer Renderer {get; set;}
}

      

The reason I am doing this is because I want to store the renderer instance in its own control as a tag. However, the cell renderer does not inherit Java.Lang.Object, so I need to wrap it in another one that does.

However, I get this strange error when I scroll through the list very quickly. You can see this happening in the EnclosedCellRenderer constructor:

[art] JNI RegisterNativeMethods: attempt to register 0 native methods for md5530bd51e982e6e7b340b73e88efe666e.LabelRenderer
[mono-rt] Stacktrace:
[mono-rt] 
[mono-rt]   at <unknown> <0xffffffff>
[mono-rt]   at (wrapper managed-to-native) string.InternalAllocateStr (int) <IL 0x00029, 0xffffffff>
[mono-rt]   at string.CreateString (char[],int,int) <IL 0x00067, 0x001df>
[mono-rt]   at (wrapper managed-to-managed) string..ctor (char[],int,int) <IL 0x0000a, 0xffffffff>
[mono-rt]   at System.NumberFormatter.FormatHexadecimal (int) <IL 0x0007e, 0x001df>
[mono-rt]   at System.NumberFormatter.IntegerToString (string,System.IFormatProvider) <IL 0x000db, 0x002b7>
[mono-rt]   at System.NumberFormatter.NumberToString (string,int,System.IFormatProvider) <IL 0x00014, 0x0008f>
[mono-rt]   at System.Number.FormatInt32 (int,string,System.Globalization.NumberFormatInfo) <IL 0x00003, 0x00033>
[mono-rt]   at byte.ToString (string,System.IFormatProvider) <IL 0x00009, 0x00053>
[mono-rt]   at string.FormatHelper (System.Text.StringBuilder,System.IFormatProvider,string,object[]) <IL 0x00169, 0x00811>
[mono-rt]   at System.Text.StringBuilder.AppendFormat (System.IFormatProvider,string,object[]) <IL 0x00004, 0x0003f>
[mono-rt]   at System.Text.StringBuilder.AppendFormat (string,object) <IL 0x0000d, 0x00083>
[mono-rt]   at MonoDroid.Utils.JniType.ToMd5 (string) [0x00037] in /Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d419c934/source/monodroid/src/utils/JniType.cs:533
[mono-rt]   at MonoDroid.Utils.JniType.GetPackageName (System.Type) [0x00000] in /Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d419c934/source/monodroid/src/utils/JniType.cs:167
[mono-rt]   at MonoDroid.Utils.JniType.ToJniName<T> (T,System.Func`2<T, T>,System.Func`2<T, string>,System.Func`2<T, string>) [0x00064] in /Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d419c934/source/monodroid/src/utils/JniType.cs:520
[mono-rt]   at MonoDroid.Utils.JniType.ToJniName (System.Type,Java.Interop.ExportParameterKind) [0x0007e] in /Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d419c934/source/monodroid/src/utils/JniType.cs:148
[mono-rt]   at MonoDroid.Utils.JniType.ToJniName (System.Type) [0x00000] in /Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d419c934/source/monodroid/src/utils/JniType.cs:129
[mono-rt]   at Android.Runtime.JNIEnv.FindClass (System.Type) [0x00009] in /Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d419c934/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.cs:434
[mono-rt]   at Android.Runtime.JNIEnv.AllocObject (System.Type) [0x00000] in /Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d419c934/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.cs:279
[mono-rt]   at Android.Runtime.JNIEnv.StartCreateInstance (System.Type,string,Android.Runtime.JValue*) [0x0000a] in /Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d419c934/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.cs:318
[mono-rt]   at Android.Runtime.JNIEnv.StartCreateInstance (System.Type,string,Android.Runtime.JValue[]) [0x0001d] in /Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d419c934/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.cs:326
[mono-rt]   at Java.Lang.Object..ctor () [0x0001c] in /Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d419c934/source/monodroid/src/Mono.Android/src/Java.Lang/Object.cs:72
[mono-rt]   at Voatus.Droid.EnclosedCellRenderer..ctor () <IL 0x00001, 0x00017>
[mono-rt]   at Voatus.Droid.CellThreadNativeRenderer..ctor () [0x00008] in d:\Code\VoatusXamarinForms\Droid\Renderers\CellThreadNativeRenderer.cs:37
[mono-rt]   at (wrapper runtime-invoke) object.runtime_invoke_void__this__ (object,intptr,intptr,intptr) <IL 0x0005e, 0xffffffff>
[mono-rt]   at <unknown> <0xffffffff>
[mono-rt]   at (wrapper managed-to-native) System.Reflection.MonoCMethod.InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&) <IL 0x00038, 0xffffffff>
[mono-rt]   at System.Reflection.MonoCMethod.InternalInvoke (object,object[]) <IL 0x00007, 0x0005f>
[mono-rt]   at System.Activator.CreateInstance (System.Type,bool) <IL 0x000b2, 0x00313>
[mono-rt]   at System.Activator.CreateInstance (System.Type) <IL 0x00002, 0x0002b>
[mono-rt]   at Xamarin.Forms.Registrar`1.GetHandler (System.Type) <IL 0x00016, 0x0008b>
[mono-rt]   at Xamarin.Forms.Registrar`1.GetHandler<TOut> (System.Type) <IL 0x00002, 0x0002f>
[mono-rt]   at Xamarin.Forms.Platform.Android.CellFactory.GetCell (Xamarin.Forms.Cell,Android.Views.View,Android.Views.ViewGroup,Android.Content.Context,Xamarin.Forms.View) <IL 0x00015, 0x0007f>
[mono-rt]   at Xamarin.Forms.Platform.Android.ListViewAdapter.GetView (int,Android.Views.View,Android.Views.ViewGroup) <IL 0x0009f, 0x0047b>
[mono-rt]   at Android.Widget.BaseAdapter.n_GetView_ILandroid_view_View_Landroid_view_ViewGroup_ (intptr,intptr,int,intptr,intptr) [0x0001a] in /Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d419c934/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Android.Widget.BaseAdapter.cs:509
[mono-rt]   at (wrapper dynamic-method) object.7c50ef9d-fe73-4781-bc29-06789b46b8aa (intptr,intptr,int,intptr,intptr) <IL 0x00023, 0x00047>
[mono-rt]   at (wrapper native-to-managed) object.7c50ef9d-fe73-4781-bc29-06789b46b8aa (intptr,intptr,int,intptr,intptr) <IL 0x00030, 0xffffffff>
[mono-rt] 
[mono-rt] Attempting native Android stacktrace:
[mono-rt] 
[mono-rt]  at ???+2738985527 [0xa341ab32]
[mono-rt]  at ???+2738985527 [0xa33c9c4f]
[mono-rt]  at ???+2738985527 [0xa33d4efb]
[mono-rt]  at ???+2738985527 [0xa33d6840]
[mono-rt]  at ???+2738985527 [0xa33d466f]
[mono-rt]  at ???+2738985527 [0xa33ed014]
[mono-rt]  at ???+2738985527 [0xa33c850b]
[mono-rt]  at ???+2738985527 [0xa33c89a7]
[mono-rt]  at ???+2738985527 [0xa33e1bd7]
[mono-rt]  at ???+2738985527 [0xa33e1fca]
[mono-rt]  at ???+2738985527 [0xa339babf]
[mono-rt]  at ???+2738985527 [0xa337d4c4]
[mono-rt]  at ???+2738985527 [0x9ed6f7fb]
[mono-rt]  at ???+2738985527 [0x9ed3fb4f]
[mono-rt]  at ???+2738985527 [0x9ed3f95b]
[mono-rt]  at ???+2738985527 [0x9ed3f837]
[mono-rt]  at ???+2738985527 [0x9ed3f37f]
[mono-rt]  at ???+2738985527 [0x9ed5e387]
[mono-rt]  at ???+2738985527 [0x9ed5e2cb]
[mono-rt]  at ???+2738985527 [0x9ed5cb4b]
[mono-rt]  at ???+2738985527 [0x9ed5bbc9]
[mono-rt]  at ???+2738985527 [0x9ed5b37f]
[mono-rt]  at ???+2738985527 [0x9ed5b30b]
[mono-rt]  at ???+2738985527 [0x9ed674eb]
[mono-rt]  at ???+2738985527 [0x9ed66b1b]
[mono-rt]  at ???+2738985527 [0x9ed65417]
[mono-rt]  at ???+2738985527 [0x9ed61597]
[mono-rt]  at ???+2738985527 [0x9ed611af]
[mono-rt]  at ???+2738985527 [0x9ed60d8b]
[mono-rt]  at ???+2738985527 [0x9ed60c87]
[mono-rt]  at ???+2738985527 [0x9ed60bff]
[mono-rt]  at ???+2738985527 [0x9ed60b93]
[mono-rt]  at ???+2738985527 [0x9ed60a7f]
[mono-rt]  at ???+2738985527 [0x9c4ba3ef]
[mono-rt]  at ???+2738985527 [0x9c4ba2bb]
[mono-rt]  at ???+2738985527 [0x9ed56f9c]
[mono-rt]  at ???+2738985527 [0xa3213764]
[mono-rt]  at ???+2738985527 [0xa339980b]
[mono-rt]  at ???+2738985527 [0xa33a0542]
[mono-rt]  at ???+2738985527 [0xa332f646]
[mono-rt]  at ???+2738985527 [0x9ed7c333]
[mono-rt]  at ???+2738985527 [0x9ed7c187]
[mono-rt]  at ???+2738985527 [0x9ec1973b]
[mono-rt]  at ???+2738985527 [0x9ec193fb]
[mono-rt]  at ???+2738985527 [0x9dc91193]
[mono-rt]  at ???+2738985527 [0x9dc910af]
[mono-rt]  at ???+2738985527 [0x9c4b9e87]
[mono-rt]  at ???+2738985527 [0x9c4b7103]
[mono-rt]  at ???+2738985527 [0x9c4b6c41]
[mono-rt]  at ???+2738985527 [0x9ed1e25f]
[mono-rt]  at ???+2738985527 [0x9dc87497]
[mono-rt]  at ???+2738985527 [0xa38a9137]
[mono-rt]  at ???+2738985527 [0x98b76f0b]
[mono-rt] 
[mono-rt] =================================================================
[mono-rt] Got a SIGSEGV while executing native code. This usually indicates
[mono-rt] a fatal error in the mono runtime or one of the native libraries 
[mono-rt] used by your application.
[mono-rt] =================================================================
[mono-rt] 
[libc] Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 2714

      

Why will this error happen and is there any other way to achieve what I want?

What I want exactly is, for example, set a click handler on the inline button that is in the cell, and in the handler, get the renderer that is holding the button currently, so I can get the Xamarin Forms cell object and call the method on it ... Currently, if I use this buggy method, I can do the following in GetCellCore:

            _ibShare.Click += async (sender, e) => {
                var ib = sender as Android.Widget.ImageButton;
                var renderer = ib.Tag as EnclosedCellRenderer;
                var cell = EnclosedCellRenderer.Renderer.Cell as CellThreadNative;
                await cell.ShareClicked();
            };

      

+3


source to share





All Articles