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

Fix StorageUI Bug and Update demo usage for SDWebImgae integration #842

Merged
merged 6 commits into from
Mar 12, 2020

Conversation

dreampiggy
Copy link
Contributor

Hey there! So you want to contribute to FirebaseUI? Before you file this pull request, follow these steps:

  • Read the contribution guidelines.
  • If this has been discussed in an issue, make sure to mention the issue number here. If not, go file an issue about this to make sure this is a desirable change.
  • If this is a new feature please co-ordinate with someone on FirebaseUI-Android to make sure that we can implement this on both platforms and maintain feature parity.

Fix issues related StorageUI and SDWebImage, introduced in #841


1. The FIRStorage throw exception on passed url contains object path
2. The progress block may been called on main queue, should use another coder queue for decoding
3. The expectedSize should use URLResponse's info to check, but not the bodyLength

CC @morganchen12


1. The FIRStorage throw exception on passed url contains object path
2. The progress block may been called on main queue, should use another coder queue for decoding
3. The expectedSize should use URLResponse's info to check, but not the bodyLength
…, this can avoid blocking issue during massive image loading
… if queue is empty (to avoid too frequent callback), don't need to create AutoReleasePool as well
});
}];
// Each download task use independent serial coder queue, to ensure callback in order during prorgessive decoding
NSOperationQueue *coderQueue = [NSOperationQueue new];
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like a new coderQueue is allocated on each invocation of this method, but never retained anywhere. Is this intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like a new coderQueue is allocated on each invocation of this method, but never retained anywhere.

It retained in the below, the dataWithMaxSize:completion: block, here use coderQueue addOperationWithBlock:. And also, the progressive one. The block keep a strong reference to capture Objecitve-C object by default (unless you mark __weak).

Just use NSOperation to replace previous's GCD.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The NSOperationQueue lifetime is associated to the completion block, and the completion block lifetime is associated to FIRStorageDownloadTask. This implements the design I want : Each download task use independent serial coder queue

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or, if you think it's hard to find, we can change this into an associated object of FIRStorageDownloadTask, like

@interface FIRStorageDownloadTask (StorageUI)
@property (nonatomic) NSOperationQueue *coderQueue;
@end
@implementation FIRStorageDownloadTask (StorageUI)
- (NSOperationQueue *)coderQueue {
    NSOperationQueue *coderQueue = objc_getAsscoaitedObject(self, @selector(coderQueue));
    if (!coderQueue) {
        coderQueue = [NSOperationQueue new];
        coderQueue.maxConcurrentOperationCount = 1;
        objc_setAssociatedObject(self, @selector(coderQueue), coderQueue, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
    } 
    return coderQueue;
}
@end

But actually, they have the same effect...

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm ok with the way the code is, just wanted to clarify 👍

Copy link
Contributor

@morganchen12 morganchen12 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @dreampiggy!

@dreampiggy dreampiggy changed the title Fix storage ui bug and demo Fix StorageUI Bug and Update demo usage for SDWebImgae integration Mar 12, 2020
@dreampiggy
Copy link
Contributor Author

If you find there are no extra review suggestion to check, feel free to merge. :)

@dreampiggy
Copy link
Contributor Author

The Travis-CI failed bacause of CocoaPods repo update failed :(

@morganchen12 Can you update the Gemfile and CI to use new CocoaPods version ? At least v1.8.0, which introduce the CDN trunk instead of Spec repo. Which don't need to wasting time to git clone the https://github.com/CocoaPods/Specs. It use a CDN for HTTP download, 10x faster.

@morganchen12
Copy link
Contributor

Updated gems in #844.

@morganchen12
Copy link
Contributor

The changes look fine to me, I'll take care of fixing the build. Thanks @dreampiggy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants