-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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] [macos] appWindow.setTheme(null)
then output in input element, app crashes
#11384
Comments
appWindow.setTheme(null)
then output in input, app crashesappWindow.setTheme(null)
then output in input element, app crashes
appWindow.setTheme(null)
then output in input element, app crashesappWindow.setTheme(null)
then output in input element, app crashes
Originally I was trying to achieve this by doing the following, but it was also problematic! useAsyncEffect(async () => {
const appWindow = getCurrentWebviewWindow();
let isDark = globalStore.appearance.theme === "dark";
if (globalStore.appearance.theme === "auto") {
isDark = (await appWindow.theme()) === "dark"; // Gets the theme color of the window
// or
isDark = window.matchMedia("(prefers-color-scheme: dark)").matches; // It is also the theme color of the window, not the system theme color.
}
appWindow.setTheme(isDark ? "dark" : "light");
globalStore.appearance.isDark = isDark;
}, [globalStore.appearance.theme]);
// If the value of `appWindow.setTheme` is not null or undefined, a change in the system theme will not be triggered.
appWindow.onThemeChanged(async ({ payload }) => {
if (globalStore.appearance.theme !== "auto") return;
globalStore.appearance.isDark = payload === "dark";
}); |
I don't have a mac device to test on, do you mind trying the theme example in Run this and you should see the instruction in the console git clone https://github.com/tauri-apps/tao.git
cd tao
cargo run --example theme
|
I can help test, how do I put in an input field element? Just switching themes won't crash, and neither will the sample repository I sent! Must be entered in the input field @Legend-Master I don't know how to put a web input box on the page in rust implementation |
This is so strange, I thought it's just from switching the theme, I don't quite know how to put an input box in a simple way but maybe you can try the simple example from wry? You will need to manually add in the switch theme code though
|
My video has demonstrated it clearly ah, you must enter text in the input box content and then the app will crash right in the auto theme! |
Sorry about that, I think I'll leave this to other members who has more knowledge about macos than me |
Here is the crash report for the failing thread. Error happens on I believe some invalid value has been passed to it and caused the crash.
BTW, this crash was produced on MacOS 14.4.1, other people had this problem on 15.0.1. |
I use tauri-plugin-theme and don't have problems with crash! |
Describe the bug
Reproduction case: https://github.com/ayangweb/tauri-input-demo
This bug is so tricky that I've been troubleshooting for ages to figure out the problem☹️ I don't really understand why it's having this problem
Currently, tested to be a stable reproduction only on macOS, The video is quite long, so please be patient
iShot_2024-10-16_23.41.35.mp4
In my development EcoPaste, I also can stable reproducing bug!
iShot_2024-10-16_23.51.29.mp4
Reproduction
No response
Expected behavior
No response
Full
tauri info
outputStack trace
No response
Additional context
This bug was reported by a user of EcoPaste, so it's not just my computer!
The text was updated successfully, but these errors were encountered: