-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[flutter_image] Fix : network image memory and nullsafety #8440
base: main
Are you sure you want to change the base?
[flutter_image] Fix : network image memory and nullsafety #8440
Conversation
…ovements - Added a static `dispose` method to close the HTTP client used for image fetching, preventing potential resource leaks. - Improved code formatting and consistency in the constructor and method signatures. - Introduced a maximum size limit for the `_Uint8ListBuilder` to handle large responses more effectively. - Updated error handling to provide clearer messages for fetch failures. These changes enhance the reliability and maintainability of the image loading functionality.
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). 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. 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. |
- Bump minimum supported SDK version to Flutter 3.22/Dart 3.4. - Introduce `dispose()` method for proper HTTP client resource management. - Implement a 50MB memory usage limit in `_Uint8ListBuilder` to optimize memory allocation. - Enhance null safety handling in HTTP request headers. - Improve error messages for empty responses and failed requests. - Update documentation to align with the latest HTTP RFC. These changes enhance the reliability and performance of the image loading functionality.
Thanks for the contribution! I'm marking this as a draft pending completion of the checklist; please mark the PR as ready for review once all of the elements of the checklist are complete. When filing the issue, please be sure to include a clear and detailed description of the memory issue you are trying to address, since currently this PR introduces a (incorrectly versioned) breaking change without a clearly described motivation. |
Thank you for the feedback! I’ve completed the checklist, updated the PR description with a detailed explanation of the memory issue being addressed, and reviewed the versioning to align with the changes introduced. The PR is now ready for review. Please let me know if there’s anything else you'd like me to address! |
7884eb0
to
c894e35
Compare
c894e35
to
04ae85f
Compare
The memory issue arises from _Uint8ListBuilder allocating memory without a defined limit. In scenarios where large or continuous data streams are handled, this can result in excessive memory usage, leading to degraded performance or out-of-memory errors, especially on devices with limited resources.
To address this, the PR introduces a memory usage limit of 50MB. This ensures:
Controlled memory allocation, preventing _Uint8ListBuilder from exceeding reasonable thresholds.
Improved app stability and responsiveness, particularly on low-memory devices or environments with heavy workloads.
Protection against unintended memory leaks or inefficient resource usage.
This change aligns with the broader goal of improving resource management in the flutter_image package, alongside the newly added dispose() method, which cleans up HTTP client resources to prevent potential leaks.
Let me know if further clarification is needed or if you'd like specific examples illustrating the issue!
dispose()
method to properly clean up HTTP client resources._Uint8ListBuilder
.Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style, or this PR is exempt from CHANGELOG changes.///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.