{"action":"closed","number":288,"pull_request":{"url":"https://api.github.com/repos/xamarin/xamarin-android/pulls/288","id":93003174,"html_url":"https://github.com/xamarin/xamarin-android/pull/288","diff_url":"https://github.com/xamarin/xamarin-android/pull/288.diff","patch_url":"https://github.com/xamarin/xamarin-android/pull/288.patch","issue_url":"https://api.github.com/repos/xamarin/xamarin-android/issues/288","number":288,"state":"closed","locked":false,"title":"[Mono.Android] Add a manual dispose fallback path when calling Dispose on a surfaced object fails","user":{"login":"garuma","id":104105,"avatar_url":"https://avatars.githubusercontent.com/u/104105?v=3","gravatar_id":"","url":"https://api.github.com/users/garuma","html_url":"https://github.com/garuma","followers_url":"https://api.github.com/users/garuma/followers","following_url":"https://api.github.com/users/garuma/following{/other_user}","gists_url":"https://api.github.com/users/garuma/gists{/gist_id}","starred_url":"https://api.github.com/users/garuma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garuma/subscriptions","organizations_url":"https://api.github.com/users/garuma/orgs","repos_url":"https://api.github.com/users/garuma/repos","events_url":"https://api.github.com/users/garuma/events{/privacy}","received_events_url":"https://api.github.com/users/garuma/received_events","type":"User","site_admin":false},"body":"Previously we would simply call `Dispose` on each object surfaced to the runtime before shutdown so that no finalizer code could be run into a dead appdomain.\r\n\r\nUnfortunately, because `Dispose` naturally calls `Dispose(bool)` before doing any low-level cleanup, user code can potentially throw exceptions which prevent the operation from happening correcly and (currently) triggers a process crash because of the unhandled exception.\r\n\r\nThis is the case when in the context of the Xamarin.Forms previewer where XF objects usually implement their own Dispose mechanism. Due to the \"flat\" nature of our cleanup loop, it may happen that we call `Dispose` on a XF object that in its own `Dispose(bool)` implementation also tries to invoke `Dispose` on an underlying object. The issue is that we may have already disposed it previously in our loop (since we have no clue on objects relationship with each other) causing an ObjectDisposedException to be thrown:\r\n\r\n```\r\n Unhandled Exception:\r\n System.ObjectDisposedException: Cannot access a disposed object.\r\n Object name: 'Android.Widget.ListView'.\r\n   at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00036] in /Users/builder/data/lanes/1196/cf38796b/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.cs:166\r\n   at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00002] in /Users/builder/data/lanes/1196/cf38796b/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:21\r\n   at Android.Widget.AdapterView.set_OnItemClickListener (Android.Widget.AdapterView+IOnItemClickListener value) [0x00031] in /Users/builder/data/lanes/1196/cf38796b/source/monodroid/src/Mono.Android/platforms/android-24/src/generated/Android.Widget.AdapterView.cs:946\r\n   at Xamarin.Forms.Platform.Android.ListViewAdapter.Dispose (System.Boolean disposing) [0x00050] in C:\\BuildAgent3\\work\\82141f6bfad29a4c\\Xamarin.Forms.Platform.Android\\Renderers\\ListViewAdapter.cs:332\r\n   at Java.Lang.Object.Dispose () [0x00000] in /Users/builder/data/lanes/1196/cf38796b/source/xamarin-android/src/Mono.Android/Java.Lang/Object.cs:203\r\n   at Android.Runtime.JNIEnv.Exit () [0x00051] in /Users/builder/data/lanes/1196/cf38796b/source/xamarin-android/src/Mono.Android/Android.Runtime/JNIEnv.cs:309\r\n```\r\n\r\nThis commit adds a workaround for now that catches all exception on calling `Dispose` and log them. If an exception did happen, it then proceed onto trying to manually clean up the JLO instance by reproducing the second part of `Java.Lang.Object.Dispose` to clear the object's GREF and suppress its finalizer. This is far from \"nice\" but until a better integration with `Java.Interop.Runtime` can be devised it's the less intrusive method.","created_at":"2016-11-09T17:17:06Z","updated_at":"2016-11-09T18:29:00Z","closed_at":"2016-11-09T18:29:00Z","merged_at":"2016-11-09T18:29:00Z","merge_commit_sha":"b9b52fdb48c317484827ef7d396826409313d995","assignee":{"login":"jonpryor","id":155958,"avatar_url":"https://avatars.githubusercontent.com/u/155958?v=3","gravatar_id":"","url":"https://api.github.com/users/jonpryor","html_url":"https://github.com/jonpryor","followers_url":"https://api.github.com/users/jonpryor/followers","following_url":"https://api.github.com/users/jonpryor/following{/other_user}","gists_url":"https://api.github.com/users/jonpryor/gists{/gist_id}","starred_url":"https://api.github.com/users/jonpryor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonpryor/subscriptions","organizations_url":"https://api.github.com/users/jonpryor/orgs","repos_url":"https://api.github.com/users/jonpryor/repos","events_url":"https://api.github.com/users/jonpryor/events{/privacy}","received_events_url":"https://api.github.com/users/jonpryor/received_events","type":"User","site_admin":false},"assignees":[{"login":"jonpryor","id":155958,"avatar_url":"https://avatars.githubusercontent.com/u/155958?v=3","gravatar_id":"","url":"https://api.github.com/users/jonpryor","html_url":"https://github.com/jonpryor","followers_url":"https://api.github.com/users/jonpryor/followers","following_url":"https://api.github.com/users/jonpryor/following{/other_user}","gists_url":"https://api.github.com/users/jonpryor/gists{/gist_id}","starred_url":"https://api.github.com/users/jonpryor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonpryor/subscriptions","organizations_url":"https://api.github.com/users/jonpryor/orgs","repos_url":"https://api.github.com/users/jonpryor/repos","events_url":"https://api.github.com/users/jonpryor/events{/privacy}","received_events_url":"https://api.github.com/users/jonpryor/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/xamarin/xamarin-android/pulls/288/commits","review_comments_url":"https://api.github.com/repos/xamarin/xamarin-android/pulls/288/comments","review_comment_url":"https://api.github.com/repos/xamarin/xamarin-android/pulls/comments{/number}","comments_url":"https://api.github.com/repos/xamarin/xamarin-android/issues/288/comments","statuses_url":"https://api.github.com/repos/xamarin/xamarin-android/statuses/71879a0d3e3bd62690591ac75b634bf3166f1f9f","head":{"label":"xamarin:manual-jobj-dispose","ref":"manual-jobj-dispose","sha":"71879a0d3e3bd62690591ac75b634bf3166f1f9f","user":{"login":"xamarin","id":790012,"avatar_url":"https://avatars.githubusercontent.com/u/790012?v=3","gravatar_id":"","url":"https://api.github.com/users/xamarin","html_url":"https://github.com/xamarin","followers_url":"https://api.github.com/users/xamarin/followers","following_url":"https://api.github.com/users/xamarin/following{/other_user}","gists_url":"https://api.github.com/users/xamarin/gists{/gist_id}","starred_url":"https://api.github.com/users/xamarin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xamarin/subscriptions","organizations_url":"https://api.github.com/users/xamarin/orgs","repos_url":"https://api.github.com/users/xamarin/repos","events_url":"https://api.github.com/users/xamarin/events{/privacy}","received_events_url":"https://api.github.com/users/xamarin/received_events","type":"Organization","site_admin":false},"repo":{"id":55075302,"name":"xamarin-android","full_name":"xamarin/xamarin-android","owner":{"login":"xamarin","id":790012,"avatar_url":"https://avatars.githubusercontent.com/u/790012?v=3","gravatar_id":"","url":"https://api.github.com/users/xamarin","html_url":"https://github.com/xamarin","followers_url":"https://api.github.com/users/xamarin/followers","following_url":"https://api.github.com/users/xamarin/following{/other_user}","gists_url":"https://api.github.com/users/xamarin/gists{/gist_id}","starred_url":"https://api.github.com/users/xamarin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xamarin/subscriptions","organizations_url":"https://api.github.com/users/xamarin/orgs","repos_url":"https://api.github.com/users/xamarin/repos","events_url":"https://api.github.com/users/xamarin/events{/privacy}","received_events_url":"https://api.github.com/users/xamarin/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/xamarin/xamarin-android","description":null,"fork":false,"url":"https://api.github.com/repos/xamarin/xamarin-android","forks_url":"https://api.github.com/repos/xamarin/xamarin-android/forks","keys_url":"https://api.github.com/repos/xamarin/xamarin-android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xamarin/xamarin-android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xamarin/xamarin-android/teams","hooks_url":"https://api.github.com/repos/xamarin/xamarin-android/hooks","issue_events_url":"https://api.github.com/repos/xamarin/xamarin-android/issues/events{/number}","events_url":"https://api.github.com/repos/xamarin/xamarin-android/events","assignees_url":"https://api.github.com/repos/xamarin/xamarin-android/assignees{/user}","branches_url":"https://api.github.com/repos/xamarin/xamarin-android/branches{/branch}","tags_url":"https://api.github.com/repos/xamarin/xamarin-android/tags","blobs_url":"https://api.github.com/repos/xamarin/xamarin-android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xamarin/xamarin-android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xamarin/xamarin-android/git/refs{/sha}","trees_url":"https://api.github.com/repos/xamarin/xamarin-android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xamarin/xamarin-android/statuses/{sha}","languages_url":"https://api.github.com/repos/xamarin/xamarin-android/languages","stargazers_url":"https://api.github.com/repos/xamarin/xamarin-android/stargazers","contributors_url":"https://api.github.com/repos/xamarin/xamarin-android/contributors","subscribers_url":"https://api.github.com/repos/xamarin/xamarin-android/subscribers","subscription_url":"https://api.github.com/repos/xamarin/xamarin-android/subscription","commits_url":"https://api.github.com/repos/xamarin/xamarin-android/commits{/sha}","git_commits_url":"https://api.github.com/repos/xamarin/xamarin-android/git/commits{/sha}","comments_url":"https://api.github.com/repos/xamarin/xamarin-android/comments{/number}","issue_comment_url":"https://api.github.com/repos/xamarin/xamarin-android/issues/comments{/number}","contents_url":"https://api.github.com/repos/xamarin/xamarin-android/contents/{+path}","compare_url":"https://api.github.com/repos/xamarin/xamarin-android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xamarin/xamarin-android/merges","archive_url":"https://api.github.com/repos/xamarin/xamarin-android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xamarin/xamarin-android/downloads","issues_url":"https://api.github.com/repos/xamarin/xamarin-android/issues{/number}","pulls_url":"https://api.github.com/repos/xamarin/xamarin-android/pulls{/number}","milestones_url":"https://api.github.com/repos/xamarin/xamarin-android/milestones{/number}","notifications_url":"https://api.github.com/repos/xamarin/xamarin-android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xamarin/xamarin-android/labels{/name}","releases_url":"https://api.github.com/repos/xamarin/xamarin-android/releases{/id}","deployments_url":"https://api.github.com/repos/xamarin/xamarin-android/deployments","created_at":"2016-03-30T15:37:14Z","updated_at":"2016-11-05T19:55:19Z","pushed_at":"2016-11-09T18:29:00Z","git_url":"git://github.com/xamarin/xamarin-android.git","ssh_url":"git@github.com:xamarin/xamarin-android.git","clone_url":"https://github.com/xamarin/xamarin-android.git","svn_url":"https://github.com/xamarin/xamarin-android","homepage":null,"size":6538,"stargazers_count":635,"watchers_count":635,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":157,"mirror_url":null,"open_issues_count":9,"forks":157,"open_issues":9,"watchers":635,"default_branch":"master"}},"base":{"label":"xamarin:master","ref":"master","sha":"bb59de1aaee86a334beee5d3f91f123a9a71f454","user":{"login":"xamarin","id":790012,"avatar_url":"https://avatars.githubusercontent.com/u/790012?v=3","gravatar_id":"","url":"https://api.github.com/users/xamarin","html_url":"https://github.com/xamarin","followers_url":"https://api.github.com/users/xamarin/followers","following_url":"https://api.github.com/users/xamarin/following{/other_user}","gists_url":"https://api.github.com/users/xamarin/gists{/gist_id}","starred_url":"https://api.github.com/users/xamarin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xamarin/subscriptions","organizations_url":"https://api.github.com/users/xamarin/orgs","repos_url":"https://api.github.com/users/xamarin/repos","events_url":"https://api.github.com/users/xamarin/events{/privacy}","received_events_url":"https://api.github.com/users/xamarin/received_events","type":"Organization","site_admin":false},"repo":{"id":55075302,"name":"xamarin-android","full_name":"xamarin/xamarin-android","owner":{"login":"xamarin","id":790012,"avatar_url":"https://avatars.githubusercontent.com/u/790012?v=3","gravatar_id":"","url":"https://api.github.com/users/xamarin","html_url":"https://github.com/xamarin","followers_url":"https://api.github.com/users/xamarin/followers","following_url":"https://api.github.com/users/xamarin/following{/other_user}","gists_url":"https://api.github.com/users/xamarin/gists{/gist_id}","starred_url":"https://api.github.com/users/xamarin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xamarin/subscriptions","organizations_url":"https://api.github.com/users/xamarin/orgs","repos_url":"https://api.github.com/users/xamarin/repos","events_url":"https://api.github.com/users/xamarin/events{/privacy}","received_events_url":"https://api.github.com/users/xamarin/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/xamarin/xamarin-android","description":null,"fork":false,"url":"https://api.github.com/repos/xamarin/xamarin-android","forks_url":"https://api.github.com/repos/xamarin/xamarin-android/forks","keys_url":"https://api.github.com/repos/xamarin/xamarin-android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xamarin/xamarin-android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xamarin/xamarin-android/teams","hooks_url":"https://api.github.com/repos/xamarin/xamarin-android/hooks","issue_events_url":"https://api.github.com/repos/xamarin/xamarin-android/issues/events{/number}","events_url":"https://api.github.com/repos/xamarin/xamarin-android/events","assignees_url":"https://api.github.com/repos/xamarin/xamarin-android/assignees{/user}","branches_url":"https://api.github.com/repos/xamarin/xamarin-android/branches{/branch}","tags_url":"https://api.github.com/repos/xamarin/xamarin-android/tags","blobs_url":"https://api.github.com/repos/xamarin/xamarin-android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xamarin/xamarin-android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xamarin/xamarin-android/git/refs{/sha}","trees_url":"https://api.github.com/repos/xamarin/xamarin-android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xamarin/xamarin-android/statuses/{sha}","languages_url":"https://api.github.com/repos/xamarin/xamarin-android/languages","stargazers_url":"https://api.github.com/repos/xamarin/xamarin-android/stargazers","contributors_url":"https://api.github.com/repos/xamarin/xamarin-android/contributors","subscribers_url":"https://api.github.com/repos/xamarin/xamarin-android/subscribers","subscription_url":"https://api.github.com/repos/xamarin/xamarin-android/subscription","commits_url":"https://api.github.com/repos/xamarin/xamarin-android/commits{/sha}","git_commits_url":"https://api.github.com/repos/xamarin/xamarin-android/git/commits{/sha}","comments_url":"https://api.github.com/repos/xamarin/xamarin-android/comments{/number}","issue_comment_url":"https://api.github.com/repos/xamarin/xamarin-android/issues/comments{/number}","contents_url":"https://api.github.com/repos/xamarin/xamarin-android/contents/{+path}","compare_url":"https://api.github.com/repos/xamarin/xamarin-android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xamarin/xamarin-android/merges","archive_url":"https://api.github.com/repos/xamarin/xamarin-android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xamarin/xamarin-android/downloads","issues_url":"https://api.github.com/repos/xamarin/xamarin-android/issues{/number}","pulls_url":"https://api.github.com/repos/xamarin/xamarin-android/pulls{/number}","milestones_url":"https://api.github.com/repos/xamarin/xamarin-android/milestones{/number}","notifications_url":"https://api.github.com/repos/xamarin/xamarin-android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xamarin/xamarin-android/labels{/name}","releases_url":"https://api.github.com/repos/xamarin/xamarin-android/releases{/id}","deployments_url":"https://api.github.com/repos/xamarin/xamarin-android/deployments","created_at":"2016-03-30T15:37:14Z","updated_at":"2016-11-05T19:55:19Z","pushed_at":"2016-11-09T18:29:00Z","git_url":"git://github.com/xamarin/xamarin-android.git","ssh_url":"git@github.com:xamarin/xamarin-android.git","clone_url":"https://github.com/xamarin/xamarin-android.git","svn_url":"https://github.com/xamarin/xamarin-android","homepage":null,"size":6538,"stargazers_count":635,"watchers_count":635,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":157,"mirror_url":null,"open_issues_count":9,"forks":157,"open_issues":9,"watchers":635,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/xamarin/xamarin-android/pulls/288"},"html":{"href":"https://github.com/xamarin/xamarin-android/pull/288"},"issue":{"href":"https://api.github.com/repos/xamarin/xamarin-android/issues/288"},"comments":{"href":"https://api.github.com/repos/xamarin/xamarin-android/issues/288/comments"},"review_comments":{"href":"https://api.github.com/repos/xamarin/xamarin-android/pulls/288/comments"},"review_comment":{"href":"https://api.github.com/repos/xamarin/xamarin-android/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/xamarin/xamarin-android/pulls/288/commits"},"statuses":{"href":"https://api.github.com/repos/xamarin/xamarin-android/statuses/71879a0d3e3bd62690591ac75b634bf3166f1f9f"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"jonpryor","id":155958,"avatar_url":"https://avatars.githubusercontent.com/u/155958?v=3","gravatar_id":"","url":"https://api.github.com/users/jonpryor","html_url":"https://github.com/jonpryor","followers_url":"https://api.github.com/users/jonpryor/followers","following_url":"https://api.github.com/users/jonpryor/following{/other_user}","gists_url":"https://api.github.com/users/jonpryor/gists{/gist_id}","starred_url":"https://api.github.com/users/jonpryor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonpryor/subscriptions","organizations_url":"https://api.github.com/users/jonpryor/orgs","repos_url":"https://api.github.com/users/jonpryor/repos","events_url":"https://api.github.com/users/jonpryor/events{/privacy}","received_events_url":"https://api.github.com/users/jonpryor/received_events","type":"User","site_admin":false},"comments":0,"review_comments":0,"commits":1,"additions":32,"deletions":3,"changed_files":1}}
{"actor":{"display_login":"jonpryor"}}