Skip to content
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

[iOS] Fixed the Application crash when ToolbarItem is created with invalid IconImageSource name #27175

Merged
merged 1 commit into from
Feb 17, 2025

Conversation

Ahamed-Ali
Copy link
Contributor

@Ahamed-Ali Ahamed-Ali commented Jan 16, 2025

Root Cause of the issue

  • The exception is thrown from FileImageSourceService.iOS when the image is null, causing the application to crash if an invalid IconImageSource is provided.

Description of Change

  • Instead of throwing an exception, log the exception details and safely return to prevent the application from crashing when an invalid IconImageSource is provided.

Reference

Issues Fixed

Fixes #27095

Tested the behaviour in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Screenshot

Before Issue Fix After Issue Fix
WithCrash.mov
FixedWithouCrash.mov

Sorry, something went wrong.

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Jan 16, 2025
Copy link
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.

@sheiksyedm sheiksyedm added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Jan 16, 2025
@Ahamed-Ali Ahamed-Ali marked this pull request as ready for review January 16, 2025 10:43
@Ahamed-Ali Ahamed-Ali requested a review from a team as a code owner January 16, 2025 10:43
@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jsuarezruiz
Copy link
Contributor

/rebase

@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens on other platforms? Based on the test, guess not throwing an exception, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An exception is not thrown on other platforms when an invalid IconImageSource name is provided @jsuarezruiz

@@ -41,7 +41,7 @@ public partial class FileImageSourceService
{
Logger?.LogWarning(ex, "Unable to load image file '{File}'.", imageSource.File);

throw;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattleibow I understand that throwing the exception at this point was a expected behavior, right?

@@ -41,7 +41,7 @@ public partial class FileImageSourceService
{
Logger?.LogWarning(ex, "Unable to load image file '{File}'.", imageSource.File);

throw;
return FromResult(null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on https://github.com/dotnet/maui/pull/27175/files#r1939317042
This align the behavior between platforms. LGTM.

@rmarinho rmarinho merged commit 325e19c into dotnet:main Feb 17, 2025
320 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Mar 20, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[iOS] Application crashes when ToolbarItem is created with invalid IconImageSource name
6 participants