Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] dynamic create webview in current window crash in windows 10 #10010

Open
chenrensong opened this issue Jun 7, 2024 · 12 comments
Open

[bug] dynamic create webview in current window crash in windows 10 #10010

chenrensong opened this issue Jun 7, 2024 · 12 comments
Labels
scope: unstable flag Issue only occures with "unstable" feature flag enabled status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@chenrensong
Copy link

chenrensong commented Jun 7, 2024

Describe the bug

#[tauri::command]
pub fn create_webview_inner(
window: tauri::Window,
url: String,
x: f64,
y: f64,
width: f64,
height: f64,
) -> Result<String, String> {
let window_id = WINDOW_ID.fetch_add(1, atomic::Ordering::SeqCst);
let label = format!("webview_{}", window_id);
let webview_builder =
tauri::webview::WebviewBuilder::new(label.clone(), WebviewUrl::App(url.parse().unwrap()));
let _webview = window.add_child(
webview_builder.auto_resize(),
LogicalPosition::new(x, y),
LogicalSize::new(width, height),
);
Ok(label)
}

The above code can be allowed normally on Mac, but cannot be allowed on Windows

Reproduction

No response

Expected behavior

No response

Full tauri info output

thread 'main' has overflowed its stack

Stack trace

No response

Additional context

No response

@chenrensong chenrensong added status: needs triage This issue needs to triage, applied to new issues type: bug labels Jun 7, 2024
@JingyuanZhang
Copy link

I have encountered this issue as well.

@FabianLars
Copy link
Member

Can one of you please post the output of the tauri info command as required by the issue template?
And if you're on v2, do you have tauri's unstable feature flag enabled or not? (if you don't know then the answer is probably no)

@lindongchen
Copy link

lindongchen commented Jun 12, 2024

Similar issues.

import { WebviewWindow } from '@tauri-apps/api/webviewWindow'
import { getCurrent } from '@tauri-apps/api/window'
...
                       if(platform.value=='windows'){
				options.parent = getCurrent();
			}
			const webview = new WebviewWindow(`${app.name}-webview`, options);
			webview.once('tauri:https://created', function (d) {
				console.log('tauri:https://created')
				console.log(d)
			// webview successfully created
			});
			webview.once('tauri:https://error', function (e) {
				console.log('tauri:https://error')
				console.log(e)
			// an error happened creating the webview
			});
...
[dependencies]
fix-path-env = { git = "https://github.com/tauri-apps/fix-path-env-rs" }
tauri = { version = "=2.0.0-beta.22", features = ["macos-proxy", "unstable"] }
tauri-utils = "=2.0.0-beta.17"
tauri-plugin-shell = "=2.0.0-beta.5"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
tauri-plugin-process = "=2.0.0-beta.5"
tauri-plugin-http = "=2.0.0-beta.5"
tauri-plugin-os = "=2.0.0-beta.5"
tauri-plugin-fs = "=2.0.0-beta.7"
tauri-plugin-deep-link = "=2.0.0-beta.6"

Whether in Win10/Win11, creating a window will crash, tauri:https://created It will happen, but there are no errors,

@FabianLars
Copy link
Member

@lindongchen Does this also happen if you remove the unstable flag?

@chenrensong
Copy link
Author

@lindongchen Does this also happen if you remove the unstable flag?

error[E0599]: no method named add_child found for struct tauri::Window in the current scope
--> src\webview.rs:35:27
|
35 | let _webview = window.add_child(
| -------^^^^^^^^^ method not found in Window

error[E0599]: no method named add_child found for struct tauri::Window in the current scope
--> src\webview.rs:71:27
|
71 | let _webview = window.add_child(
| -------^^^^^^^^^ method not found in Window

error[E0599]: no method named get_webview found for struct AppHandle in the current scope
--> src\webview.rs:81:22
|
81 | match app_handle.get_webview(label) {

@lindongchen
Copy link

I have tracked the source code and found that many functions are enabled under the unstable flag, so removing the unstable flag seems meaningless @FabianLars

@FabianLars FabianLars added the scope: unstable flag Issue only occures with "unstable" feature flag enabled label Jun 24, 2024
@FabianLars
Copy link
Member

Apologies, i only looked at your js example and forgot about the initial issue code...

@chenrensong
Copy link
Author

May I know which version can be fixed

@FabianLars
Copy link
Member

The implementations behind the unstable flag currently do not get much priority so i can't give you an ETA.

@chenrensong
Copy link
Author

The implementations behind the unstable flag currently do not get much priority so i can't give you an ETA.

I have a very important project that relies on this feature. Can you help optimize it

@FabianLars
Copy link
Member

No, sorry. I don't have any spare time myself.

One thing I just noticed though, did you ever try making your create_webview_inner command async? That was already a requirement for webview/window creation on windows in v1 so maybe it's the issue here (though it should cause a deadlock, not a crash).

@WalrusSoup
Copy link

WalrusSoup commented Jul 10, 2024

Check src-tauri/capabilities/desktop.json for duplicate permissions. Duplicate permissions here will cause a stack overflow on windows - no idea why. Tested on Win10/11.

We had an extra notification:default and it was just having a meltdown after it launched the webview.

edit: nevermind, it does launch now when debugging but crashes in production builds still.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: unstable flag Issue only occures with "unstable" feature flag enabled status: needs triage This issue needs to triage, applied to new issues type: bug
Projects
None yet
Development

No branches or pull requests

5 participants