- VSCode Version: 1.23.0-insider
- OS Version: macOS 10.3.4
If you have created a web view using the new vscode.window.createWebview api, with retainContextWhenHidden set to true any messages that are sent to the web view using the webview.postMessage method will not be received (either while it is in the background - or when it regains focus).
To me this seems to limit the usefulness of the API - as you cannot send data to your webview if you cannot guarantee it is currently visible.
For example, in the extension that I develop (Cortex-Debug - https://marketplace.visualstudio.com/items?itemName=marus25.cortex-debug) , one of the features is an SWO decoding and graphing tool for use when debugging ARM Cortex-M microcontrollers. This data can be received at any time during the debug process. My intention is to use the new webview functionality to be able to present these graphs within the VSCode interface.
Current releases use the existing previewHTML method, and I create a WebSocket server to communicate in real-time between the html preview and the extension - but this has several drawbacks (extra complexity of running said WebSocket server; preview HTML is not persistent when in background, etc). While the new method is an improvement for the communication between the extension and the HTML view; not being able to communicate while the HTML webview is not visible is less than stellar - as it still essentially means having to load all data that occurred since it was last visible (this can be 10s if not 100s of messages being backlogged every second on faster target devices) which is not much better than a full refresh.
If you have created a web view using the new vscode.window.createWebview api, with retainContextWhenHidden set to true any messages that are sent to the web view using the webview.postMessage method will not be received (either while it is in the background - or when it regains focus).
To me this seems to limit the usefulness of the API - as you cannot send data to your webview if you cannot guarantee it is currently visible.
For example, in the extension that I develop (Cortex-Debug - https://marketplace.visualstudio.com/items?itemName=marus25.cortex-debug) , one of the features is an SWO decoding and graphing tool for use when debugging ARM Cortex-M microcontrollers. This data can be received at any time during the debug process. My intention is to use the new webview functionality to be able to present these graphs within the VSCode interface.
Current releases use the existing previewHTML method, and I create a WebSocket server to communicate in real-time between the html preview and the extension - but this has several drawbacks (extra complexity of running said WebSocket server; preview HTML is not persistent when in background, etc). While the new method is an improvement for the communication between the extension and the HTML view; not being able to communicate while the HTML webview is not visible is less than stellar - as it still essentially means having to load all data that occurred since it was last visible (this can be 10s if not 100s of messages being backlogged every second on faster target devices) which is not much better than a full refresh.