Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

No constructor found for Xamarin.Forms.Platform.Android.LabelRenderer #2584

Closed
yorkvolvo opened this issue May 2, 2018 · 25 comments
Closed
Labels
p/Android s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/needs-repro ❔ This reported issue doesn't include a sample project reproducing the issue. Please provide one.

Comments

@yorkvolvo
Copy link

yorkvolvo commented May 2, 2018

Description

Our customer are developing a Xamarin Forms application which is running on an android scanner device. Inconsistently, customer get the issue of "no constructor found.." for random controls.

Steps to Reproduce

Unknown, but if customer spend 2-3 hours and do lot of testing then they could get this issue.

Expected Behavior

Not crashing

Actual Behavior

Crashing

Origianl Crash Log

The log for one such crash is below:

04-27 13:42:55.652 I/mono-stdout( 9159): Error: Unhandled Exception
	System.Exception: CurrentDomainOnUnhandledException ---> System.NotSupportedException: Unable to activate instance of type Xamarin.Forms.Platform.Android.LabelRenderer from native handle 0xbeab25ec (key_handle 0x10571cc2). ---> System.MissingMethodException: No constructor found for Xamarin.Forms.Platform.Android.LabelRenderer::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership) ---> Java.Interop.JavaLocationException: Exception of type 'Java.Interop.JavaLocationException' was thrown.
04-27 13:42:55.654 I/mono-stdout( 9159): System.Exception: CurrentDomainOnUnhandledException ---> System.NotSupportedException: Unable to activate instance of type Xamarin.Forms.Platform.Android.LabelRenderer from native handle 0xbeab25ec (key_handle 0x10571cc2). ---> System.MissingMethodException: No constructor found for Xamarin.Forms.Platform.Android.LabelRenderer::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership) ---> Java.Interop.JavaLocationException: Exception of type 'Java.Interop.JavaLocationException' was thrown.
04-27 13:42:55.656 I/mono-stdout( 9159):    --- End of inner exception stack trace ---
   --- End of inner exception stack trace ---
  at Java.Interop.TypeManager.CreateProxy (System.Type type, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00054] in <e79c73bcbbb547688bef6c7e9665c95e>:0 
04-27 13:42:55.657 I/mono-stdout( 9159):   at Java.Interop.TypeManager.CreateProxy (System.Type type, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00054] in <e79c73bcbbb547688bef6c7e9665c95e>:0 
04-27 13:42:55.659 I/mono-stdout( 9159):   at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x00111] in <e79c73bcbbb547688bef6c7e9665c95e>:0 
  at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x00111] in <e79c73bcbbb547688bef6c7e9665c95e>:0 
04-27 13:42:55.660 I/mono-stdout( 9159):    --- End of inner exception stack trace ---
   --- End of inner exception stack trace ---
04-27 13:42:55.662 I/mono-stdout( 9159):   at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x0017d] in <e79c73bcbbb547688bef6c7e9665c95e>:0 
  at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x0017d] in <e79c73bcbbb547688bef6c7e9665c95e>:0 
