You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The documentation suggests that panel.onDidDispose can reliable be used to avoid exception. I think this is not true since the communication between the renderer and extension host is async. It can happen that the user presses the close button and the extension tries to access the WebView before the dispose event made it to the extension host. We should either make this clear in the doc or handle these cases more gracefully.
The text was updated successfully, but these errors were encountered:
Good point, although I believe this is mitigated by how dispose is implemented. The important points:
The extension host throws if you try accessing a disposed webview. The main thread does not.
The main thread throws if you try accessing an unknown webview.
Here's what happens when the user closes a panel:
The onDispose callback is invoked in mainThreadWebview
The callback sends a onDidDisposeWebview message to the extension host.
The extension host receives this message. It marks its ExtHostWebview object as being disposed and fires the extension onDidDispose method which synchronously invokes all the listeners. If an extension tries to call method on the webview object at this point, an error will be thrown
Meanwhile, the mainThreadWebview has been waiting for the extension host's onDidDiposeWebview event to complete. If the extension host tries to access the disposed webview while the mainThreadWebview is waiting, no error should occur because the main thread still knows about this webview
Once onDidDisposeWebview completes in the mainThreadWebview, we delete the webview. At this point, any future attempts to access it will throw errors
What happens if the extension does something with the web view between 1. and 3. If this returns reasonable results and doesn't throw I am fine with closing the issue.
Tests: #48453
The documentation suggests that panel.onDidDispose can reliable be used to avoid exception. I think this is not true since the communication between the renderer and extension host is async. It can happen that the user presses the close button and the extension tries to access the WebView before the dispose event made it to the extension host. We should either make this clear in the doc or handle these cases more gracefully.
The text was updated successfully, but these errors were encountered: