Lecrapouille / gdcef

[Plugin][Version 0.13.0][Functional] Chromium Embedded Framework Webview for Godot 3 and 4
https://discord.gg/EckEwy7S5U
MIT License
261 stars 31 forks source link

Windows CEF crashing on play #27

Closed kcfresh53 closed 1 year ago

kcfresh53 commented 1 year ago

First off thanks for the amazing project, I have a similar issue to this but it has a unique cause. The web view works when run within its own scene but when put as a child of another scene it crashes with no errors present. This is the image of the web view scene: image and this is the structure of the other scene: image No matter the scene I place it in, as long as it is a child of another node, it will crash. I also tried copying a known working project and it still crashes but the demos work. Here is what my log file is reporting:

[0214/104650.053:WARNING:browser_info.cc(300)] Returning a speculative frame for 25769803781 [6,5]
[0214/104650.742:WARNING:browser_info.cc(300)] Returning a speculative frame for 25769803781 [6,5]
[0214/104650.743:WARNING:browser_info.cc(300)] Returning a speculative frame for 25769803781 [6,5]
[0214/104650.743:WARNING:browser_info.cc(300)] Returning a speculative frame for 25769803781 [6,5]
[0214/104650.743:WARNING:browser_info.cc(300)] Returning a speculative frame for 25769803781 [6,5]
[0214/104700.493:WARNING:sqlite_persistent_store_backend_base.cc(163)] Failed to post task from FlushAndNotifyInBackground@net\extras\sqlite\sqlite_persistent_store_backend_base.cc:211 to client_task_runner_.
[0214/104700.494:WARNING:sqlite_persistent_store_backend_base.cc(163)] Failed to post task from FlushAndNotifyInBackground@net\extras\sqlite\sqlite_persistent_store_backend_base.cc:211 to client_task_runner_.
[0214/111540.506:WARNING:browser_info.cc(300)] Returning a speculative frame for 25769803781 [6,5]
[0214/111540.507:WARNING:browser_info.cc(300)] Returning a speculative frame for 25769803781 [6,5]
[0214/111540.507:WARNING:browser_info.cc(300)] Returning a speculative frame for 25769803781 [6,5]
[0214/111540.507:WARNING:browser_info.cc(300)] Returning a speculative frame for 25769803781 [6,5]
[0214/111540.574:WARNING:browser_info.cc(300)] Returning a speculative frame for 25769803781 [6,5]
[0214/111617.191:WARNING:dns_config_service_win.cc(584)] Failed to read DnsConfig.
[0214/111617.195:WARNING:dns_config_service_win.cc(584)] Failed to read DnsConfig.
[0214/111714.402:WARNING:frame_impl.cc(460)] SendCommandWithResponse sent to detached frame 17179869185 [4,1] will be ignored
[0214/111714.407:ERROR:interface_endpoint_client.cc(690)] Message 0 rejected by interface blink.mojom.WidgetHost
[0214/111739.085:ERROR:gpu_init.cc(537)] Passthrough is not supported, GL is disabled, ANGLE is 
[0214/112524.558:ERROR:gpu_init.cc(537)] Passthrough is not supported, GL is disabled, ANGLE is 

If the issue is from my end, any help would be highly appreciated.

Lecrapouille commented 1 year ago

@kcfresh53 hi ! Are you with Windows or Linux ? Can you share your project as zip in this ticket or share a link (or send it to my email if you want to keep it private) I'll investigate (you shared me CEF logs but my code also make logs (probably not displayed with Windows)) but seems to me the "scene" is not the root cause because in our project https://github.com/stigmee/stigmee the CEF node was on a scene. Maybe in your script you are closing the scene and reopening it and CEF was closed.

Lecrapouille commented 1 year ago

@kcfresh53 I may have understood what you have made wrong: you only need one instance of CEF for the whole project. No more :) You should let consider it as the "engine" and be singleton i.e. the Godot update function is implicitly "pumping" CEF internal messages between CEF forked processes:

https://github.com/Lecrapouille/gdcef/blob/da447a366b41d62b2446ea7b1244bfc539ea4d85/addons/gdcef/gdcef/src/gdcef.cpp#L88

https://github.com/Lecrapouille/gdcef/blob/da447a366b41d62b2446ea7b1244bfc539ea4d85/addons/gdcef/gdcef/src/gdcef.cpp#L187

Therefore, do not confuse CEF with its browser views (aka tabs ... I do not know to name things, I hope the name is correct) that you are allowed to create as many as you want. My code is probably detecting that you are trying to create 2 CEF instances ...

https://github.com/Lecrapouille/gdcef/blob/da447a366b41d62b2446ea7b1244bfc539ea4d85/addons/gdcef/gdcef/src/gdcef.cpp#L106

... and an error message is displayed (readable in the Godot console ?) ...

https://github.com/Lecrapouille/gdcef/blob/da447a366b41d62b2446ea7b1244bfc539ea4d85/addons/gdcef/demos/3D/GUI.gd#L142

... and abort.

https://github.com/Lecrapouille/gdcef/blob/da447a366b41d62b2446ea7b1244bfc539ea4d85/addons/gdcef/demos/3D/GUI.gd#L143

Why do you need one CEF for each of your "Navigat" (ion panel ?) ? When you create a new browser view, it will be created as Godot node as a child of the CEF node. Contrary to Unity, Godot does not display them in the scene graph. Let these "private" nodes in peace : the creation function will return you their node reference, and you can store them as variables in your "Navigat" nodes.

https://github.com/Lecrapouille/gdcef/blob/da447a366b41d62b2446ea7b1244bfc539ea4d85/addons/gdcef/demos/3D/GUI.gd#L147

https://github.com/Lecrapouille/gdcef/blob/da447a366b41d62b2446ea7b1244bfc539ea4d85/addons/gdcef/demos/3D/GUI.gd#L105

Note : For the moment, I never tried to delete browser views there is maybe a crash because CEF and Godot both reference them.

kcfresh53 commented 1 year ago

Thanks for the response, I am on windows and CEF is only used once in the project. The other pages do not hold a web view, the project is an app development base framework with customizable mobile components, multi database support (e.g superbase, firebase, SQL, etc.) and I planned on using the WebView to view native JavaScript components, local html pages, Leaflet JS maps and faster integration of other payment providers in Godot. I plan on the project being open source but its not ready yet so I will just send a project invite.

Lecrapouille commented 1 year ago

Beware CEF is not supported on Android and IOs https://magpcss.org/ceforum/viewtopic.php?f=6&t=18268

Lecrapouille commented 1 year ago

@kcfresh53 I have created a dev-cef branch in your project and added CEF node and 2 texture rectangles inside the 1st and 2nd panel. I added a Main.gd to your main node for the logic. Only the second browser reacts to mouse inputs, you have to add the logic to enable the good browser. You can follow my demos to add more features for your CEF.

It works nicely on my side so we can close this ticket I guess. We can continue talking about your project by email if you want :)