04-27 13:42:55.664 I/mono-stdout( 9159):   at Java.Lang.Object.GetObject (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type type) [0x000b9] in <e79c73bcbbb547688bef6c7e9665c95e>:0 
04-27 13:42:55.665 I/mono-stdout( 9159):   at Java.Lang.Object._GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00017] in <e79c73bcbbb547688bef6c7e9665c95e>:0 
04-27 13:42:55.666 I/mono-stdout( 9159):   at Java.Lang.Object.GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00000] in <e79c73bcbbb547688bef6c7e9665c95e>:0 
04-27 13:42:55.666 I/mono-stdout( 9159):   at Java.Lang.Object.GetObject[T] (System.IntPtr jnienv, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00006] in <e79c73bcbbb547688bef6c7e9665c95e>:0 
04-27 13:42:55.667 I/mono-stdout( 9159):   at Android.Views.View.n_DispatchTouchEvent_Landroid_view_MotionEvent_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_e) [0x00000] in <e79c73bcbbb547688bef6c7e9665c95e>:0 
04-27 13:42:55.667 I/mono-stdout( 9159):   at (wrapper dynamic-method) System.Object:bbf912d2-01a2-4ae6-92cf-485eec6621f6 (intptr,intptr,intptr)
04-27 13:42:55.667 I/mono-stdout( 9159):    --- End of inner exception stack trace ---end----------------end
  at Java.Lang.Object.GetObject (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type type) [0x000b9] in <e79c73bcbbb547688bef6c7e9665c95e>:0 
  at Java.Lang.Object._GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00017] in <e79c73bcbbb547688bef6c7e9665c95e>:0 
  at Java.Lang.Object.GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00000] in <e79c73bcbbb547688bef6c7e9665c95e>:0 
  at Java.Lang.Object.GetObject[T] (System.IntPtr jnienv, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00006] in <e79c73bcbbb547688bef6c7e9665c95e>:0 
  at Android.Views.View.n_DispatchTouchEvent_Landroid_view_MotionEvent_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_e) [0x00000] in <e79c73bcbbb547688bef6c7e9665c95e>:0 
  at (wrapper dynamic-method) System.Object:bbf912d2-01a2-4ae6-92cf-485eec6621f6 (intptr,intptr,intptr)

Something customer have tried to resolve this issue but it raised another issue

Customer read a lot of artical or documentaion about this:

  1. MonoDroid: Error when calling constructor of custom view - TwoDScrollView
  2. MissingMethodException: No constructor found for Xamarin.Forms.Maps.Android.MapRenderer
  3. Random System.NotSupportedException on Android: Unable to activate instance of type Xamarin.Forms.Platform.Android.[VARIOUS_TYPES]

So customer tried using the work around solution of custom rendering the label class and adding the constructor as mentioned in the stack overflow url that i shared.

public class MyLabelRenderer : LabelRenderer
    {
        public MyLabelRenderer(Context context) : base(context)
        {
        }

        public MyLabelRenderer(IntPtr handle, JniHandleOwnership transfer)
        {
        }

    }

After about 2 hours of testing, customer don't see the label renderer issue. But they got the a new crash issue:

System.Exception: CurrentDomainOnUnhandledException ---> System.NotSupportedException: Unable to activate instance of type Xamarin.Forms.Platform.Android.Platform+DefaultRenderer from native handle 0xbeb7167c (key_handle 0x1d94631). ---> System.MissingMethodException: No constructor found for Xamarin.Forms.Platform.Android.Platform+DefaultRenderer::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership) ---> Java.Interop.JavaLocationException: Exception of type 'Java.Interop.JavaLocationException' was thrown.
04-27 06:59:35.574 I/mono-stdout( 9467): System.Exception: CurrentDomainOnUnhandledException ---> System.NotSupportedException: Unable to activate instance of type Xamarin.Forms.Platform.Android.Platform+DefaultRenderer from native handle 0xbeb7167c (key_handle 0x1d94631). ---> System.MissingMethodException: No constructor found for Xamarin.Forms.Platform.Android.Platform+DefaultRenderer::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership) ---> Java.Interop.JavaLocationException: Exception of type 'Java.Interop.JavaLocationException' was thrown.
   --- End of inner exception stack trace ---
04-27 06:59:35.581 I/mono-stdout( 9467):    --- End of inner exception stack trace ---
  at Java.Interop.TypeManager.CreateProxy (System.Type type, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00054] in <e79c73bcbbb547688bef6c7e9665c95e>:0 
04-27 06:59:35.588 I/mono-stdout( 9467):   at Java.Interop.TypeManager.CreateProxy (System.Type type, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00054] in <e79c73bcbbb547688bef6c7e9665c95e>:0 
04-27 06:59:35.589 I/mono-stdout( 9467):   at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x00111] in <e79c73bcbbb547688bef6c7e9665c95e>:0 
  at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x00111] in <e79c73bcbbb547688bef6c7e9665c95e>:0 
   --- End of inner exception stack trace ---
04-27 06:59:35.596 I/mono-stdout( 9467):    --- End of inner exception stack trace ---
  at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x0017d] in <e79c73bcbbb547688bef6c7e9665c95e>:0 
  at Java.Lang.Object.GetObject (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type type) [0x000b9] in <e79c73bcbbb547688bef6c7e9665c95e>:0 
04-27 06:59:35.602 I/mono-stdout( 9467):   at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x0017d] in <e79c73bcbbb547688bef6c7e9665c95e>:0 
04-27 06:59:35.605 I/mono-stdout( 9467):   at Java.Lang.Object.GetObject (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type type) [0x000b9] in <e79c73bcbbb547688bef6c7e9665c95e>:0 
  at Java.Lang.Object._GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00017] in <e79c73bcbbb547688bef6c7e9665c95e>:0 
  at Java.Lang.Object.GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00000] in <e79c73bcbbb547688bef6c7e9665c95e>:0 
04-27 06:59:35.607 I/mono-stdout( 9467):   at Java.Lang.Object._GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00017] in <e79c73bcbbb547688bef6c7e9665c95e>:0 
  at Java.Lang.Object.GetObject[T] (System.IntPtr jnienv, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00006] in <e79c73bcbbb547688bef6c7e9665c95e>:0 
  at Android.Views.View.n_DispatchTouchEvent_Landroid_view_MotionEvent_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_e) [0x00000] in <e79c73bcbbb547688bef6c7e9665c95e>:0 
04-27 06:59:35.613 I/mono-stdout( 9467):   at Java.Lang.Object.GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00000] in <e79c73bcbbb547688bef6c7e9665c95e>:0 
04-27 06:59:35.619 I/mono-stdout( 9467):   at Java.Lang.Object.GetObject[T] (System.IntPtr jnienv, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00006] in <e79c73bcbbb547688bef6c7e9665c95e>:0 
04-27 06:59:35.621 I/mono-stdout( 9467):   at Android.Views.View.n_DispatchTouchEvent_Landroid_view_MotionEvent_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_e) [0x00000] in <e79c73bcbbb547688bef6c7e9665c95e>:0 
04-27 06:59:35.625 I/mono-stdout( 9467):   at (wrapper dynamic-method) System.Object:2a2a9180-ab25-4e91-a4dc-87cf0582de37 (intptr,intptr,intptr)
  at (wrapper dynamic-method) System.Object:2a2a9180-ab25-4e91-a4dc-87cf0582de37 (intptr,intptr,intptr)


Basic Information

  • Version with issue:

  • Last known good version:

  • IDE: Visual Studio 2017 15.6.6

  • Platform Target Frameworks:

    • Android: Android 7.1 Nougat
  • Android Support Library Version: 25.4.0.2

  • Nuget Packages: Arc.UserDialogs 7.0.1 Xamarin.Forms 2.5.0.122203 Symbol.XamarinEMDK 2.7.0.76-rc
    third part SDK: EMDK, and VS has to configured with EMDK

  • Affected Devices: Scanner device: TC8000 of Zebra

Screenshots

Reproduction Link

@hartez hartez added the s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. label May 2, 2018
@hartez
Copy link
Contributor

hartez commented May 2, 2018

@aixiaozi Which version of Xamarin.Forms does your application use?

@yorkvolvo
Copy link
Author

@hartez , Xamarin Forms version: 2.5.0.122203

@hartez
Copy link
Contributor

hartez commented May 3, 2018

@aixiaozi Is the application using ListViews?

@yorkvolvo
Copy link
Author

@hartez yeah, can you give us a direction about how to resolve this crash issue?

@hartez
Copy link
Contributor

hartez commented May 4, 2018

@aixiaozi Without being able to see your code or a reproduction of the issue, there is not much guidance I can give you. I can tell you that we've fixed several ListView bugs since 2.5.0, so updating your application to a more recent version of Forms may help.

@hartez hartez added s/needs-repro ❔ This reported issue doesn't include a sample project reproducing the issue. Please provide one. and removed s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. labels May 4, 2018
@yorkvolvo
Copy link
Author

