OutSystems / WebView

Avalonia/WPF control that wraps CefGlue webview control
Apache License 2.0
358 stars 40 forks source link

Add logging to webview #326

Closed tbragaf closed 9 months ago

tbragaf commented 9 months ago

I noticed a bug when we would dispose all JS executors when creating and quickly destroying an iframe.

When creating and destroying an iframe very quickly, an event for javascript context create is triggered in cef and handled in “OnJavascriptContextCreated“ - whose Frame name is unusually empty. When doing so without being very quick, the frame name ends up fill in in the form of “

The event is handled in https://github.com/OutSystems/WebView/blob/master/WebViewControl/WebView.cs#L445

When destroying the frame, another event is triggered which is handled in “OnJavascriptContextReleased“ (https://github.com/OutSystems/WebView/blob/master/WebViewControl/WebView.cs#L478)

Being the name empty, which is consulted in https://github.com/OutSystems/WebView/blob/master/WebViewControl/WebView.cs#L484, we are disposing the JS executors for the main frame a couple line below.

The extension method in turn checks whether the frame name empty or not (https://github.com/OutSystems/WebView/blob/master/WebViewControl/WebView.Extensions.cs#L20).

The bug is not 100% on the WebView side, but we want to add logging so we can better understand similar scenarios like this that would lead to an unresposive browser