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

Prevent UI thread from blocking during batch upload #241

Merged

Conversation

roostr
Copy link
Contributor

@roostr roostr commented Feb 26, 2019

The batchUploadFiles call does not report back a response until all uploads are completed. To do this, it calls sleep(1) while it waits for:

  1. everything to finish,
  2. a cancel request, or
  3. all uploads to finish.

The calls to sleep(1) are made inside a setResponseBlock handler that is not passed a queue parameter. Because the queue isn't specified, it runs on the main thread. This causes apps that call this function to freeze on their main thread for a second.

This patch makes a dedicated NSOperationQueue for monitoring the progress.

@greg-db
Copy link
Contributor

greg-db commented Feb 26, 2019

Thanks for putting this together!

@guidedways
Copy link

This was reported as a bug a long time ago: #221

@roostr roostr force-pushed the fix/batch-upload-blocks-main-thread branch from 284a20f to 454c368 Compare June 25, 2019 18:42
@roostr
Copy link
Contributor Author

roostr commented Jun 25, 2019

Updated to be rebased onto the latest master.

The `batchUploadFiles` call does not report back a response
until all uploads are completed. To do this, it calls sleep(1)
while it waits for (1) everything to finish, (2) a cancel request,
or (3) all uploads to finish.

The calls to sleep(1) are made inside a `setResponseBlock` handler
that is not passed a `queue` parameter. Because the queue isn't
specified, it runs on the main thread. This causes apps that call
this function to freeze on their main thread for a second.

This patch makes a dedicated NSOperationQueue for monitoring the
progress.
@roostr roostr force-pushed the fix/batch-upload-blocks-main-thread branch from 454c368 to 6f32fb3 Compare November 12, 2019 21:55
Copy link
Contributor

@hector-dropbox hector-dropbox left a comment

Choose a reason for hiding this comment

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

This is fairly simple and makes total sense. Thanks for putting this together @roostr! I'm sorry it took so long but like I mentioned in the issue I just started with Dropbox so I'm getting a bunch of stuff together. I won't be owning this SDK at the moment but I was the last one in the codebase. I'm happy to help elsewhere when I can!

@hector-dropbox hector-dropbox merged commit 9c10d0e into dropbox:master Apr 16, 2020
@roostr
Copy link
Contributor Author

roostr commented Apr 16, 2020

Thank you, @hector-dropbox!

@hector-dropbox
Copy link
Contributor

@roostr Of course! Thanks for putting in the work to figure it out to begin with!

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

Successfully merging this pull request may close these issues.

4 participants