@radical , hi, our customer said that they could resolve this issue by adding a constructor in LabelRenderer and avoiding animation while navigating. For now, our customer wants to know the root cause of the issue, can you help our customer on that? I could send you customer's sample project but we need to protect customer's privacy, please tell me how can I share this project with you.

@radical
Copy link

radical commented May 21, 2018

@aixiaozi you probably meant to reply to @hartez!

@PureWeen
Copy link
Contributor

@aixiaozi The cases I've seen this come up is when a handler hasn't been detached from a disposed renderer so then mono tries to manually "re-activate" the renderer by instantiating a new one but it can't because it doesn't have a default constructor that mono can use. It definitely "works" to supply that constructor but that most likely still causes down stream issues as there is now dangling instances.

If you follow the original stack trace you can see what I'm talking about.

Here's a good write up from @jonpryor that gets more into the technical side of it

https://stackoverflow.com/questions/10593022/monodroid-error-when-calling-constructor-of-custom-view-twodscrollview/10603714#10603714

The scenario he is talking about is more about construction why the exception is happening is about the same

@aixiaozi if you have a project where you can consistently recreate this that would be awesome!!

shneuvil at microsoft

@yorkvolvo
Copy link
Author

@PureWeen , thanks for your reply. The problem is that if the customer just add the (IntPtr handle, JniHandleOwnership transfer) constructor as mentioned in the Stack Overflow , there is another issue occurred randomly:

 System.Exception: CurrentDomainOnUnhandledException---> System.NotSupportedException: 
            Unable to activate instance of type Xamarin.Forms.Platform.Android.Platform + DefaultRenderer from native handle

Our customer resolved this issue by did some minor tweaking in his LabelRenderer and avoiding animation while navigating. Here is the customer's final solution:

1. Did some minor tweaking in LabelRenderer

public class MyLabelRenderer : LabelRenderer
{
    public MyLabelRenderer(Context context) : base(context)
    {
    }

    public MyLabelRenderer(IntPtr handle, JniHandleOwnership transfer)
    {
        
    }

    protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
    {
        try
        {
            base.OnElementChanged(e);
        }
        catch (Exception ex)
        {
        }
    }

    protected override void OnDetachedFromWindow()
    {
        if (Element == null)
            return;
        base.OnDetachedFromWindow();
    }
}

2. Stopped animation on page navigation using the below code

await PopupNavigation.PushAsync(cohp, false);

And I will send you an email to share customer's project. But as our customer said, reproducing it is tough. They spend 2-3 hours and do lot of testing then they get this issue.

Question

For now, customer need a confirmation that these are indeed the correct way to handle the issues. Do you have any tips or suggestion about this? Thanks and do look forward to your reply.

@yorkvolvo
Copy link
Author

@PureWeen , is there any updates? :)

@fishajavier
Copy link

fishajavier commented May 30, 2018

@aixiaozi We also have the same issue. Is your work around works well?!!!

@PureWeen
Copy link
Contributor

@fishajavier is your scenario also based around animations? Do you have a small repro by chance of your issue that we can look at? I have a PR here
#2857
that relates to disposing of elements inside a listview which might resolve the issue if you're dealing with components inside a listview

@samhouts samhouts added p/Android i/critical s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. labels Jun 14, 2018
@samhouts
Copy link
Member

We understand that this is an intermittent issue. If you can, please try Xamarin.Forms 3.1.0.561732-pre4 and let us know if it appears to resolve your issue. If not, please provide a sample project that exhibits the problem, if at all possible. Thank you!

@schemburkar
Copy link

If this helps, I hit the same problem today in the Google Pre-launch test for an app.

Xamarin.Forms 3.0.0.561731
Xamarin 4.10.10.2
VS 2017 15.7.4
Android 8..1 API27

