Skip to content

Prevent blank-screen launch when the auto-start registry key is missing (Windows)#2239

Open
jabagawee wants to merge 2 commits into
hiddify:mainfrom
jabagawee:fix/auto-start-registry-crash
Open

Prevent blank-screen launch when the auto-start registry key is missing (Windows)#2239
jabagawee wants to merge 2 commits into
hiddify:mainfrom
jabagawee:fix/auto-start-registry-crash

Conversation

@jabagawee

Copy link
Copy Markdown
Contributor

Problem

On Windows, AutoStartNotifier.build() awaits launchAtStartup.isEnabled(), which reads HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run. The launch_at_startup package opens that key without handling its absence, so on a fresh Windows install where no application has registered a startup entry yet and the key does not exist, it throws instead of returning false.

That throw propagates out of build(), and bootstrap initializes the auto start service through _init, which rethrows. The rethrow aborts lazyBootstrap before runApp() is reached, so the app shows a blank screen with no UI.

Fix

  • auto_start_notifier.dart: read the status through a new _isEnabledSafe() that treats any read failure as disabled. A missing key means auto start is not registered, so false is the correct status. The periodic updateStatus() refresh uses the same guard.
  • bootstrap.dart: initialize the auto start service through _safeInit instead of _init, matching the system tray and other non-critical desktop services, so its failure cannot prevent launch.

On a fresh Windows install the HKEY_CURRENT_USER CurrentVersion\Run
key may not exist yet. The launch_at_startup package opens that key
in isEnabled() without handling its absence, so it throws a
WindowsException instead of returning false, and the exception
propagates out of the auto start notifier's build().

This commit wraps the isEnabled() call in _isEnabledSafe(), which
treats any read failure as disabled. A missing key means auto start
is not registered, so false is the correct status. The periodic
updateStatus() refresh uses the same guard.
The auto start service initialized through _init, which rethrows on
failure. A throw there aborts lazyBootstrap before runApp() is
reached, leaving the app on a blank screen with no UI.

This commit switches it to _safeInit so a failure is logged and
swallowed instead of aborting startup, matching how the system tray
and other non-critical desktop services are already initialized.
Auto start is not required for the app to run, so its failure should
not prevent launch.
@aima666qs-commits

Copy link
Copy Markdown

!

@bradatkinson96

Copy link
Copy Markdown

If this works, a great find!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants