Coder Social home page Coder Social logo

应用闪退 about webview_cef HOT 6 OPEN

Crush-star avatar Crush-star commented on June 3, 2024
应用闪退

from webview_cef.

Comments (6)

Crush-star avatar Crush-star commented on June 3, 2024

是macos下的

from webview_cef.

SinyimZhi avatar SinyimZhi commented on June 3, 2024

因为现在这个插件还不支持多实例,你在使用overlay的时候第一次关闭的时候是销毁了webviewhandler,但是Webviewhandler本身是单例的。所以这里判空会报错,如果你想支持多实例使用的话,目前这个插件还有一段路要走,我个人的fork上有个试验性的分支,但是依然面临着很多问题,尤其是面对多窗口时。

from webview_cef.

SinyimZhi avatar SinyimZhi commented on June 3, 2024

尤其是mac上面问题更多,实在是之前没有macos的技术栈,一直做的很慢 /笑哭

from webview_cef.

alldev avatar alldev commented on June 3, 2024

Hey, @SinyimZhi, I also faced that "!g_instance" problem and probably found the solution to solve it. In our case it's not about WebView multi instance, but about same instance reinitialization. We have separate screen deep inside our application which contains WebView, the business logic is to open/close it time to time. Also it seems similar problem was already mentioned in prevoius issue which was closed as not reproducible.

I think I figured out the solution. Please chech the webview_plugin.cc file. In Dec 26 2023 commit this file was changed, but not drastically. However, these changes cause error.

I am on the recent (i.e. Jan 15 2024) commit and changed few things.

This part of handler & app initialization:

CefRefPtr<WebviewHandler> handler;
CefRefPtr<WebviewApp> app;

Was changed by me to this one:

CefRefPtr<WebviewHandler> handler(new WebviewHandler());
CefRefPtr<WebviewApp> app(new WebviewApp(handler));

And this part of CEF initialization:

void initCEFProcesses(CefMainArgs args){
	mainArgs = args;
	initCEFProcesses();
}

void initCEFProcesses(){
#ifdef OS_MAC
	CefScopedLibraryLoader loader;
	if(!loader.LoadInMain()) {
		printf("load cef err");
	}
#endif
	handler = new WebviewHandler();
	app = new WebviewApp(handler);
	CefExecuteProcess(mainArgs, app, nullptr);
}

To this one:

void initCEFProcesses(CefMainArgs args){
	mainArgs = args;
	CefExecuteProcess(mainArgs, app, nullptr);
 }

void initCEFProcesses(){
#ifdef OS_MAC
	CefScopedLibraryLoader loader;
	if(!loader.LoadInMain()) {
		printf("load cef err");
	}
#endif
	CefExecuteProcess(mainArgs, app, nullptr);
}

Now everything seems working fine and I do not face any issue.

Hope this stuff can be helpful to be implemented in update and/or will be useful for further understanding.

from webview_cef.

SinyimZhi avatar SinyimZhi commented on June 3, 2024

@alldev In fact, the
CefRefPtr<WebviewHandler> handler(new WebviewHandler()); CefRefPtr<WebviewApp> app(new WebviewApp(handler));
is not quite correct because variables are initialized once on the main thread during program execution, but when initCEFProcesses are executed, they may be initialized again because initCEFProcesses may not be executed on the main thread under different operating systems.That's why i changed the code to initialized WebviewHandler、WebviewApp when initCEFProcesses is called(In fact, it is also to prepare for multiple instantiation).
However, this brings another issue, when you dispose WebViewController at dart side. CefShutdown() was called.Due to the intelligent pointer,the singleton WebviewHandler was released. And when you guys called WebViewController::initialize() again, it will try to get WebviewHandler and will not pass null checker. That's why "!g_instance" assert is Thrown out.
Above all, there is currently no good way to balance the contradiction between multiple component page instances you want and the existing single instance mode of plugins support. What can i do is try to build correct multi instance mode as fast as i can.

from webview_cef.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.