FATAL EXCEPTION: ControllerMessenger
Process: next.applications.wp.studio.droid, PID: 19252
android.runtime.JavaProxyThrowable: System.NotSupportedException: Unable to activate instance of type Xamarin.Forms.Platform.Android.LabelRenderer from native handle 0xfff2f34c (key_handle 0x12f4e574). ---> System.MissingMethodException: No constructor found for Xamarin.Forms.Platform.Android.LabelRenderer::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership) ---> Java.Interop.JavaLocationException: Exception of type 'Java.Interop.JavaLocationException' was thrown.
   --- End of inner exception stack trace ---
  at Java.Interop.TypeManager.CreateProxy (System.Type type, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00054] in <bc23cd8ff24944b8a8b16cc7bd6b8ec5>:0 
  at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x00111] in <bc23cd8ff24944b8a8b16cc7bd6b8ec5>:0 
   --- End of inner exception stack trace ---
  at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x0017d] in <bc23cd8ff24944b8a8b16cc7bd6b8ec5>:0 
  at Java.Lang.Object.GetObject (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type type) [0x000b9] in <bc23cd8ff24944b8a8b16cc7bd6b8ec5>:0 
  at Java.Lang.Object._GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00017] in <bc23cd8ff24944b8a8b16cc7bd6b8ec5>:0 
  at Java.Lang.Object.GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00000] in <bc23cd8ff24944b8a8b16cc7bd6b8ec5>:0 
  at Java.Lang.Object.GetObject[T] (System.IntPtr jnienv, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00006] in <bc23cd8ff24944b8a8b16cc7bd6b8ec5>:0 
  at Android.Views.View.n_DispatchTouchEvent_Landroid_view_MotionEvent_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_e) [0x00000] in <bc23cd8ff24944b8a8b16cc7bd6b8ec5>:0 
  at (wrapper dynamic-method) System.Object.43108681-229f-4a3d-8545-9ec8899faa30(intptr,intptr,intptr)
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <780c7e838e9e4becb12a6614b2764112>:0 
  at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00089] in <a696302a15eb4b83b9c3f48dfb7b82fa>:0 
  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0005d] in <a696302a15eb4b83b9c3f48dfb7b82fa>:0 
  at Android.Views.ViewGroup.RemoveAllViews () [0x0000a] in <bc23cd8ff24944b8a8b16cc7bd6b8ec5>:0 
  at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Dispose (System.Boolean disposing) [0x00088] in <09e4bdebfa024bfd9231e2318fd7c3d7>:0 
  at Java.Lang.Object.Dispose () [0x00000] in <bc23cd8ff24944b8a8b16cc7bd6b8ec5>:0 
  at Xamarin.Forms.Platform.Android.ListViewRenderer.ClearRenderer (Android.Views.View renderedView) [0x00036] in <09e4bdebfa024bfd9231e2318fd7c3d7>:0 
  at Xamarin.Forms.Platform.Android.ListViewRenderer.Dispose (System.Boolean disposing) [0x0002a] in <09e4bdebfa024bfd9231e2318fd7c3d7>:0 
  at Java.Lang.Object.Dispose () [0x00000] in <bc23cd8ff24944b8a8b16cc7bd6b8ec5>:0 
  at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Dispose (System.Boolean disposing) [0x0007b] in <09e4bdebfa024bfd9231e2318fd7c3d7>:0 
  at Java.Lang.Object.Dispose () [0x00000] in <bc23cd8ff24944b8a8b16cc7bd6b8ec5>:0 
  at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Dispose (System.Boolean disposing) [0x0007b] in <09e4bdebfa024bfd9231e2318fd7c3d7>:0 
  at Xamarin.Forms.Platform.Android.PageRenderer.Dispose (System.Boolean d

@fishajavier
Copy link

fishajavier commented Jun 20, 2018

This is still an issue for us. This crash is happening on around 300 users in our Production App. Users are frustrated and uninstall our app in unexpected rate. Any workaround please? @PureWeen We can't reproduce the issue for you to investigate; it only happens on production.

@PureWeen
Copy link
Contributor

@schemburkar @fishajavier Some fixes were put into the upcoming 3.1 release that should resolve this issue. Once you're able to run with the next 3.1 let me know if you are still seeing the issue.

@schemburkar
Copy link

@PureWeen I tried with 3.1.0.561732-pre4 and the issue is still present. I can see that 3.1.0.583944 got released few hours ago, I will test using those bits today.

@schemburkar
Copy link

Issue is still present. @PureWeen tested with the latest bits 3.1.0.583944

@PureWeen
Copy link
Contributor

PureWeen commented Jun 22, 2018

@schemburkar do you have a reproduction at all you can share?

The problem with this type of exception is that it can manifest in a lot of different ways. For example if I create a custom renderer and add a touch handler that I never remove it can cause this exception

What's interesting about your stacktrace is that it's thrown during the dispose call from the page and I don't feel like I've seen it thrown from that point in the code before. It seems odd that a n_DispatchTouchEvent_Landroid_view_MotionEvent_ call would trigger during dispose so I'm curious to see how your page is composed (renderers etc...)

@schemburkar
Copy link

schemburkar commented Jun 22, 2018

@PureWeen My app code is on VSTS so might not be possible to share as is, I will try to create a standalone GitHub repo.
Not sure if it would be helpful. This is the Google's pre-launch report video showing the crash.

https://drive.google.com/file/d/1JxdGK-NKfX1YQAiNEVAvUe4Th9lNlLHe/view?usp=sharing

@KaelSuncaster
Copy link

KaelSuncaster commented Jun 26, 2018

Random crashes on android 6 and 8.1.

SDK version 27 (8.1)

Xamarin forms 2.5 and 3.0

Xamarin forms 2.5:

Xamarin caused by: android.runtime.JavaProxyThrowable: System.NotSupportedException: Unable to activate instance of type ExtendedEntryRenderer from native handle 0x7fefba88b4 (key_handle 0xe3a7635). ---> System.MissingMethodException: No constructor found for ExtendedEntryRenderer::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership) ---> Java.Interop.JavaLocationException: Exception of type 'Java.Interop.JavaLocationException' was thrown.
--- End of inner exception stack trace ---
at Java.Interop.TypeManager.CreateProxy (System.Type type, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00054] in <9cbfc420f01047ff8bed5f9881f74a56>:0
at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x00111] in <9cbfc420f01047ff8bed5f9881f74a56>:0
--- End of inner exception stack trace ---
at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x0017d] in <9cbfc420f01047ff8bed5f9881f74a56>:0
at Java.Lang.Object.GetObject (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type type) [0x000b9] in <9cbfc420f01047ff8bed5f9881f74a56>:0
at Java.Lang.Object._GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00017] in <9cbfc420f01047ff8bed5f9881f74a56>:0
at Java.Lang.Object.GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00000] in <9cbfc420f01047ff8bed5f9881f74a56>:0
at Java.Lang.Object.GetObject[T] (System.IntPtr jnienv, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00006] in <9cbfc420f01047ff8bed5f9881f74a56>:0
at Android.Text.ITextWatcherInvoker.n_BeforeTextChanged_Ljava_lang_CharSequence_III (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_s, System.Int32 start, System.Int32 count, System.Int32 after) [0x00000] in <9cbfc420f01047ff8bed5f9881f74a56>:0
at (wrapper dynamic-method) System.Object.1c72b9b0-95ff-48c1-831c-f72340d9f4f6(intptr,intptr,intptr,int,int,int)
at md51558244f76c53b6aeda52c8a337f2c37.EntryRenderer.n_beforeTextChanged(Native Method)
at md51558244f76c53b6aeda52c8a337f2c37.EntryRenderer.beforeTextChanged(EntryRenderer.java:59)
at android.widget.TextView.sendBeforeTextChanged(TextView.java:7953)
at android.widget.TextView.access$1300(TextView.java:246)
at android.widget.TextView$ChangeWatcher.beforeTextChanged(TextView.java:10163)
at android.text.SpannableStringBuilder.sendBeforeTextChanged(SpannableStringBuilder.java:1035)
at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:521)
at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:492)
at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:34)
at android.view.inputmethod.BaseInputConnection.replaceText(BaseInputConnection.java:685)
at android.view.inputmethod.BaseInputConnection.setComposingText(BaseInputConnection.java:445)
at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:340)
at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:78)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:168)
at android.app.ActivityThread.main(ActivityThread.java:5885)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)

