[
https://issues.apache.org/jira/browse/CB-11355?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15324467#comment-15324467
]
David Barth commented on CB-11355:
----------------------------------
Pat, thanks for pointing that out. Yeah, it looks like we don't need to
initPlugins more than once. I pushed at patch on master based on your idea.
See
https://github.com/cordova-ubuntu/cordova-ubuntu/commit/68d1cd91f25560de8642aa3386e126045e1f3784
Plugins still have the ability to be signaled when the app is reloaded in
Cordova::appLoaded()
Let me know if this fixes things in your case.
> 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: David Barth
> Labels: easyfix, plugins, segfault, triaged, ubuntu
>
> I'm working on an (ubuntu) plugin that is thread-safe 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.MyPlugin"
> 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.MyPlugin"
> 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.MyPlugin"
> 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: [email protected]
For additional commands, e-mail: [email protected]