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

threadhelper also for copyTo and remove actions #240

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

paolosanchi
Copy link

@paolosanchi paolosanchi commented Feb 26, 2021

In Android, I experienced that "copyTo" and "remove" can take several seconds (i verified at least 16 secs) to execute, and during the execution the UI is blocked. This is very bad for background and custom update mode.
I set up for them the "threadhelper" (aka cordova.getThreadPool().execute()), just like it was made for "downloadFile", and it works perfectly without blocking the UI.

Maybe there is a way to do it more "globally" for all the action, however now it works really good.

@paolosanchi
Copy link
Author

Can you please check this out?

@ramikhafagi96
Copy link

@ltm @nphyatt can you guys check this PR and see if it's helpful, because the copyTo method takes a lot of time on older android devices and blocks the main UI thread

@paolosanchi
Copy link
Author

paolosanchi commented Oct 27, 2022

I actually found an issue: the variable passed in copyTo() and remove() shuld be changed from callbackContext to cbcontext.
I'm not sure if it changes anything, but it shuold worth to fix it.

@ingageco
Copy link

ingageco commented Jan 31, 2023

@paolosanchi Why would it need to be changed? The reference in the method definition is callbackContext

@ramikhafagi96
Copy link

@ingageco I don't think actually this is the main problem, the method copyTo runs on the main thread and cause the app to hang and doesn't process any user interactions and cause ANR eventually, the PR is running the method in a background thread, if this is valid it should be merged

@paolosanchi
Copy link
Author

paolosanchi commented Feb 7, 2023

@paolosanchi Why would it need to be changed? The reference in the method definition is callbackContext

just because in "downloadFile" the parameter is declared as "cbcontext" instead of "callbackContext". I missed the real meaning, I'm not really into Java and I forgot the inline override thing.
So I guess, it's totally the same.

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.

3 participants