Removed the try catch block of animation enabled check by providing default value to avoid the exception occurs while triggering FirstChanceException of MAUI App #255
+3
−10
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.
Bug Description
Chart rendering throws exceptions on Android devices related to animation settings. This occurs when Developer Options have never been enabled, making animation scale settings inaccessible.
Discussion link: #221
Root Cause of the Issue
The exception was caused by attempting to retrieve the animation scale setting using Settings.Global.GetFloat, which fails if Developer Options were never enabled. This results in a FirstChanceException being logged even though the exception is handled.
Description of Change
To avoid unnecessary exception logging during chart rendering, we replaced the try-catch block with a direct call to Settings.Global.GetFloat using a default value. This ensures smooth behavior even when Developer Options are disabled. The chart now renders with or without animation based on the retrieved scale value, without triggering exceptions.
Screenshots
Before:
After:
Here SettingsNotFound Exception does not occur in the console while triggering the FirstChanceException
Device Name: Redmi Note 11 Pro 5G
With Animator duration Scale as 1.5x
With Animator duration Scale as off
Here SettingsNotFound Exception does not occur in the console while triggering the FirstChanceException
Test cases