{"action":"created","issue":{"url":"https://api.github.com/repos/xamarin/Xamarin.Forms/issues/8262","repository_url":"https://api.github.com/repos/xamarin/Xamarin.Forms","labels_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/issues/8262/labels{/name}","comments_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/issues/8262/comments","events_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/issues/8262/events","html_url":"https://github.com/xamarin/Xamarin.Forms/issues/8262","id":512996294,"node_id":"MDU6SXNzdWU1MTI5OTYyOTQ=","number":8262,"title":"[Bug] System.NotSupportedException: Unable to activate instance of type Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer","user":{"login":"Happypig375","id":19922066,"node_id":"MDQ6VXNlcjE5OTIyMDY2","avatar_url":"https://avatars2.githubusercontent.com/u/19922066?v=4","gravatar_id":"","url":"https://api.github.com/users/Happypig375","html_url":"https://github.com/Happypig375","followers_url":"https://api.github.com/users/Happypig375/followers","following_url":"https://api.github.com/users/Happypig375/following{/other_user}","gists_url":"https://api.github.com/users/Happypig375/gists{/gist_id}","starred_url":"https://api.github.com/users/Happypig375/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Happypig375/subscriptions","organizations_url":"https://api.github.com/users/Happypig375/orgs","repos_url":"https://api.github.com/users/Happypig375/repos","events_url":"https://api.github.com/users/Happypig375/events{/privacy}","received_events_url":"https://api.github.com/users/Happypig375/received_events","type":"User","site_admin":false},"labels":[{"id":978570995,"node_id":"MDU6TGFiZWw5Nzg1NzA5OTU=","url":"https://api.github.com/repos/xamarin/Xamarin.Forms/labels/e/5%20:clock5:","name":"e/5 :clock5:","color":"23d3cd","default":false,"description":"5"},{"id":1589979093,"node_id":"MDU6TGFiZWwxNTg5OTc5MDkz","url":"https://api.github.com/repos/xamarin/Xamarin.Forms/labels/in-progress","name":"in-progress","color":"ededed","default":false,"description":"This issue has an associated pull request that may resolve it!"},{"id":770579964,"node_id":"MDU6TGFiZWw3NzA1Nzk5NjQ=","url":"https://api.github.com/repos/xamarin/Xamarin.Forms/labels/p/Android","name":"p/Android","color":"f9aee2","default":false,"description":null},{"id":343860851,"node_id":"MDU6TGFiZWwzNDM4NjA4NTE=","url":"https://api.github.com/repos/xamarin/Xamarin.Forms/labels/t/bug%20:bug:","name":"t/bug :bug:","color":"fc2929","default":false,"description":""}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":21,"created_at":"2019-10-27T17:30:02Z","updated_at":"2019-12-27T22:19:00Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"<!-- Bug report best practices: https://github.com/xamarin/Xamarin.Forms/wiki/Submitting-Issues -->\r\n\r\n### Description\r\nThe following exception occurs when scrolling in the repro on an Android device.\r\n```\r\n**System.NotSupportedException:** 'Unable to activate instance of type Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer from native handle 0xbedad7ec (key_handle 0xd22eb7f).'\r\n```\r\n\r\n### Steps to Reproduce\r\n\r\n1. Paste into MainPage.xaml.cs\r\n```cs\r\nusing System;\r\nusing System.Collections.Generic;\r\nusing System.ComponentModel;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing System.Threading.Tasks;\r\nusing Xamarin.Forms;\r\n\r\nnamespace FastRendererCrash\r\n{\r\n    static class Extensions\r\n    {\r\n        public static View WithBounds(this View v, double x, double y, double w, double h)\r\n        {\r\n            AbsoluteLayout.SetLayoutBounds(v, new Rectangle(x, y, w, h));\r\n            return v;\r\n        }\r\n    }\r\n    // Learn more about making custom code visible in the Xamarin.Forms previewer\r\n    // by visiting https://aka.ms/xamarinforms-previewer\r\n    [DesignTimeVisible(false)]\r\n    public partial class MainPage : ContentPage\r\n    {\r\n        public MainPage()\r\n        {\r\n            InitializeComponent();\r\n            IEnumerable<View> Select((string groupHeader, IEnumerable<int> items) t)\r\n            {\r\n                yield return new AbsoluteLayout\r\n                {\r\n                    Children = {\r\n                        new Label {\r\n                            Text = t.groupHeader, HorizontalTextAlignment = TextAlignment.Center,\r\n                            TextColor = Color.FromUint(0xff5a5a5a), FontSize = 10\r\n                        }.WithBounds(0, 21.1, 310, AbsoluteLayout.AutoSize) },\r\n                    HorizontalOptions = LayoutOptions.FillAndExpand,\r\n                    VerticalOptions = LayoutOptions.Start,\r\n                    HeightRequest = 46\r\n                };\r\n                foreach (var item in t.items)\r\n                {\r\n                    yield return new AbsoluteLayout\r\n                    {\r\n                        Children = {\r\n                            new Image { Source = ImageSource.FromResource(\"FastRendererScrollCrash.light.png\", System.Reflection.Assembly.GetCallingAssembly()) }\r\n                            .WithBounds(23.6, 14.5, 14.9, 20.7),\r\n                            new Label { Text = item.ToString(), TextColor = Color.FromUint(0xff5a5a5a), FontSize = 10 }\r\n                            .WithBounds(58, 18.2, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize)\r\n                        },\r\n                        HorizontalOptions = LayoutOptions.FillAndExpand,\r\n                        VerticalOptions = LayoutOptions.Start,\r\n                        HeightRequest = 49.7\r\n                    };\r\n                }\r\n            }\r\n            Content = new AbsoluteLayout\r\n            {\r\n                Children = {\r\n                    new CollectionView {\r\n                        ItemsSource =\r\n                            new (string, Func<int, bool>)[] {\r\n                                (\"odd\", i => i % 2 == 1),\r\n                                (\"even\", i => i % 2 == 0),\r\n                                (\"triple\", i => i % 3 == 0),\r\n                                (\"fives\", i => i % 5 == 0) }\r\n                            .Select(t => (t.Item1, Enumerable.Range(1, 100).Where(t.Item2)))\r\n                            .SelectMany(Select),\r\n                        ItemTemplate = new DataTemplate(() => {\r\n                            var template = new ContentView();\r\n                            template.SetBinding(ContentView.ContentProperty, \".\");\r\n                            return template;\r\n                        }),\r\n                        ItemsLayout = LinearItemsLayout.Vertical,\r\n                        ItemSizingStrategy = ItemSizingStrategy.MeasureFirstItem\r\n                    }\r\n                }\r\n            };\r\n        }\r\n    }\r\n}\r\n```\r\n2. Add an embedded image file with name \"light.png\"\r\n3. Debug the app onto an Android phone (e.g. my Xiaomi Redmi 6 running Android 8.1 is a phone that can repro the exception)\r\n4. Scroll downwards quickly (aim for at least 30 items per screen update)\r\n5. After 2 screen updates, the app crashes:\r\n```\r\n10-28 01:20:31.487 I/MonoDroid(17924): UNHANDLED EXCEPTION:\r\n10-28 01:20:31.491 I/MonoDroid(17924): System.NotSupportedException: Unable to activate instance of type Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer from native handle 0xbedad7ec (key_handle 0xf313e4). ---> 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.\r\n10-28 01:20:31.491 I/MonoDroid(17924):    --- End of inner exception stack trace ---\r\n10-28 01:20:31.491 I/MonoDroid(17924):   at Java.Interop.TypeManager.CreateProxy (System.Type type, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00055] in <11a340ccc8de43f09c97400139266ef5>:0 \r\n10-28 01:20:31.491 I/MonoDroid(17924):   at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x00116] in <11a340ccc8de43f09c97400139266ef5>:0 \r\n10-28 01:20:31.491 I/MonoDroid(17924):    --- End of inner exception stack trace ---\r\n10-28 01:20:31.492 I/MonoDroid(17924):   at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x00182] in <11a340ccc8de43f09c97400139266ef5>:0 \r\n10-28 01:20:31.492 I/MonoDroid(17924):   at Java.Lang.Object.GetObject (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type type) [0x000c1] in <11a340ccc8de43f09c97400139266ef5>:0 \r\n10-28 01:20:31.492 I/MonoDroid(17924):   at Java.Lang.Object._GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00017] in <11a340ccc8de43f09c97400139266ef5>:0 \r\n10-28 01:20:31.492 I/MonoDroid(17924):   at Java.Lang.Object.GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00000] in <11a340ccc8de43f09c97400139266ef5>:0 \r\n10-28 01:20:31.492 I/MonoDroid(17924):   at Java.Lang.Object.GetObject[T] (System.IntPtr jnienv, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00006] in <11a340ccc8de43f09c97400139266ef5>:0 \r\n10-28 01:20:31.492 I/MonoDroid(17924):   at Android.Views.View.n_Invalidate (System.IntPtr jnienv, System.IntPtr native__this) [0x00000] in <11a340ccc8de43f09c97400139266ef5>:0 \r\n10-28 01:20:31.492 I/MonoDroid(17924):   at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.55(intptr,intptr)\r\n```\r\n\r\n### Expected Behavior\r\nThe app does not crash and continues to scroll.\r\n\r\n### Actual Behavior\r\nThe app crashes.\r\n\r\n### Basic Information\r\n\r\n- Version with issue: 4.2, 4.3.0.908765\r\n- Last known good version: Idk\r\n- IDE: VS16.3.6\r\n- Platform Target Frameworks: <!-- All that apply -->\r\n  - Android: 9.0\r\n- Android Support Library Version: 28.0.0.3\r\n- Nuget Packages: XForms4.3.0.908765, XEssentials1.3.1, NetStandard2.0.3, AndroidSupport28.0.0.3\r\n- Affected Devices: Android phones including Xiaomi Redmi 6\r\n\r\n### Screenshots\r\n\r\nDuring step 4:\r\n\r\n![image](https://user-images.githubusercontent.com/19922066/67638660-0cc5ba80-f922-11e9-8b7e-233c3df4612d.png)|![image](https://user-images.githubusercontent.com/19922066/67638664-12230500-f922-11e9-807f-41ff302c1ad4.png)\r\n------|----------\r\n![image](https://user-images.githubusercontent.com/19922066/67638666-18b17c80-f922-11e9-8714-a08c6c8fe26f.png)|![image](https://user-images.githubusercontent.com/19922066/67638668-1bac6d00-f922-11e9-91f3-35e7cc69b65e.png)\r\n\r\n\r\n### Reproduction Link\r\n\r\n<!-- Please upload or provide a link to a reproduction case -->\r\n[FastRendererCrash.zip](https://github.com/xamarin/Xamarin.Forms/files/3776191/FastRendererCrash.zip)\r\n"},"comment":{"url":"https://api.github.com/repos/xamarin/Xamarin.Forms/issues/comments/569355805","html_url":"https://github.com/xamarin/Xamarin.Forms/issues/8262#issuecomment-569355805","issue_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/issues/8262","id":569355805,"node_id":"MDEyOklzc3VlQ29tbWVudDU2OTM1NTgwNQ==","user":{"login":"PureWeen","id":5375137,"node_id":"MDQ6VXNlcjUzNzUxMzc=","avatar_url":"https://avatars1.githubusercontent.com/u/5375137?v=4","gravatar_id":"","url":"https://api.github.com/users/PureWeen","html_url":"https://github.com/PureWeen","followers_url":"https://api.github.com/users/PureWeen/followers","following_url":"https://api.github.com/users/PureWeen/following{/other_user}","gists_url":"https://api.github.com/users/PureWeen/gists{/gist_id}","starred_url":"https://api.github.com/users/PureWeen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PureWeen/subscriptions","organizations_url":"https://api.github.com/users/PureWeen/orgs","repos_url":"https://api.github.com/users/PureWeen/repos","events_url":"https://api.github.com/users/PureWeen/events{/privacy}","received_events_url":"https://api.github.com/users/PureWeen/received_events","type":"User","site_admin":false},"created_at":"2019-12-27T22:19:00Z","updated_at":"2019-12-27T22:19:00Z","author_association":"CONTRIBUTOR","body":"@kvpt were you able to reproduce the dispose exception on the Label?\r\n\r\n\r\nUsing the reproduction attached to this issue\r\nhttps://github.com/xamarin/Xamarin.Forms/issues/8262#issue-512996294\r\n\r\nThe exception I'm seeing is from the ImageRenderer. \r\nI created this PR which seems to fix the ImageRenderer scenario\r\nhttps://github.com/xamarin/Xamarin.Forms/pull/9034"}}
{"actor":{"display_login":"PureWeen"}}