tauri: [bug] [alpha.17] [windows] Cannot instantiate more than one window on some machines
Describe the bug
When I try to instantiate more than one window - either using WindowBuilder or by having more than one entry in the windows config array - on some Windows machine the app consistently dies and shows failed to create webview: WebView2 error: WindowsError(Error { code: HRESULT(0x8007139F), message: "The group or resource is not in the correct state to perform the requested operation." }) on the console.
This is only reproducible on some Windows machines (I managed to reproduce it on 1 out of 3 I tried), but on that one it is produced very consistently. I suspect it’s linked to OneDrive (the machine where it fails is using OneDrive).
The workaround was to remove all the entries from the windows config array, and instantiate all the windows manually while setting different data_directory built from app_data_dir with different subdirectories attached to it. I suspect it might be a good idea to instantiate all windows with their own data_directory by default, at least on Windows.
Reproduction
- Run npm create tauri-app@latest --alpha
- Add a second entry to the
windowsarray in the config - Run the app
Expected behavior
Two windows open
Platform and versions
[✔] Environment
- OS: Windows 10.0.20348 X64
✔ WebView2: 118.0.2088.76
✔ MSVC: Visual Studio Community 2022
✔ rustc: 1.72.0 (5680fa18f 2023-08-23)
✔ cargo: 1.72.0 (103a7ff2e 2023-08-15)
✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
- node: 18.13.0
- yarn: 1.22.19
- npm: 8.19.3
[-] Packages
- tauri [RUST]: 2.0.0-alpha.17
- tauri-build [RUST]: 2.0.0-alpha.11
- wry [RUST]: 0.34.2
- tao [RUST]: 0.23.0
- @tauri-apps/api [NPM]: 2.0.0-alpha.11
- @tauri-apps/cli [NPM]: 2.0.0-alpha.17
[-] App
- build-type: bundle
- CSP: unset
- distDir: ../dist
- devPath: http://localhost:1420/
- bundler: Vite
Stack trace
failed to create webview: WebView2 error: WindowsError(Error { code: HRESULT(0x8007139F), message: "The group or resource is not in the correct state to perform the requested operation." })
Additional context
No response
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 21 (8 by maintainers)
I am still experiencing this 😭 latest tauri latest rust latest webview2 latest everything
x2 when I try to add additional_browser_args the app start crashing with the same error. if you open or find a issue/ticket for this tag me please.
thank you @mrdkprj, that was indeed the problem. I am in the process of refactoring our code in WRY which touched this area of code and I didn’t see this error in a while. Good to finally know what exactly caused the issue.
The refactor is being done on https://github.com/tauri-apps/wry/tree/refactor-backends if anyone wants to test it. Also subscribe to https://github.com/tauri-apps/wry/issues/1173 to get notified when refactor is done
The argument passed to ICoreWebView2EnvironmentOptions.SetAdditionalBrowserArguments seems to be inconsistent in wry. Default argument string is “–disable-features=msWebOOUI,msPdfOOUI,msSmartScreenProtection --autoplay-policy=no-user-gesture-required” and its code points should be
[45, 45, 100, 105, 115, 97, 98, 108, 101, 45, 102, 101, 97, 116, 117, 114, 101, 115, 61, 109, 115, 87, 101, 98, 79, 79, 85, 73, 44, 109, 115, 80, 100, 102, 79, 79, 85, 73, 44, 109, 115, 83, 109, 97, 114, 116, 83, 99, 114, 101, 101, 110, 80, 114, 111, 116, 101, 99, 116, 105, 111, 110, 32, 45, 45, 97, 117, 116, 111, 112, 108, 97, 121, 45, 112, 111, 108, 105, 99, 121, 61, 110, 111, 45, 117, 115, 101, 114, 45, 103, 101, 115, 116, 117, 114, 101, 45, 114, 101, 113, 117, 105, 114, 101, 100]But code points sometimes become different like [16560, 21260, 607], [26016, 48040, 354].
Error occurs when first WebView is created with invalid argument and the second WebView is created with valid argument. Webviews are created successfully when both arguments are valid or invalid(ignorable).
I don’t even know if this inconsistency is expected and irrelevant to the error, but this was the only difference I observed.