Xamarin Forms 3.0:

Xamarin caused by: android.runtime.JavaProxyThrowable: System.NotSupportedException: Unable to activate instance of type Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer from native handle 0x7fcbd10ba4 (key_handle 0x95fa57b). ---> System.MissingMethodException: No constructor found for Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership) ---> Java.Interop.JavaLocationException: Exception of type 'Java.Interop.JavaLocationException' was thrown.
--- End of inner exception stack trace ---
at Java.Interop.TypeManager.CreateProxy (System.Type type, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00054] in <71b99a5ba8734f8eb16b99db3d296ff3>:0
at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x00111] in <71b99a5ba8734f8eb16b99db3d296ff3>:0
--- End of inner exception stack trace ---
at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x0017d] in <71b99a5ba8734f8eb16b99db3d296ff3>:0
at Java.Lang.Object.GetObject (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type type) [0x000b9] in <71b99a5ba8734f8eb16b99db3d296ff3>:0
at Java.Lang.Object._GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00017] in <71b99a5ba8734f8eb16b99db3d296ff3>:0
at Java.Lang.Object.GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00000] in <71b99a5ba8734f8eb16b99db3d296ff3>:0
at Java.Lang.Object.GetObject[T] (System.IntPtr jnienv, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00006] in <71b99a5ba8734f8eb16b99db3d296ff3>:0
at Android.Views.View.n_Invalidate (System.IntPtr jnienv, System.IntPtr native__this) [0x00000] in <71b99a5ba8734f8eb16b99db3d296ff3>:0
at (wrapper dynamic-method) System.Object.3b755176-09cb-49fd-8c44-596fd521a4e5(intptr,intptr)
at md51558244f76c53b6aeda52c8a337f2c37.FormsTextView.n_invalidate(Native Method)
at md51558244f76c53b6aeda52c8a337f2c37.FormsTextView.invalidate(FormsTextView.java:45)
at android.view.ViewRootImpl$InvalidateOnAnimationRunnable.run(ViewRootImpl.java:7218)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:927)
at android.view.Choreographer.doCallbacks(Choreographer.java:702)
at android.view.Choreographer.doFrame(Choreographer.java:635)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:913)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6682)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)

