当我将其他插件嵌入其中时,QtBrowserPlugin 崩溃:我的修复正确吗?

发布于 2024-09-26 07:54:42 字数 3027 浏览 7 评论 0原文

QtBrowserPlugin 包含 QWebView,可加载包含其他插件的页面。

(opera 
    (some_page 
        (my_qtbrowser_plugin 
            (QWebView 
                (some_other_page 
                    (some_other_plugin))))))

为什么在加载加载或尝试加载其他插件的页面后,它会停止向 QtBrowserPlugin 调度事件(从外部调用任何 JS 都会崩溃: http://sprunge.us/HeZA

在堆栈跟踪中我看到:

#3  <signal handler called>
#4  0xb63ae1f2 in WebCore::IdentifierRep::string() const () from /usr/local/Trolltech/Qt-4.7.0/lib/libQtWebKit.so.4
#5  0xb63b339c in _NPN_UTF8FromIdentifier () from /usr/local/Trolltech/Qt-4.7.0/lib/libQtWebKit.so.4
#6  0xb76e3d51 in NPN_UTF8FromIdentifier (identifier=0x7ffffffe) at .../src/qtbrowserplugin.cpp:200
#7  0xb76e4aaf in NPClass_HasMethod (npobj=0x80e5c80, name=0x7ffffffe) at .../src/qtbrowserplugin.cpp:364

为什么 qtbrowserplugin 中的代码调用 QtWebKit 中的东西?还有其他想法如何调试/修复它吗?

更新 我还刚刚发现它调用 qtbrowserplugin.cpp:NP_Initialize 两次( http://sprunge .us/BdfQ ):

*** GDB BACKTRACE ***
#2  0xb78ad817 in NP_Initialize (nFuncs=0x807599c, pFuncs=0x8074740) at /mnt/sda8/src/p/qtbrowserplugin-2.4_1-opensource/src/qtbrowserplugin.cpp:1273
#3  0x080556ea in Handle::Open(char const*, _NPNetscapeFuncs*) ()
#4  0x08056692 in pluginController::open(char const*) ()
#5  0x08055ca8 in main ()
*** END OF BACKTRACE ***
** (operapluginwrapper:1281): DEBUG: NP_Initialize
** (operapluginwrapper:1281): DEBUG: NP_Initialize succeeded

*** GDB BACKTRACE ***
#2  0xb78ad817 in NP_Initialize (nFuncs=0xb4357094, pFuncs=0xb4357058) at /mnt/sda8/src/p/qtbrowserplugin-2.4_1-opensource/src/qtbrowserplugin.cpp:
#3  0xb6af7dae in WebCore::PluginPackage::load() () from /usr/local/Trolltech/Qt-4.7.0/lib/libQtWebKit.so.4
#4  0xb6af774d in WebCore::PluginPackage::fetchInfo() () from /usr/local/Trolltech/Qt-4.7.0/lib/libQtWebKit.so.4
#5  0xb69578ae in WebCore::PluginPackage::createPackage(WebCore::String const&, long const&) () from /usr/local/Trolltech/Qt-4.7.0/lib/libQtWebKit.so.4
...

更新 2 我的修复正确吗? http://vi-server.org/vi/ bin/qtbrowserplugin-2.4_1-opensource-netsing-fix.patch

diff --git a/qtbrowserplugin-2.4_1-opensource.orig/src/qtbrowserplugin.cpp b/qtbrowserplugin-2.4_1-opensource/src/qtbrowserplugin.cpp
index e7c6f31..632d546 100644
--- a/qtbrowserplugin-2.4_1-opensource.orig/src/qtbrowserplugin.cpp
+++ b/qtbrowserplugin-2.4_1-opensource/src/qtbrowserplugin.cpp
@@ -1271,6 +1271,10 @@ extern "C" NPError WINAPI NP_Initialize(NPNetscapeFuncs* nFuncs, NPPluginFuncs*
 {
     if(!nFuncs)
         return NPERR_INVALID_FUNCTABLE_ERROR;
+    
+    if(qNetscapeFuncs) {
+        return NPERR_INVALID_PLUGIN_ERROR;
+    }

     qNetscapeFuncs = nFuncs;
     int navMajorVers = qNetscapeFuncs->version >> 8;

There is QtBrowserPlugin which contains QWebView that load a page that contains other plugin.

(opera 
    (some_page 
        (my_qtbrowser_plugin 
            (QWebView 
                (some_other_page 
                    (some_other_plugin))))))

Why after loading a page which loads or attempts to load some other plugin it stops dispatching events to the QtBrowserPlugin (crashes on any JS call from the outside: http://sprunge.us/HeZA)

In the stacktrace I see:

#3  <signal handler called>
#4  0xb63ae1f2 in WebCore::IdentifierRep::string() const () from /usr/local/Trolltech/Qt-4.7.0/lib/libQtWebKit.so.4
#5  0xb63b339c in _NPN_UTF8FromIdentifier () from /usr/local/Trolltech/Qt-4.7.0/lib/libQtWebKit.so.4
#6  0xb76e3d51 in NPN_UTF8FromIdentifier (identifier=0x7ffffffe) at .../src/qtbrowserplugin.cpp:200
#7  0xb76e4aaf in NPClass_HasMethod (npobj=0x80e5c80, name=0x7ffffffe) at .../src/qtbrowserplugin.cpp:364

Why the code in qtbrowserplugin calls things in QtWebKit? Are there any other ideas how to debug/fix it?

Update I've also just found that it calls qtbrowserplugin.cpp:NP_Initialize twice ( http://sprunge.us/BdfQ ):

*** GDB BACKTRACE ***
#2  0xb78ad817 in NP_Initialize (nFuncs=0x807599c, pFuncs=0x8074740) at /mnt/sda8/src/p/qtbrowserplugin-2.4_1-opensource/src/qtbrowserplugin.cpp:1273
#3  0x080556ea in Handle::Open(char const*, _NPNetscapeFuncs*) ()
#4  0x08056692 in pluginController::open(char const*) ()
#5  0x08055ca8 in main ()
*** END OF BACKTRACE ***
** (operapluginwrapper:1281): DEBUG: NP_Initialize
** (operapluginwrapper:1281): DEBUG: NP_Initialize succeeded

*** GDB BACKTRACE ***
#2  0xb78ad817 in NP_Initialize (nFuncs=0xb4357094, pFuncs=0xb4357058) at /mnt/sda8/src/p/qtbrowserplugin-2.4_1-opensource/src/qtbrowserplugin.cpp:
#3  0xb6af7dae in WebCore::PluginPackage::load() () from /usr/local/Trolltech/Qt-4.7.0/lib/libQtWebKit.so.4
#4  0xb6af774d in WebCore::PluginPackage::fetchInfo() () from /usr/local/Trolltech/Qt-4.7.0/lib/libQtWebKit.so.4
#5  0xb69578ae in WebCore::PluginPackage::createPackage(WebCore::String const&, long const&) () from /usr/local/Trolltech/Qt-4.7.0/lib/libQtWebKit.so.4
...

Update 2 Is my fix correct? http://vi-server.org/vi/bin/qtbrowserplugin-2.4_1-opensource-netsing-fix.patch :

diff --git a/qtbrowserplugin-2.4_1-opensource.orig/src/qtbrowserplugin.cpp b/qtbrowserplugin-2.4_1-opensource/src/qtbrowserplugin.cpp
index e7c6f31..632d546 100644
--- a/qtbrowserplugin-2.4_1-opensource.orig/src/qtbrowserplugin.cpp
+++ b/qtbrowserplugin-2.4_1-opensource/src/qtbrowserplugin.cpp
@@ -1271,6 +1271,10 @@ extern "C" NPError WINAPI NP_Initialize(NPNetscapeFuncs* nFuncs, NPPluginFuncs*
 {
     if(!nFuncs)
         return NPERR_INVALID_FUNCTABLE_ERROR;
+    
+    if(qNetscapeFuncs) {
+        return NPERR_INVALID_PLUGIN_ERROR;
+    }

     qNetscapeFuncs = nFuncs;
     int navMajorVers = qNetscapeFuncs->version >> 8;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

人生百味 2024-10-03 07:54:42

对于全屏要求,在没有更多细节的情况下提出合理的解决方案有点棘手。但是,对于分层插件,您应该查看无窗口插件(我不知道 QtBrowserPlugin 是否支持它们,FireBreath 应该在下一个版本中支持它们)。

我认为您实际上无法解决问题 - 两个浏览器引擎都将您的插件作为共享库加载,并由于处于同一进程中而获得相同的实例。现在它们都想调用 NP_Initialize() 来交换函数指针,这使得您无法与两个浏览器通信:
您可以存储单独的 NPNetspaceFuncs,但您无法(没有重大黑客攻击)检测哪个浏览器实际调用 NPP_New() 等,因此无法确定应该调用哪个浏览器从哪个插件返回。

一种巧妙的解决方法可能是实际使用两个不同的插件,每个浏览器引擎一个。但请记住,如果您同时使用其他插件,也可能会破坏它们。
解决全屏问题的另一种选择可能是调用单独的进程,这使您可以完全控制 GUI 元素。

For the full-screen requirement it's a bit tricky to suggest sensible solutions without more details. For layering plugins however you should look into windowless plugins (i don't know whether QtBrowserPlugin supports them, FireBreath should support them in the next release).

I don't think you can actually fix the problem - both browser engines load your plugin as a shared library and get the same instance due to being in the same process. Now they both want to call NP_Initialize() to exchange function pointers, which makes it impossible for you to talk to both browsers:
You could store the separate NPNetspaceFuncs, but you can't (without major hacks) detect which browser actually calls NPP_New() etc. and thus not determine which browser you should call back from which plugin.

A hacky workaround might be to actually use two different plugins, one for each browser engine. Keep in mind however that you can break other plugins too if you use them in both.
Another alternative for your fullscreen problem might be to invoke a seperate process, which gives you full control over GUI elements.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文