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

LogCat messages: "Plugin should use CordovaInterface.getThreadPool()" #19

Closed
frell opened this issue Oct 24, 2013 · 8 comments
Closed
Assignees
Labels

Comments

@frell
Copy link

frell commented Oct 24, 2013

Hello,

Thanks for a great plugin.

I've noticed lots of these sorts of messages in my Logcat. All works fine, but think it could be causing some UI lag. Any suggestions?

THREAD WARNING: exec() call to BackgroundServicePlugin.getStatus blocked the main thread for 25ms. Plugin should use CordovaInterface.getThreadPool().

Phonegap v3.0
Android : 4.3

@Red-Folder
Copy link
Owner

I have seen this warning message before ... however I don't believe I can do any further work to improve it.

The code is already using getThreadPool and follows the pattern as described here (see the getThreadPool example) -> http://docs.phonegap.com/en/2.7.0/guide_plugin-development_android_index.md.html#Developing%20a%20Plugin%20on%20Android

If you look at the code within the source repository (https://github.com/Red-Folder/Cordova-Plugin-BackgroundService-Source/tree/master/src/com/red_folder/phonegap/plugin/backgroundservice). The difference is that the logic split into a separate class to allow it to be decorated with the appropriate interface.

I've possibly got something wrong in the threading logic - but I'm afraid I can't spot it. I'm open to suggestions.

@Red-Folder
Copy link
Owner

Having done some further research I wonder if it is related to the variables (used in the run) not being final.

See this article -> http://stackoverflow.com/questions/11424753/why-do-variables-passed-to-runnable-need-to-be-final

@Red-Folder
Copy link
Owner

I've tried some changes - but that's completely broken it ;)

I'll review the changes over the next couple of days .... but this "final" may well be a red herring.

@ghost ghost assigned Red-Folder Oct 29, 2013
@frell
Copy link
Author

frell commented Oct 29, 2013

Your efforts are very much appreciated.

Interesting, although a little over my head. The phonegap example does seem to point towards your point about final as the line before the getThreadPool() call is;

final long duration = args.getLong(0);

Im polling the getStatus regularly (5 second interval) from the UI. Maybe i need to reduce this to help work around the problem. Is there a better way to for the UI to be notified of new data from the service? I.e. having the service invoke somesort of callback to the UI when it has something to say, rather than the UI keeping polling a question.

@Red-Folder
Copy link
Owner

I have another issue raised (#17) which asks for the Plugin to push the latest results to the HTML/ JavaScript. When this is done, you should be able to remove the getStatus every 5 seconds.

I hope to get to that issue in the next couple of weeks.

@Red-Folder
Copy link
Owner

Just to update;

I've release the code for issue #17 - this means that you can register for updates rather than use setInterval. May help.

I will look at this issue again (the warning) - maybe in a week or two. I'd like to look at the repo/ Plugman work (#20) first.

@frell
Copy link
Author

frell commented Nov 18, 2013

Awesome. I'll test that out when i can get back onto that project

@Red-Folder
Copy link
Owner

Issue moved to Red-Folder/bgs-core#26

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

No branches or pull requests

2 participants