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

[feat] Catch tauri errors #10157

Open
thewh1teagle opened this issue Jul 1, 2024 · 8 comments
Open

[feat] Catch tauri errors #10157

thewh1teagle opened this issue Jul 1, 2024 · 8 comments

Comments

@thewh1teagle
Copy link
Contributor

Describe the problem

Some users have an old version of webview2. if it's too old, the internal function create_webview will fail to run, tauri will log the error, but the app will still run in the background without show any error or crash the thread.

Describe the solution you'd like

Let me catch such errors. currently I don't get anything from it. I even have a panic hook, but it doesn't kick in since seems like the event loop just keep runing.

Alternatives considered

Additional context

thewh1teagle/vibe#153 (comment)

@Legend-Master
Copy link
Contributor

Legend-Master commented Jul 1, 2024

Seems like we use ICoreWebView2Environment10 which requires 101+ to support setting incognito mode, maybe we can skip that cast if we don't use incognito?

https://github.com/tauri-apps/wry/blob/f9e6bcc032369c6d5e7ce0284406953a16da3d82/src/webview2/mod.rs#L330-L331
https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environment10?view=webview2-1.0.2478.35
https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes/archive?tabs=dotnetcsharp#10121039

Seems like this is also when theme API gets added, probably could document when it's added and skip it instead of returning error for unsupported platforms

Let me catch such errors

I might be wrong but looks like you're using expect here?

https://github.com/thewh1teagle/vibe/blob/434e922ac386c3a45e989b094c8d25a85895eb5c/desktop/src-tauri/src/setup.rs#L73

@thewh1teagle
Copy link
Contributor Author

thewh1teagle commented Jul 1, 2024

I might be wrong but looks like you're using expect here?

Let me catch such errors. currently I don't get anything from it. I even have a panic hook, but it doesn't kick in since seems like the event loop just keep runing.

@Legend-Master
Copy link
Contributor

Legend-Master commented Jul 1, 2024

I don't quite get it to be honest, expect will panic the thread on error, if you want to handle the error you can just use the returned Result from it or do you mean it's crashing at somewhere else?

@thewh1teagle
Copy link
Contributor Author

I don't quite get it to be honest, expect will panic the thread on error, if you want to handle the error you can just use the returned Result from it or do you mean it's crashing at somewhere else?

Sorry, I should have explained it better. Even though I'm using expect, it never gets there. Like I said, if the webview fails to start (like with an old version), tauri logs the error, but expect isn't hit, and the event loop just keeps running. Hope that makes more sense!

@Legend-Master
Copy link
Contributor

Legend-Master commented Jul 1, 2024

Ah, got it

C:\Users\1234>[2024-06-30T23:19:39Z DEBUG vibe_desktop] Vibe App Running
[2024-06-30T23:19:39Z ERROR tauri_runtime_wry] failed to create webview: WebView2 error: WindowsError(Error { code: HRESULT(0x80004002), message: "No such interface supported" })
[2024-06-30T23:19:39Z DEBUG vibe_desktop::setup] webview version: 100.0.1185.36
[2024-06-30T23:19:39Z DEBUG vibe_desktop::setup] CPU Features:
    AVX: true
    AVX2: true
    AVX512: true
    AVX512-VBMI: true
    AVX512-VNNI: true
    FMA: true
    F16C: true
[2024-06-30T23:19:39Z DEBUG vibe_desktop::setup] COMMIT_HASH: cc1bb4f721a794c58081b139e57808c6ec8e00a5

https://github.com/thewh1teagle/vibe/blob/434e922ac386c3a45e989b094c8d25a85895eb5c/desktop/src-tauri/src/setup.rs#L73

Looking at this, it seems like the failed to create webview error happened before WebviewWindowBuilder::build, presumably before the whole setup function, and that probably explained why the panic hook didn't work

It seems like it's creating windows before setup hook which should be from config files but I don't see any windows from your config files, pretty strange

@thewh1teagle
Copy link
Contributor Author

and that probably explained why the panic hook didn't work

In addition the process kept running (the process was still listed in task manager)

@bukowa
Copy link

bukowa commented Jul 1, 2024

Is it possible to also detect an outdated webview version and ask the user to update?

@Legend-Master
Copy link
Contributor

Yes, with webview_version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants