[iOS] Fixed the Application crash when ToolbarItem is created with invalid IconImageSource name#27175
Merged
rmarinho merged 1 commit intodotnet:mainfrom Feb 17, 2025
Merged
Conversation
Contributor
|
Hey there @Ahamed-Ali! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
Contributor
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
Contributor
|
/rebase |
94a6964 to
b20c542
Compare
Contributor
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
jsuarezruiz
reviewed
Jan 31, 2025
| @@ -1,5 +1,4 @@ | |||
| #if TEST_FAILS_ON_IOS //Application crashes when ToolbarItem is created with invalid IconImageSource name.Issue Link: https://github.com/dotnet/maui/issues/27095 | |||
| using NUnit.Framework; | |||
| using NUnit.Framework; | |||
Contributor
There was a problem hiding this comment.
What happens on other platforms? Based on the test, guess not throwing an exception, right?
Contributor
Author
There was a problem hiding this comment.
An exception is not thrown on other platforms when an invalid IconImageSource name is provided @jsuarezruiz
| { | ||
| Logger?.LogWarning(ex, "Unable to load image file '{File}'.", imageSource.File); | ||
|
|
||
| throw; |
Contributor
There was a problem hiding this comment.
@mattleibow I understand that throwing the exception at this point was a expected behavior, right?
jsuarezruiz
approved these changes
Feb 17, 2025
| Logger?.LogWarning(ex, "Unable to load image file '{File}'.", imageSource.File); | ||
|
|
||
| throw; | ||
| return FromResult(null); |
Contributor
There was a problem hiding this comment.
Based on https://github.com/dotnet/maui/pull/27175/files#r1939317042
This align the behavior between platforms. LGTM.
rmarinho
approved these changes
Feb 17, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root Cause of the issue
FileImageSourceService.iOSwhen the image is null, causing the application to crash if an invalid IconImageSource is provided.Description of Change
Reference
https://github.com/xamarin/Xamarin.Forms/blob/5.0.0/Xamarin.Forms.Platform.MacOS/ImageSourceHandlers.cs#L19
Issues Fixed
Fixes #27095
Tested the behaviour in the following platforms
Screenshot
WithCrash.mov
FixedWithouCrash.mov