fix(FirebaseStorageUI): prevent crash with .progressiveLoad on Firebase Storage 9+#1352
fix(FirebaseStorageUI): prevent crash with .progressiveLoad on Firebase Storage 9+#1352demolaf wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors FirebaseStorage imports and declarations to support Swift Package Manager (SPM) builds and avoid Clang module-scanner failures. It replaces @import FirebaseStorage with forward declarations in public headers and moves the actual imports and category declarations to implementation files. Additionally, it guards progressive decoding in FUIStorageImageLoader.m to prevent crashes on Firebase Storage 9+ where the internal GTMSessionFetcher was removed. Feedback suggests avoiding performSelector: in FUIStorageImageLoader.m to prevent ARC compiler warnings, recommending direct property access to task.fetcher instead, since the property is already declared in the class extension.
| if ([task respondsToSelector:@selector(fetcher)]) { | ||
| GTMSessionFetcher *fetcher = [task performSelector:@selector(fetcher)]; |
There was a problem hiding this comment.
Using performSelector: under ARC can trigger a compiler warning (-Warc-performSelector-leaks) because the compiler cannot statically verify the selector's memory management behavior.
Since fetcher is already declared in the class extension of FIRStorageTask (which FIRStorageDownloadTask inherits from) on line 45 of this file, the compiler is fully aware of the fetcher property. Therefore, you can safely access task.fetcher directly once you have guarded it with respondsToSelector:. This is cleaner, type-safe, and avoids any potential compiler warnings.
if ([task respondsToSelector:@selector(fetcher)]) {
GTMSessionFetcher *fetcher = task.fetcher;
FIRStorageDownloadTask.fetcherwas an internal property removed in Firebase Storage 9.0.0. Accessing it via the progress observer caused a crash when.progressiveLoadwas passed as an option.Guard with
respondsToSelector:so the progressive decode path is skipped on Firebase 9+. Images still load to completion — only the in-flight progressive rendering is lost, since Firebase no longer exposes partial download data publicly.Closes #1146
Closes #1114