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

Functions blocking main thread frequently #22

Open
galenthomasramos opened this issue Apr 1, 2014 · 6 comments
Open

Functions blocking main thread frequently #22

galenthomasramos opened this issue Apr 1, 2014 · 6 comments

Comments

@galenthomasramos
Copy link

From my logcat when trying to call any js scheduler function:

when trying to cancel alarms:

  03-31 21:04:00.301: I/Web Console(10218): ----------------------------------------------- Alarm:2 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.301: I/Web Console(10218): ----------------------------------------------- Alarm:3 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.301: I/Web Console(10218): ----------------------------------------------- Alarm:4 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.311: I/Web Console(10218): ----------------------------------------------- Alarm:5 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.311: I/Web Console(10218): ----------------------------------------------- Alarm:6 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.321: I/Web Console(10218): ----------------------------------------------- Alarm:7 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.331: I/Web Console(10218): ----------------------------------------------- Alarm:9 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.331: I/Web Console(10218): ----------------------------------------------- Alarm:10 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.341: I/Web Console(10218): ----------------------------------------------- Alarm:12 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.351: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.cancelAlarm blocked the main thread for 18ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:00.351: I/Web Console(10218): ----------------------------------------------- Alarm:13 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.371: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.cancelAlarm blocked the main thread for 18ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:00.371: I/Web Console(10218): ----------------------------------------------- Alarm:14 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.391: I/Web Console(10218): ----------------------------------------------- Alarm:15 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.391: I/Web Console(10218): ----------------------------------------------- Alarm:19 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.421: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.cancelAlarm blocked the main thread for 25ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:00.421: I/Web Console(10218): ----------------------------------------------- Alarm:18 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.421: I/Web Console(10218): ----------------------------------------------- Alarm:21 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.431: I/Web Console(10218): ----------------------------------------------- Alarm:20 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.461: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.cancelAlarm blocked the main thread for 34ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:00.471: I/Web Console(10218): ----------------------------------------------- Alarm:22 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.492: I/Web Console(10218): ----------------------------------------------- Alarm:25 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.512: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.cancelAlarm blocked the main thread for 30ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:00.512: I/Web Console(10218): ----------------------------------------------- Alarm:24 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.532: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.cancelAlarm blocked the main thread for 23ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:00.542: I/Web Console(10218): ----------------------------------------------- Alarm:27 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.542: I/Web Console(10218): ----------------------------------------------- Alarm:29 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.562: I/Web Console(10218): ----------------------------------------------- Alarm:28 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.572: I/Web Console(10218): ----------------------------------------------- Alarm:31 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.642: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.cancelAlarm blocked the main thread for 67ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:00.642: I/Web Console(10218): ----------------------------------------------- Alarm:30 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.732: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.cancelAlarm blocked the main thread for 89ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:00.732: I/Web Console(10218): ----------------------------------------------- Alarm:34 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.752: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.cancelAlarm blocked the main thread for 21ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:00.762: I/Web Console(10218): ----------------------------------------------- Alarm:35 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.792: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.cancelAlarm blocked the main thread for 41ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:00.792: I/Web Console(10218): ----------------------------------------------- Alarm:32 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.822: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.cancelAlarm blocked the main thread for 23ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:00.822: I/Web Console(10218): ----------------------------------------------- Alarm:33 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.902: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.cancelAlarm blocked the main thread for 80ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:00.902: I/Web Console(10218): ----------------------------------------------- Alarm:38 at file:///android_asset/www/index.html:1413
    03-31 21:04:00.932: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.cancelAlarm blocked the main thread for 24ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:00.942: I/Web Console(10218): ----------------------------------------------- Alarm:39 at file:///android_asset/www/index.html:1413
    03-31 21:04:01.002: I/Web Console(10218): ----------------------------------------------- Alarm:36 at file:///android_asset/www/index.html:1413
    03-31 21:04:01.062: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.cancelAlarm blocked the main thread for 61ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:01.102: I/Web Console(10218): ----------------------------------------------- Alarm:42 at file:///android_asset/www/index.html:1413
    03-31 21:04:01.112: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.cancelAlarm blocked the main thread for 46ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:01.132: I/Web Console(10218): ----------------------------------------------- Alarm:43 at file:///android_asset/www/index.html:1413
    03-31 21:04:01.222: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.cancelAlarm blocked the main thread for 105ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:01.322: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.cancelAlarm blocked the main thread for 46ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:01.342: I/Web Console(10218): ----------------------------------------------- Alarm:40 at file:///android_asset/www/index.html:1413
    03-31 21:04:01.352: I/Web Console(10218): ----------------------------------------------- Alarm:41 at file:///android_asset/www/index.html:1413
    03-31 21:04:01.412: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.cancelAlarm blocked the main thread for 85ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:01.453: I/Web Console(10218): ----------------------------------------------- Alarm:44 at file:///android_asset/www/index.html:1413
    03-31 21:04:01.453: I/Web Console(10218): ----------------------------------------------- Alarm:45 at file:///android_asset/www/index.html:1413

