Skip to content

Commit 11bb315

Browse files
authored
fix: chrome's memory saver seems to cause spurious preview disconnects (#209)
1 parent a8fe069 commit 11bb315

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed
3.42 KB
Loading
93.3 KB
Loading

docs/platform/webcontainers/browser-config.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,39 @@ WebContainers use a combination of browser technologies, such as [Service Worker
1616

1717
In some browsers, this feature is blocked by “third-party cookie” or “third-party storage” restrictions. These are legitimate restrictions when the third-party domain is an ad server or a tracking server, but in the case of WebContainers the third-party domain is where your project code runs.
1818

19-
## Chrome: enabling Service Workers {#chrome-service-workers}
19+
## Chrome
2020

21-
If you use the “Block Third Party Cookies” option in Chrome and you have "Third-party Storage Partitioning" disabled, you will need to either:
21+
With Chrome's defaults, starting with version 118 or later, you should get a pretty good experience out of the box.
22+
23+
Read on if you run into issues or want an even smoother experience.
24+
25+
Previews opened in a separate tab will require you to connect them to the editor. You usually get prompted to click on a button to do that. However, you might do that more frequently than expected with Chrome's [memory saver][CHROME_MEMORY_SAVER]. To avoid it, you can add the following exception in [chrome://settings/performance](chrome://settings/performance):
26+
27+
```
28+
https://stackblitz.com
29+
```
30+
31+
Once done, you should see something similar to this:
32+
33+
<img alt="Chrome performance settings showing the memory saver section with an exception for stackblitz.com" src="./assets/chrome-memory-saver.png" width="800" />
34+
35+
### Enabling Service Workers {#chrome-service-workers}
36+
37+
If you use the “Block Third Party Cookies” option in Chrome and you have “Third-party Storage Partitioning” disabled, you will need to either:
2238

2339
- Enable Storage partitioning
2440
- Or add exceptions for StackBlitz projects.
2541

2642
The first option should be preferred because this is a [new feature][GOOGLE_SP] of Chrome which improves your privacy when you visit websites that embed third-party sites.
2743

28-
### Enable Storage partitioning
44+
#### Enable Storage partitioning
2945

3046
Visit `chrome://flags/#third-party-storage-partitioning` and choose `Enabled` in the drop down. In recent version of Chrome, choosing the `Default` value should work too.
3147

3248
<img alt="Chrome flags showing the third-party Storage Partitioning option enabled." src="./assets/chrome-enable-sp.png" width="800" />
3349

3450

35-
### Or add exceptions for Stackblitz
51+
#### Or add exceptions for Stackblitz
3652

3753
To allow all StackBlitz projects to use Service Workers, go to your browser’s cookie preferences, and add exceptions for the following URL patterns:
3854

@@ -143,4 +159,5 @@ stackblitz.com
143159

144160
[MDN_SERVICE_WORKER]: https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API
145161
[MDN_WEB_ASSEMBLY]: https://developer.mozilla.org/en-US/docs/WebAssembly
146-
[GOOGLE_SP]: https://developers.google.com/privacy-sandbox/3pcd/storage-partitioning
162+
[GOOGLE_SP]: https://developers.google.com/privacy-sandbox/3pcd/storage-partitioning
163+
[CHROME_MEMORY_SAVER]: https://support.google.com/chrome/answer/12929150

0 commit comments

Comments
 (0)