Skip to content

Warn at startup when a desktop native library fails to load - #1499

Open
sneurlax wants to merge 5 commits into
stagingfrom
fix/native-library-check-hybrid
Open

sneurlax wants to merge 5 commits into
stagingfrom
fix/native-library-check-hybrid

Conversation

@sneurlax

@sneurlax sneurlax commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

A tester's Windows Defender quarantined monero_libwallet2_api_c.dll; the app opened the wallet anyway and hung with no explanation.

On desktop, before any wallet loads, this tries to open each bundled native library in turn (Monero, Wownero, Salvium, and coinlib's secp256k1) on the main isolate. Failures are classified as missing, blocked by antivirus, or failed to load, logged once, and shown once as a single dialog when the home screen first appears, naming the affected wallets, the file, its expected path and the loader's error. On a fresh desktop install the same dialog shows on the "Restore from Stack Wallet backup" screen, which comes before any home view. The user dismisses it and nothing else changes.

Nothing on the open, create, restore, init or lock screen paths is touched: gates there would add overhead to every wallet and would lock a user out of a seed they can still reach through wallet settings. coinlib's synchronous throw on a missing secp256k1 is caught on desktop so the home screen can still warn; mobile is unchanged.

Verified on Linux with each library renamed away (desktop and mobile layouts), unit tests using the tester's loader messages, widget tests, and an Android compile. Windows not run.

Windows Defender quarantined monero_libwallet2_api_c.dll on a tester's
machine. The app opened the Monero wallet anyway, swallowed the load error
inside open(), and the wallet hung with no hint of what had gone wrong.

This adds a short table of the native libraries the desktop builds bundle
(Monero, Wownero, Salvium and coinlib's secp256k1) and tries to open each
one at startup, before any wallet loads. Failures are classified as
missing, blocked by antivirus or failed to load, logged once, and kept for
the home screen to show. The check runs sequentially on the main isolate
while nothing else is loading, so it adds nothing to wallet load time, and
it never throws.

Nothing on the open paths changes. Gating init() or open() on the check
would add overhead to every wallet and would lock a user out of a seed
they can still reach through wallet settings, so a broken library is
reported and the app otherwise behaves as before. This is a bandaid until
native assets or signed Windows DLLs.

coinlib's loader throws synchronously when secp256k1 won't open, which
would end main() before the home screen could warn. On desktop that error
is now kept for the check to report and startup continues; wallets that
need coinlib fail their own init as they do today. Mobile is unchanged.
The first time a home view appears after launch, show one dialog listing
what the startup check could not load: which wallets it affects, the file,
where it should be, and the loader's error. One failure gets the title "A
required file could not be loaded", several get "Some required files could
not be loaded" with each failure separated by a blank line.

The failures are handed over once, so coming back to the home screen
within the same run shows nothing. There is no retry button and nothing
else changes: after dismissing it the user can open, create and restore
wallets exactly as before, including a wallet whose library is broken, so
the seed in wallet settings stays reachable.
@sneurlax
sneurlax force-pushed the fix/native-library-check-hybrid branch from 3d84123 to 924b752 Compare November 3, 2026 20:27
@sneurlax sneurlax changed the title Check a coin's native library at startup and gate the wallet layer Warn at startup when a desktop native library fails to load Nov 3, 2026
On desktop a new install can go straight from the intro to "Restore from
Stack Wallet backup", which runs before any home view exists. With a
library missing, that restore would fail its Monero, Wownero or Salvium
wallets with nothing to say why, and the warning would only appear on the
home screen afterwards.

The restore screen now shows the same one-time dialog when it appears.
The failures are handed over once, so on an existing install, where the
home screen has already shown them, this screen shows nothing.
sneurlax and others added 2 commits November 3, 2026 15:36
CI formats every Dart file a PR touches, and these three were not in dart format's current style before this branch touched them. No code change.
@codecov

codecov Bot commented Nov 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 38.51852% with 83 lines in your changes missing coverage. Please review.
✅ Project coverage is 11.70%. Comparing base (cdb5aff) to head (0170552).
⚠️ Report is 6 commits behind head on staging.

Files with missing lines Patch % Lines
lib/pages/home_view/home_view.dart 0.00% 47 Missing ⚠️
...assword/forgotten_passphrase_restore_from_swb.dart 0.00% 18 Missing ⚠️
.../onetime_popups/native_library_warning_dialog.dart 35.71% 9 Missing ⚠️
lib/utilities/native_library_check.dart 90.38% 5 Missing ⚠️
lib/pages_desktop_specific/desktop_home_view.dart 0.00% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           staging    #1499      +/-   ##
===========================================
+ Coverage    11.64%   11.70%   +0.05%     
===========================================
  Files         1135     1138       +3     
  Lines       114334   114487     +153     
===========================================
+ Hits         13317    13401      +84     
- Misses      101017   101086      +69     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants