cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pat Deegan (JIRA)" <j...@apache.org>
Subject [jira] [Created] (CB-11355) initPlugins() abuse borking plugins on (ajax) loads, and potential fix
Date Wed, 01 Jun 2016 18:11:59 GMT
Pat Deegan created CB-11355:
-------------------------------

             Summary: initPlugins() abuse borking plugins on (ajax) loads, and potential fix
                 Key: CB-11355
                 URL: https://issues.apache.org/jira/browse/CB-11355
             Project: Apache Cordova
          Issue Type: Bug
          Components: CordovaLib, Ubuntu
         Environment: Ubuntu 15.10

$ cordova -v
6.1.1

$ nodejs -v
v6.2.0
            Reporter: Pat Deegan
            Assignee: Maxim Ermilov


I'm working on an (ubuntu) plugin that is thread-safe and meant to , but was causing segfaults
everytime I'd (asynch) load a new page or component.

Trying to run it under gdb, I found that as long as I avoided moving around there were no
issues, but every load of a new page or (html) popup would spawn a new thread and somehow
re-init my plugin (which is stateful and needs to stay alive).

The traces looked like so:
======================== snip ========================
[New Thread 0x7fffcf8a9700 (LWP 26618)]
Debug: Enable plugin "com.example.ThreadedPlugin"
Debug: Enable plugin "File"
Debug: Enable plugin "Notification"
Debug: Enable plugin "com.cordova.Device"
Debug: Testing "/path/to/project/platforms/ubuntu/native/prefix/www/logo.png"
[Thread 0x7fffcf8a9700 (LWP 26618) exited]
Debug: Testing "/path/to/project/platforms/ubuntu/native/prefix/www/cordova.js"
Debug: Testing "/path/to/project/platforms/ubuntu/native/prefix/www/cordova_plugins.js"
Debug: Testing "/path/to/project/platforms/ubuntu/native/prefix/www/pageA.html"
Debug: Testing "/path/to/project/platforms/ubuntu/native/prefix/www/pageB.html"
Debug: Testing "/path/to/project/platforms/ubuntu/native/prefix/www/index.html"
Debug: Testing "/path/to/project/platforms/ubuntu/native/prefix/www/libcoreplugins.so"
[New Thread 0x7fffcf8a9700 (LWP 26619)]
[Thread 0x7fffcf8a9700 (LWP 26619) exited]
Debug: Enable plugin "com.example.ThreadedPlugin"
Debug: Enable plugin "File"
Debug: Enable plugin "Notification"
Debug: Enable plugin "com.cordova.Device"
Debug: Testing "/path/to/project/platforms/ubuntu/native/prefix/www/logo.png"
Debug: Testing "/path/to/project/platforms/ubuntu/native/prefix/www/cordova.js"
Debug: Testing "/path/to/project/platforms/ubuntu/native/prefix/www/cordova_plugins.js"
Debug: Testing "/path/to/project/platforms/ubuntu/native/prefix/www/pageA.html"
Debug: Testing "/path/to/project/platforms/ubuntu/native/prefix/www/pageB.html"
Debug: Testing "/path/to/project/platforms/ubuntu/native/prefix/www/index.html"
Debug: Testing "/path/to/project/platforms/ubuntu/native/prefix/www/libcoreplugins.so"
[New Thread 0x7fffcf8a9700 (LWP 26621)]
Debug: Enable plugin "com.example.ThreadedPlugin"
Debug: Enable plugin "File"
Debug: Enable plugin "Notification"
Debug: Enable plugin "com.cordova.Device"
Debug: Testing "/path/to/project/platforms/ubuntu/native/prefix/www/logo.png"
[Thread 0x7fffcf8a9700 (LWP 26621) exited]
Program received signal SIGSEGV, Segmentation fault.
======================== /snip ========================

I tracked down the reason for all the (redundant?) "Enable plugin" events to initPlugins()
calls in loadFinished() (in the Ubuntu package/src/cordova.cpp):

void Cordova::loadFinished(bool ok) {
    Q_UNUSED(ok)
    initPlugins();
}


I'm not certain what the purpose of this call is, as the init already happens in Cordova::appLoaded().

In any case, I've disabled the call and loadFinished() and my plugin is both persistent and
has stopped causing segfaults.

Is there a reason to keep this initPlugins() call in loadFinished()?  If so, could we add
some kind of 

   virtual bool loadOnlyOnce() { return false;}

to the CPlugin base class so we can check for and skip plugins that override it?  Or is there
some other technique I'm not aware of?

Thanks,
Pat Deegan









--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Mime
View raw message