Fix WebView2 data directory failing on non-ASCII user profile paths#100
Fix WebView2 data directory failing on non-ASCII user profile paths#100hanos5 wants to merge 3 commits intoSamsidParty:mainfrom
Conversation
… height calculation
fix: dynamically resize window height based on selected monitor aspect ratio
|
Oh, I just found the Ascii.IsValid method. I think I can refactor the code to be much cleaner using this. Ascii.IsValid Method Please bear with me as I'm still learning the Git workflow. |
|
Hello, I appreciate your pull request, however this seems to be a problem that should be fixed within IgniteView not TopNotify. I was unable to find any reports of non-ASCII characters tripping up webview2 outside of this one so I believe it's an issue in IgniteView string marshalling not with WebView2 or TopNotify. I will try to fix it within IgniteView, thank you for the PR. |
|
Thank you for reviewing my PR and for your thoughtful feedback. Actually, this was my very first PR in the open-source community! I'm so excited and touched by your kind response. Open source is truly wonderful. I’m a big fan of TopNotify and find it incredibly useful. Thank you for all your hard work. Please let me know if there’s anything else I can help with, such as testing. I’d be happy to assist! |
Problem
When the Windows username contains non-ASCII characters (e.g. Japanese, Chinese, Korean), the IgniteView/WebView2 data directory path includes those characters. WebView2 cannot read or write to paths containing non-ASCII characters, causing the settings GUI to fail to launch with the error:
This is because AppIdentity.AppDataPath resolves to %LOCALAPPDATA%\IgniteViewApp\topnotify, which includes the user profile path. When DesktopWebWindow passes this path to WebView2 as its user data folder, WebView2 fails to handle the non-ASCII characters.
Solution
Introduced AsciiSafeAppIdentity, a subclass of AppIdentity that overrides AppDataPath to use CommonApplicationData (C:\ProgramData) instead of LocalApplicationData (C:\Users<username>\AppData\Local). The C:\ProgramData path is always ASCII-safe.
After ViteAppManager is initialized but before any WebWindow is created, the code checks whether the default AppDataPath contains non-ASCII characters. If it does, CurrentIdentity is replaced with the ASCII-safe variant.
Changes
Impact