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

Disposed objects are not handled properly in android scrollview renderer #8600

Closed
SubburajPandianV opened this issue Nov 21, 2019 · 4 comments
Labels
i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often p/Android partner Issue submitted by partner or related open source project s/unverified New report that has yet to be verified t/bug 🐛

Comments

@SubburajPandianV
Copy link

Issue

Disposed objects are not handled properly in android scrollview renderer.
#5820

Description

It occured due to ScrollViewRenderer is not disposed properly when navigated away from the page i.e., Renderer is not cleared from Xamarin.Forms.ScrollView even if we disposed the native object

This reported issue 5820 has been fixed in this commit 6151

Fixed in Xamarin.Forms v4.2.0.815419, release notes.

https://docs.microsoft.com/en-us/xamarin/xamarin-forms/release-notes/4.2/4.2.0-sr2

After upgrading the Xamarin.Forms to v4.2.0.815419, we have encountered the following crash report in the application,

#7602

It is also resolved, now again the mentioned issue 5820 occuring. Kindly check and let us know the details.

@SubburajPandianV SubburajPandianV added s/unverified New report that has yet to be verified t/bug 🐛 labels Nov 21, 2019
@pauldipietro pauldipietro added this to New in Triage Nov 21, 2019
@samhouts
Copy link
Member

@SubburajPandianV Can you please attach a small project that demonstrates this issue? Thanks!

@samhouts samhouts added i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often p/Android partner Issue submitted by partner or related open source project labels Nov 25, 2019
@jfversluis
Copy link
Member

Hey @SubburajPandianV thanks for the report!

I'm afraid I don't quite understand what is going on. You mention all kinds of issues and fixes and if I read it correctly everything seems fixed?

Could you give some more information and like Samantha mentioned; a reproduction project? Thanks!

@jfversluis jfversluis added 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. labels Nov 27, 2019
@jfversluis jfversluis moved this from New to Needs Info in Triage Nov 27, 2019
@SubburajPandian
Copy link

Hi @samhouts / @jfversluis,

Sorry for the delay.

I have attached the sample project in which we installed Xamarin.Forms latest stable version 4.4.0.991.

Sample: ScrollView_Sample.zip

Replication procedure:

  • Run the sample in Android
  • Tap the ExpanderSample
  • Tap back
  • Tap again the ExpanderSample
  • Throws System.ObjectDisposedException: 'Cannot access a disposed object. Object name: 'Xamarin.Forms.Platform.Android.ScrollViewRenderer.

Issue details:
The reported issue occurs due to ScrollViewRenderer is not disposed properly when navigated away from the page i.e., Renderer is not cleared from Xamarin.Forms.ScrollView even if we disposed the native object. So, that when navigate back to Expander control, we create a new renderer for ScrollView if renderer is null which is loaded in the Content and at this time, disposed renderer for ScrollView is still maintained in Xamarin Forms Android platform which leads to Object disposed exception from ScrollViewRenderer class while accessing the native view in our source in order to layout the native ScrollView.

Since it occurs in the Xamarin framework and we have already logged a defect report, please find the report link below,

#5820
#6151

And it is resolved this issue in Xamarin.Forms version 4.2.0.815419. Please find the release notes below,

https://docs.microsoft.com/en-us/xamarin/xamarin-forms/release-notes/4.2/4.2.0-sr2

Unfortunately, after upgrading the Xamarin.Forms to v4.2.0.815419, we have encountered the following crash report in the application,

System.TypeLoadException: Could not load type of field 'Xamarin.Forms.Platform.Android.RendererPool:_freeRenderers' (0) due to: Could not resolve type with token 01000273 from typeref (expected class 'System.Collections.Generic.Stack1' in assembly
After further analysis, we found that it is an issue in Xamarin Forms Android platform in this particular version. Please find the bug report link below,

#7602

It is resolved again and now the first issue replicated again in the same scenario. Issue occurs in both 4.2.0.815419 and the latest stable version 4.4.0.991.

Please let me know if you have any concern

Regards,
Subburaj Pandian V

@samhouts samhouts removed 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. labels Dec 30, 2019
@samhouts samhouts moved this from Needs Info to New in Triage Dec 30, 2019
@PureWeen
Copy link
Contributor

@SubburajPandian I feel like there are a few overlapping things here and I don't think anything you are referencing is relevant to your issue.

#6151 is just making it so the dispose happen successfully

System.TypeLoadException: Could not load type of field 'Xamarin.Forms.Platform.Android.RendererPool:_freeRenderers' (0) due to: Could not resolve type with token 01000273 from typeref (expected class 'System.Collections.Generic.Stack1' in assembly

is only related to that particular build of our nuget
#7602

Renderer is not cleared from Xamarin.Forms.ScrollView even if we disposed the native object.

This is most likely due your control not properly setting up the hierarchy so that our code can navigate the children and detach the renderers.

All of our controls use a VisualElementPackager and then on dispose it iterates over the children and disposes of the renderers.

I'm not sure how your SfExpander is setup but it's on the control to iterate it's children and dispose of the renderers. The forms code can't just descend a hierarchy it doesn't understand

Triage automation moved this from New to Closed Dec 30, 2019
@samhouts samhouts removed this from Closed in Triage Jan 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often p/Android partner Issue submitted by partner or related open source project s/unverified New report that has yet to be verified t/bug 🐛
Projects
None yet
Development

No branches or pull requests

5 participants