-
Notifications
You must be signed in to change notification settings - Fork 424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes Snackbar and Toast on iOS release builds #1767
Conversation
@dotnet-policy-service agree
… On Mar 20, 2024, at 12:28 PM, dotnet-policy-service[bot] ***@***.***> wrote:
@mjo151 <https://github.com/mjo151> please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
@dotnet-policy-service agree [company="{your company}"]
Options:
(default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@dotnet-policy-service agree
(when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@dotnet-policy-service agree company="Microsoft"
Contributor License Agreement
<http://www.opensource.org/>
—
Reply to this email directly, view it on GitHub <#1767 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AA5A5TIJY5OROZDNWTTEDULYZG2LVAVCNFSM6AAAAABE72DVKKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMBZHE4TENRQHE>.
You are receiving this because you were mentioned.
|
Thanks @mjo151. However, this doesn't fix the the two root causes:
I think the best path forward for us on the Toolkit team is the following:
|
@brminnick This PR does fix the root cause of the crash on iOS, which is the use of FrozenSet in the AlertView. The AlertView is used by Snackback and Toast. As you can see from the changes in my PR, the use of FrozenSet is completely unnecessary in this case. I don't think it makes sense to force users to enable the interpreter, which has other implications, when this problem can simply be fixed by removing the use of FrozenSet. |
I understand that. This is a workaround to a bug in the .NET Runtime and in the Mono Interpreter. It also includes a breaking change to our public API surface. |
I agree that not being able to use System.Collections.Immutable appears to be a bug in the .NET Runtime and/or the mono AOT compiler. This PR does "workaround" that bug by not using System.Collections.Immutable. However, use of System.Collections.Immutable here was unnecessary anyway and also had negative performance implications on the code. For various reasons, I am not able to enable the Mono Interpreter for my project. It's very unfortunate if that will be the stance for fixing issues moving forward, especially when there are other options. I really hope you review and consider this PR for integration into the community toolkit. I've been very happy with the toolkit so far, but if using Snackbar and Toast will require enabling the interpreter (e.g. this PR doesn't get approved), I will have to migrate away from using the toolkit. |
OK, I understand the issue with breaking the public API. I just pushed another commit that reverts the breaking change to the public API. It still resolves the crash when displaying Snackbar and Toast. |
foreach (var view in Children) | ||
foreach (var view in children) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this cause issues if the collection changes during this loop? Before it was a copy, now it is the actual collection and IEnumerable throws if you change it while it is iterating.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a possibility, but the likelihood is slim.
As Vlad pointed out in our standup today, Snackbar + Toast typically only contain 2-3 children, so enumerating through the list should be very quick. The odds of the List
being modified during enumeration are very low.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prior to this change, the foreach loop accessed the Children property, which calls children.ToFrozenSet(). ToFrozenSet() has to iterate over the collection.
In either case, AlertView is a UI control and should only ever be modified on the UI thread. If another thread is adding children to the view, that's a bug in the consumer of AlertView.
Is there a chance we get a hotfix release for this soon? Or maybe a preview release? |
I would like this also, and when could it be released? I can't use pre releases in production env. |
Description of Change
Fixes Snackbar and Toast on iOS release builds
Linked Issues
PR Checklist
approved
(bug) orChampioned
(feature/proposal)main
at time of PRAdditional information
Removed the use of FrozenSet in the iOS AlertView. FrozenSet was causing the crash on iOS release builds, and it also adds unnecessary overhead when initializing the AlertView.