When trying to add alarms:

    03-31 21:04:03.615: I/Web Console(10218): added alarm to fire @Mar 31, 9:16 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:03.675: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.addAlarm blocked the main thread for 21ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:03.755: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.addAlarm blocked the main thread for 69ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:03.875: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.addAlarm blocked the main thread for 39ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:03.905: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.addAlarm blocked the main thread for 24ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:03.945: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.addAlarm blocked the main thread for 26ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:03.995: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.addAlarm blocked the main thread for 52ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:03.995: I/Web Console(10218): added alarm to fire @Mar 31, 9:48 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:04.055: I/Web Console(10218): added alarm to fire @Mar 31, 10:12 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:04.095: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.addAlarm blocked the main thread for 33ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:04.145: I/Web Console(10218): added alarm to fire @Mar 31, 10:56 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:04.175: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.addAlarm blocked the main thread for 40ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:04.236: I/Web Console(10218): added alarm to fire @Mar 31, 11:15 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:04.356: I/Web Console(10218): added alarm to fire @Apr 1, 1:49 am at file:///android_asset/www/index.html:4134
            03-31 21:04:04.386: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.addAlarm blocked the main thread for 24ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:04.396: I/Web Console(10218): added alarm to fire @Mar 31, 11:38 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:04.426: I/Web Console(10218): added alarm to fire @Apr 1, 1:13 am at file:///android_asset/www/index.html:4134
            03-31 21:04:04.446: I/Web Console(10218): added alarm to fire @Apr 1, 12:22 am at file:///android_asset/www/index.html:4134
            03-31 21:04:04.506: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.addAlarm blocked the main thread for 56ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:04.516: I/Web Console(10218): added alarm to fire @Apr 1, 12:47 am at file:///android_asset/www/index.html:4134
            03-31 21:04:04.526: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.addAlarm blocked the main thread for 22ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:04.526: I/Web Console(10218): added alarm to fire @Apr 1, 3:16 am at file:///android_asset/www/index.html:4134
            03-31 21:04:04.586: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.addAlarm blocked the main thread for 25ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:04.586: I/Web Console(10218): added alarm to fire @Apr 1, 2:38 am at file:///android_asset/www/index.html:4134
            03-31 21:04:04.606: I/Web Console(10218): added alarm to fire @Apr 1, 2:11 am at file:///android_asset/www/index.html:4134
            03-31 21:04:04.676: I/Web Console(10218): added alarm to fire @Apr 1, 4:39 am at file:///android_asset/www/index.html:4134
            03-31 21:04:04.706: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.addAlarm blocked the main thread for 36ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:04.716: I/Web Console(10218): added alarm to fire @Apr 1, 4:07 am at file:///android_asset/www/index.html:4134
            03-31 21:04:04.756: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.addAlarm blocked the main thread for 26ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:04.756: I/Web Console(10218): added alarm to fire @Apr 1, 6:25 am at file:///android_asset/www/index.html:4134
            03-31 21:04:04.766: I/Web Console(10218): added alarm to fire @Apr 1, 6:52 am at file:///android_asset/www/index.html:4134
            03-31 21:04:04.776: I/Web Console(10218): added alarm to fire @Apr 1, 4:55 am at file:///android_asset/www/index.html:4134
            03-31 21:04:04.816: I/Web Console(10218): added alarm to fire @Apr 1, 5:25 am at file:///android_asset/www/index.html:4134
            03-31 21:04:04.856: I/Web Console(10218): added alarm to fire @Apr 1, 6:00 am at file:///android_asset/www/index.html:4134
            03-31 21:04:04.896: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.addAlarm blocked the main thread for 54ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:04.946: I/Web Console(10218): added alarm to fire @Apr 1, 3:45 am at file:///android_asset/www/index.html:4134
            03-31 21:04:04.956: I/Web Console(10218): added alarm to fire @Apr 1, 8:35 am at file:///android_asset/www/index.html:4134
            03-31 21:04:05.046: I/Web Console(10218): added alarm to fire @Apr 1, 7:16 am at file:///android_asset/www/index.html:4134
            03-31 21:04:05.046: I/Web Console(10218): added alarm to fire @Apr 1, 7:49 am at file:///android_asset/www/index.html:4134
            03-31 21:04:05.076: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.addAlarm blocked the main thread for 22ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:05.076: I/Web Console(10218): added alarm to fire @Apr 1, 9:04 am at file:///android_asset/www/index.html:4134
            03-31 21:04:05.096: I/Web Console(10218): added alarm to fire @Apr 1, 10:22 am at file:///android_asset/www/index.html:4134
            03-31 21:04:05.136: I/Web Console(10218): added alarm to fire @Apr 1, 9:39 am at file:///android_asset/www/index.html:4134
            03-31 21:04:05.166: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.addAlarm blocked the main thread for 45ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:05.207: I/Web Console(10218): added alarm to fire @Apr 1, 9:09 am at file:///android_asset/www/index.html:4134
            03-31 21:04:05.207: I/Web Console(10218): added alarm to fire @Apr 1, 10:53 am at file:///android_asset/www/index.html:4134
            03-31 21:04:05.257: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.addAlarm blocked the main thread for 56ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:05.257: I/Web Console(10218): added alarm to fire @Apr 1, 11:09 am at file:///android_asset/www/index.html:4134
            03-31 21:04:05.257: I/Web Console(10218): added alarm to fire @Apr 1, 12:38 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:05.287: I/Web Console(10218): added alarm to fire @Apr 1, 11:42 am at file:///android_asset/www/index.html:4134
            03-31 21:04:05.297: I/Web Console(10218): added alarm to fire @Apr 1, 1:16 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:05.357: I/Web Console(10218): added alarm to fire @Apr 1, 1:52 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:05.357: I/Web Console(10218): added alarm to fire @Apr 1, 2:31 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:05.567: I/Web Console(10218): added alarm to fire @Apr 1, 12:04 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:05.597: I/Web Console(10218): added alarm to fire @Apr 1, 3:26 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:05.597: I/Web Console(10218): added alarm to fire @Apr 1, 3:10 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:05.597: I/Web Console(10218): added alarm to fire @Apr 1, 2:19 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:05.607: I/Web Console(10218): added alarm to fire @Apr 1, 4:08 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:05.607: I/Web Console(10218): added alarm to fire @Apr 1, 5:12 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:05.607: I/Web Console(10218): added alarm to fire @Apr 1, 6:38 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:05.617: I/Web Console(10218): added alarm to fire @Apr 1, 4:21 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:05.647: I/Web Console(10218): added alarm to fire @Apr 1, 5:57 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:05.647: I/Web Console(10218): added alarm to fire @Apr 1, 5:38 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:05.647: I/Web Console(10218): added alarm to fire @Apr 1, 6:52 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:05.647: I/Web Console(10218): added alarm to fire @Apr 1, 8:31 pm at file:///android_asset/www/index.html:4134
            03-31 21:04:05.647: I/Web Console(10218): alarmCount: 56 at file:///android_asset/www/index.html:1543

When trying to getAlarms():

    03-31 21:04:01.463: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.getAlarms blocked the main thread for 20ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:01.493: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.getAlarms blocked the main thread for 17ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:02.033: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.getAlarms blocked the main thread for 47ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:02.343: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:02.414: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.getAlarms blocked the main thread for 49ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:02.504: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:02.664: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.getAlarms blocked the main thread for 163ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:02.794: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:02.864: W/PluginManager(10218): THREAD WARNING: exec() call to SchedulerPlugin.getAlarms blocked the main thread for 18ms. Plugin should use CordovaInterface.getThreadPool().
    03-31 21:04:02.904: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:02.904: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:02.904: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:02.954: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:02.974: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.044: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.144: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.164: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.194: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.224: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.224: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.244: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.254: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.254: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.254: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.274: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.294: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.305: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.305: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.305: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.315: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.325: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.325: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416
    03-31 21:04:03.325: I/Web Console(10218): ------ Alarm list:OK at file:///android_asset/www/index.html:1416

I can't tell for certain, but it seems like when the main thread is blocked, that the corresponding function doesn't go through... I have a counter that increases everytime I make a call to my addAlarmAtTime(passedTime) function, and the number from the the counter is quite a bit higher than the length of alarms array that I get from getAlarms()...

For example, the counter is 56, when the length of the array that holds the alarms is only 37...

@Red-Folder
Copy link
Owner

I have to admit to being very confused over the "Plugin should use CordovaInterface.getThreadPool()" message.

The code is already using:

cordova.getThreadPool().execute(new Runnable() {
                    @Override
                    public void run() {
                                             .... 
                    }
                });

This seems to match the example shown in the docs -> http://docs.phonegap.com/en/2.3.0/guide_plugin-development_android_index.md.html

I've seen the warning on my Background Service as well (open issue -> Red-Folder/Cordova-Plugin-BackgroundService#19) - but never understood why it is occurring.

I'll have a fresh look.

@Red-Folder
Copy link
Owner

Further notes to myself;

Taken from https://github.com/apache/cordova-android/blob/master/framework/src/org/apache/cordova/PluginManager.java:

private static final int SLOW_EXEC_WARNING_THRESHOLD = Debug.isDebuggerConnected() ? 60 : 16;

....

            long pluginStartTime = System.currentTimeMillis();
            boolean wasValidAction = plugin.execute(action, rawArgs, callbackContext);
            long duration = System.currentTimeMillis() - pluginStartTime;

            if (duration > SLOW_EXEC_WARNING_THRESHOLD) {
                Log.w(TAG, "THREAD WARNING: exec() call to " + service + "." + action + " blocked the main thread for " + duration + "ms. Plugin should use CordovaInterface.getThreadPool().");
            }

Within CordovaActivity.java, the getThreadPool as :

    public ExecutorService getThreadPool() {
        return threadPool;
    }

"threadPool" is defined as java.util.concurrent.Executors.newCachedThreadPool()

@Red-Folder
Copy link
Owner

I believe I've made a fundamental mistake with how I'm using the Runnable class.

While I'm defining the logic with new Runnable.run() (which in then passed to the getThreadPool().execute()), that code if making reference to lots of methods of the parent class (the plugin) - which I suspect is causing locking issues.

I think I need to be creating a new class (SchedulerLogic) which extends Runnable and move the run and logic code into that class. Then on getThreadPool().execute() pass a new SchedulerLogic.

I probably also need to put some syncronization round any dal amendment (addAlarm, updateAlarm & cancelAlarm) and release on save - may try to push this in to the DAL to ensure that its atomic. Likely to need to employ some level of dispose ... example code:

bool disposed;
public void Dispose(){
    Dispose(true);
    GC.SuppressFinalize(this); // tell GC not to call Finalizer() for this object
}

~MyObject(){
    Dispose(false);
}

void Dispose(bool manualDisposing){
    if(!disposed){
        disposed = true;
        if(manualDisposing)
           ... // call Dispose on all IDisposable fields
        ... // dispose all native resources
    }
}

@Red-Folder
Copy link
Owner

First job will be to create a repeatable test - probably a loop which creates 50 alarms should do it.

@Red-Folder
Copy link
Owner

[Another note to myself]
Need to review how to make the DAL thread safe

Read http://tutorials.jenkov.com/java-concurrency/thread-signaling.html for ideas

@galenthomasramos
Copy link
Author

Take a look at Katzer's code for a local notification plugin. When I originally used the plugin it suffered from the same problem, then in an update he documented a fix and it seemed to solve the problem for the most part (instead of nearly a third of added notifications blocking the main thread, I might get 1 or 2 when adding 50-100 notifications).

https://github.com/katzer/cordova-plugin-local-notifications

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

No branches or pull requests

2 participants