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

[Android] Don't dispose the _labelTextColorDefault on Label Fast Renderer #7163

Merged
merged 6 commits into from
Aug 16, 2019

Conversation

samhouts
Copy link
Contributor

Description of Change

#6467 disposes the _labelTextColorDefault on the fast LabelRenderer for Android. This causes a NullPointerException when attempting to access it later.

This does not happen on the legacy renderer, which now also has the same dispose but a slightly different pattern of setting the value. Using the same pattern does not fix the crash on the Fast Renderer, so the best thing is to remove the dispose and possibly revisit this later.

Issues Resolved

API Changes

None

Platforms Affected

  • Android

Behavioral/Visual Changes

Before/After Screenshots

Not applicable

Testing Procedure

There is an automated test with instructions.

PR Checklist

  • Has automated tests
  • Rebased on top of the target branch at time of PR
  • Changes adhere to coding standard

@samhouts samhouts added p/Android blocker Issue blocks next stable release. Prioritize fixing and reviewing this issue. i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often i/regression t/bug 🐛 labels Aug 15, 2019
@hartez
Copy link
Contributor

hartez commented Aug 16, 2019

The old-style renderer shouldn't be disposing of this value, either, but we're getting away with it because of the container.

possibly revisit this later
I don't think we need to; it's unlikely that an extra reference to a member of the same class is causing a leak.

@kvpt
Copy link
Contributor

kvpt commented Aug 16, 2019

@samhouts I tested your reproduction, thanks for doing that, I confirm that removing the dispose labelTextColorDefault fix the issue.
But I think this reveal that something is broken somewhere else.
The only way, for me, that the dispose can cause this issue is a race condition between dispose method and OnElementPropertyChanged event handler. Now that the unsubscribing of the handler is at the beginning of the method the probability that this occur is greatly reduced.
To confirm that it's not the issue here, I used a ManualResetEventSlim to prevent that, it not fix the crash so it's confirm that it's not the cause.

So I made some more testing after that, and found that removing the Trigger make the crash disappear.
Other thing really weird, you can test it easily, on your test case, the label dispose (so the method fixed here) is only called once, and on the top label.
So if the crash happen, it's implied that the UpdateColor is called on the top label and this label doesn't have trigger either, so how removing them fix the issue is really weird.
Other question, why the top label is disposed in the first place ? at this time, it make no sense.

From the stacktrace it's cause by :


If I remove it no more crash, and if I navigate back the dispose is called, so I don't know if it a right thing or not.
Is the label rendered need to be destroyed and recreated if you do that ?

stackLayout.Children.Remove(instructions);
stackLayout.Children.Insert(0, instructions);

Actually it's the case.

It will need some more in depth testing.

@samhouts samhouts added the approved Has two approvals, no pending reviews, and no changes requested label Aug 16, 2019
@samhouts
Copy link
Contributor Author

@kvpt @hartez I agree with both of your assessments. This was a strange crash to me. Thanks!

@samhouts
Copy link
Contributor Author

Failing tests don't look related. Also can't repro locally.

@PureWeen
Copy link
Contributor

PureWeen commented Aug 16, 2019

Yea the Android failure is one I see randomly with Android tests :-/ It seems like the UI test runner just crashes for some reason. I have an issue logged here for it microsoft/appcenter#893

Similarly with the CollectionView on iOS for some reason it fails to navigate to the test and it just gets stuck on the screen listing the tests

@samhouts samhouts merged commit be9b43f into 4.2.0 Aug 16, 2019
@samhouts samhouts deleted the fix-6994 branch August 16, 2019 16:46
@samhouts samhouts added this to the 4.2.0 milestone Aug 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Has two approvals, no pending reviews, and no changes requested blocker Issue blocks next stable release. Prioritize fixing and reviewing this issue. i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often i/regression p/Android t/bug 🐛
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants