Skip to content

Commit ce624a0

Browse files
authored
Add forceSingleThreadedSkwasm option to Flutter web loader (#178406) (#12712)
Update initialization.md This PR updates the Flutter web initialization documentation (`initialization.md`) to include the `forceSingleThreadedSkwasm` ption for `_flutter.loader.load()`. This option allows developers to force the Skia WebAssembly (skwasm) renderer to run in single-threaded mode, which improves compatibility in browsers that do not support multi-threaded WASM or when required security headers are missing. - Related to - [#178406](flutter/flutter#178406) ## Presubmit checklist - [ ] If you are unwilling, or unable, to sign the CLA, even for a _tiny_, one-word PR, please file an issue instead of a PR. - [ ] If this PR is not meant to land until a future stable release, mark it as draft with an explanation. - [x] This PR follows the [Google Developer Documentation Style Guidelines](https://developers.google.com/style)—for example, it doesn't use _i.e._ or _e.g._, and it avoids _I_ and _we_ (first-person pronouns). - [x] This PR uses [semantic line breaks](https://github.com/dart-lang/site-shared/blob/main/doc/writing-for-dart-and-flutter-websites.md#semantic-line-breaks) of 80 characters or fewer.
1 parent 80028e2 commit ce624a0

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/content/platform-integration/web/initialization.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,35 @@ The `config` argument is an object that can have the following optional fields:
126126
|`entrypointBaseUrl`| The base URL of your Flutter app's entrypoint. Defaults to "/". |`String`|
127127
|`hostElement`| HTML Element into which Flutter renders the app. When not set, Flutter web takes over the whole page. |`HtmlElement`|
128128
|`renderer`| Specifies the [web renderer][web-renderers] for the current Flutter application, either `"canvaskit"` or `"skwasm"`. |`String`|
129+
|`forceSingleThreadedSkwasm`| Forces the Skia WASM renderer to run in single-threaded mode for compatibility. |`bool`|
129130

130131
{:.table}
131132

132133
[web-renderers]: /platform-integration/web/renderers
133134

135+
## forceSingleThreadedSkwasm
136+
137+
A boolean flag to force the Skia WebAssembly (skwasm) renderer
138+
to run in **single-threaded mode**. This is useful if:
139+
140+
- Your environment does not support multi-threaded WASM (for example,
141+
`SharedArrayBuffer` is not available or required security
142+
headers are missing).
143+
- You want maximum browser compatibility.
144+
- Use `false` (default) to allow multi-threaded rendering when
145+
supported, which improves performance.
146+
147+
## Example usage
148+
149+
```js
150+
_flutter.loader.load({
151+
config: {
152+
renderer: 'skwasm',
153+
forceSingleThreadedSkwasm: true,
154+
},
155+
});
156+
```
157+
134158
## Example: Customizing Flutter configuration based on URL query parameters
135159

136160
The following example shows a custom `flutter_bootstrap.js` that allows

0 commit comments

Comments
 (0)