forked from github/cordova-android
[CB-4133] Add main thread warning for plugins that run too long
This commit is contained in:
parent
0b6e90b82a
commit
488492813d
@ -225,7 +225,12 @@ public class PluginManager {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
CallbackContext callbackContext = new CallbackContext(callbackId, app);
|
CallbackContext callbackContext = new CallbackContext(callbackId, app);
|
||||||
|
long pluginStartTime = System.currentTimeMillis();
|
||||||
boolean wasValidAction = plugin.execute(action, rawArgs, callbackContext);
|
boolean wasValidAction = plugin.execute(action, rawArgs, callbackContext);
|
||||||
|
long duration = System.currentTimeMillis() - pluginStartTime;
|
||||||
|
if (duration > 16) {
|
||||||
|
Log.w(TAG, "THREAD WARNING: exec() call to " + service + "." + action + " blocked the main thread for " + duration + "ms. Plugin should use CordovaInterface.getThreadPool().");
|
||||||
|
}
|
||||||
if (!wasValidAction) {
|
if (!wasValidAction) {
|
||||||
PluginResult cr = new PluginResult(PluginResult.Status.INVALID_ACTION);
|
PluginResult cr = new PluginResult(PluginResult.Status.INVALID_ACTION);
|
||||||
app.sendPluginResult(cr, callbackId);
|
app.sendPluginResult(cr, callbackId);
|
||||||
|
Loading…
Reference in New Issue
Block a user