@PureWeen
Copy link
Contributor

@schemburkar if you want to zip up and email it to me that's also an option shneuvil at microsoft
If not then a repro would be useful. The interesting thing about your stack trace is that there's a motion event happening during the dispose call

at Android.Views.View.n_DispatchTouchEvent_Landroid_view_MotionEvent_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_e) [0x00000] in :0
at Xamarin.Forms.Platform.Android.PageRenderer.Dispose (System.Boolean d

So I'm just curious to see how things are put together

@KaelSuncaster if you have a small repro that'd be useful or some more information about the page you are seeing this on

General Note
The problem with this exception is that it basically just happens if something doesn't get disposed so there's a dangling reference to a view left over. That means it can pop up from an assortment of places and in an assortment of ways. For example if a user has a custom renderer and they don't remove a handler from a view it will cause the exception. Even though the exception is the same the reason it's happening is usually case by case and we're just trying to clean up all the cases

@schemburkar
Copy link

@PureWeen An update:

Not sure why, After deleting all binaries (nuget, bin, obj, etc) and re-creating apk has passed the pre-launch tests from Google. I will keep monitoring if issue comes up in the wild again.

In any case, I have created a code zip to share with you on email in few days.

@PureWeen
Copy link
Contributor

Closing this for now.

If anyone is still getting this exception with the latest Xam Forms please provide a repro or a stack trace with as much information as possible about the XAML and how you are causing it to happen.

Though a repro would be preferred

@mkieres
Copy link
Contributor

mkieres commented Jul 25, 2018

@PureWeen I'm not sure how this issue relates to what's logged in the #2444, but from the stack traces it would seem that there's still an issue with LabelRenderer constructor.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p/Android s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/needs-repro ❔ This reported issue doesn't include a sample project reproducing the issue. Please provide one.
Projects
None yet
Development

No branches or pull requests

9 participants