Skip to content

[vector_graphics]Add Null Check for Image Retrieval in listener.dart's onDrawImage Function #9211

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

Merged
merged 22 commits into from
Jun 10, 2025

Conversation

wyqlxf
Copy link
Contributor

@wyqlxf wyqlxf commented May 6, 2025

This PR adds error handling for #168364

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

…error messages, and enhance the robustness and maintainability of the code.
@wyqlxf wyqlxf requested a review from jonahwilliams as a code owner May 6, 2025 10:21
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@wyqlxf
Copy link
Contributor Author

wyqlxf commented May 6, 2025

This change is exempt from additional testing as it does not alter any existing functionality.

@stuartmorgan-g
Copy link
Contributor

Thanks for the submission!

In the future, please do not delete things from the checklist that is in the PR template; they are there for a reason. This PR is missing required elements described in the checklist (I’ve restored the missing parts to the PR description), which need to be addressed before it moves forward with review.

I am marking the PR as a Draft. Please review the checklist, updating the PR as appropriate, and when that’s complete please feel free to mark the PR as ready for review.

This change is exempt from additional testing as it does not alter any existing functionality.

Could you quote the part of the linked documentation about the test requirement that led you to believe that bugfixes are exempt from testing?

@stuartmorgan-g stuartmorgan-g marked this pull request as draft May 6, 2025 19:56
wangyongqi added 3 commits May 7, 2025 09:29
…ages.

- Ensure validity checks are performed before accessing images.
- Provide informative error messages for better debugging.
- Improve code robustness and maintainability.
@wyqlxf
Copy link
Contributor Author

wyqlxf commented May 7, 2025

@stuartmorgan-g
I have reviewed the checklist and made the necessary updates as requested, including the addition of the required unit tests to ensure compliance with the testing standards.

@wyqlxf wyqlxf marked this pull request as ready for review May 8, 2025 01:32
@wyqlxf
Copy link
Contributor Author

wyqlxf commented May 19, 2025

@stuartmorgan-g @jonahwilliams There’s a PR that has been forgotten on a mysterious branch. Come rescue it!

Copy link
Member

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

LGTM

wangyongqi added 2 commits May 22, 2025 09:16
# Conflicts:
#	packages/vector_graphics/CHANGELOG.md
# Conflicts:
#	packages/vector_graphics/CHANGELOG.md
@wyqlxf
Copy link
Contributor Author

wyqlxf commented Jun 9, 2025

@domesticmouse hi, could you please take a moment to review my PR?

Copy link
Contributor

@domesticmouse domesticmouse left a comment

Choose a reason for hiding this comment

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

Please reply to review questions.

Copy link
Contributor Author

@wyqlxf wyqlxf left a comment

Choose a reason for hiding this comment

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

Regarding the cause of the image decoding failure, I believe the issue may lie within the onImage method. If an error occurs while loading the image, _images[imageId] might not be assigned a value. This can lead to a null error when we subsequently attempt to access that value.

To address this issue, I recommend adding a null check for _images[imageId] in the drawing logic. This will allow us to gracefully handle situations where the image fails to load, preventing the application from crashing and enhancing overall stability.

In the unit test, we verify that when attempting to draw an image with an invalid imageId, the program correctly throws an assertion error. This helps developers identify potential issues early during the debugging phase, thereby enhancing the reliability and maintainability of the code.

@domesticmouse
Copy link
Contributor

@jonahwilliams should I just land this, or is there an auto land process for this repo?

@jonahwilliams
Copy link
Member

Uh I dunno, let's try autosub label

@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 10, 2025
@auto-submit auto-submit bot merged commit 2930e20 into flutter:main Jun 10, 2025
80 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 10, 2025
@wyqlxf wyqlxf deleted the fix_168364 branch June 11, 2025 01:07
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 11, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 11, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 11, 2025
github-merge-queue bot pushed a commit to flutter/flutter that referenced this pull request Jun 11, 2025
flutter/packages@974f152...0b322a2

2025-06-11 stuartmorgan@google.com Roll Flutter master to 2d9977c
(flutter/packages#9402)
2025-06-11 stuartmorgan@google.com [google_maps_flutter] Fix iOS
analysis for newer Xcode (flutter/packages#9415)
2025-06-10 shaunpanjabi@gmail.com [in_app_purchase] Return
jwsRepresentation and jsonRepresentation for StoreKit2
(flutter/packages#9280)
2025-06-10 stuartmorgan@google.com Roll Flutter master to 7e30df2
(flutter/packages#9413)
2025-06-10 42757204+wyqlxf@users.noreply.github.com [vector_graphics]Add
Null Check for Image Retrieval in listener.dart's onDrawImage Function
(flutter/packages#9211)
2025-06-10 stuartmorgan@google.com Roll Flutter master to 8b22f67
(flutter/packages#9407)
2025-06-06 stuartmorgan@google.com Roll Flutter master to d8baa77
(flutter/packages#9379)
2025-06-06 ybz975218925@gmail.com Fix the `zIndex`-related issue in the
`copyWith` method. (flutter/packages#9396)
2025-06-06 katelovett@google.com [multi] Remove @tool from docs that
does not work (flutter/packages#9394)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC flutter-ecosystem@google.com on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App p: vector_graphics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants