Skip to content

Stage aumid_nif.dll and bake opaque splash - #28

Merged
dominicletz merged 2 commits into
mainfrom
fix/aumid-nif-packaging
Nov 25, 2026
Merged

dominicletz merged 2 commits into
mainfrom
fix/aumid-nif-packaging

Conversation

@dominicletz

@dominicletz dominicletz commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Copy aumid_nif.dll from beside DESKTOP_HOST_BINARY into the AppUserModelId app release priv
  • Bake splash onto splash-window gray at 128x128 to avoid transparent gutter bands

Test plan

  • Out-of-tree host build with sibling nif stages into lib/desktop_webview-*/priv/native/windows
  • Packaged splash.png is opaque 128x128 on #dcdcdc

Note

Low Risk
Build-time packaging and splash image processing only; no runtime auth or data-path changes.

Overview
Windows splash assets now composite the configured splash_icon onto a 128×128 #dcdcdc canvas (centered overlay) instead of a plain 256×256 resize, so transparent gutters do not show as vertical bands in the native host splash.

For host-first Windows builds, packaging copies aumid_nif.dll from beside the native host binary into each release lib priv/native/windows that ships DesktopWebview.AppUserModelId, so BEAM can load the NIF when the host binary is built out-of-tree.

Reviewed by Cursor Bugbot for commit 3c8c805. Configure here.

Co-authored-by: Cursor <cursoragent@cursor.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: NIF staging skips apps without priv
    • Staging now finds the AppUserModelId app via lib/*/ebin and creates priv/native/windows, so a Mix release that omitted an empty priv directory still receives aumid_nif.dll.
Preview (8f0a7e4d39)
diff --git a/lib/package.ex b/lib/package.ex
--- a/lib/package.ex
+++ b/lib/package.ex
@@ -187,11 +187,26 @@
       raise "package.splash_icon not found: #{path}"
     end
 
-    # Keep a PNG next to the host for the Windows splash (GDI+ loads PNG).
-    # Resize for a crisp splash mark without shipping a multi‑MB source asset.
+    # Bake onto the splash window gray (#dcdcdc) at the draw size (128) so
+    # transparent gutters cannot show as vertical bands on the host UI.
     # Force-overwrite: Mix :assemble may already have copied priv/splash.png
     # into the release, and priv_import! skips existing files.
-    cmd!("magick", ["convert", "-resize", "256x256", path, "splash.png"])
+    cmd!("magick", [
+      "convert",
+      "-size",
+      "128x128",
+      "xc:#dcdcdc",
+      path,
+      "-resize",
+      "128x128",
+      "-gravity",
+      "center",
+      "-compose",
+      "over",
+      "-composite",
+      "splash.png"
+    ])
+
     dst = Path.join(priv(pkg), "splash.png")
     File.mkdir_p!(priv(pkg))
     File.cp!("splash.png", dst)

diff --git a/lib/package/windows.ex b/lib/package/windows.ex
--- a/lib/package/windows.ex
+++ b/lib/package/windows.ex
@@ -38,6 +38,7 @@
     host_dest = Path.join(package_root, host_name)
     File.cp!(host_bin, host_dest)
     IO.puts("Host-first Windows/#{host_name} <- #{host_bin}")
+    maybe_stage_aumid_nif!(host_bin, path)
 
     # Explorer/taskbar use the host PE icon. copy_extra_files embeds the icon into
     # the renamed erts erl.exe, but the native host is a separate copy and must
@@ -137,6 +138,31 @@
     end
   end
 
+  # Out-of-tree host builds often emit aumid_nif.dll beside DesktopWebView.exe.
+  # BEAM loads it from :code.priv_dir of the app that owns
+  # DesktopWebview.AppUserModelId. Mix omits an empty priv directory, and
+  # :code.priv_dir still points there, so find the app by its ebin beam and
+  # create priv/native/windows.
+  defp maybe_stage_aumid_nif!(host_bin, release_path) do
+    nif_src = Path.join(Path.dirname(host_bin), "aumid_nif.dll")
+
+    if File.exists?(nif_src) do
+      dests =
+        for ebin <- Path.wildcard(Path.join(release_path, "lib/*/ebin")),
+            File.exists?(Path.join(ebin, "Elixir.DesktopWebview.AppUserModelId.beam")),
+            do: Path.join(Path.dirname(ebin), "priv/native/windows")
+
+      for dest_dir <- Enum.uniq(dests) do
+        File.mkdir_p!(dest_dir)
+        dest = Path.join(dest_dir, "aumid_nif.dll")
+        File.cp!(nif_src, dest)
+        IO.puts("Host-first Windows/aumid_nif.dll <- #{nif_src} -> #{dest}")
+      end
+
+      :ok
+    end
+  end
+
   # Host and BEAM must call SetCurrentProcessExplicitAppUserModelID with the
   # same value (package.identifier) so Task Manager groups them. The host reads
   # this from ini; BEAM gets it via EDW_APP_USER_MODEL_ID from the host.

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit 3c8c805. Configure here.

Comment thread lib/package/windows.ex Outdated
File.exists?(
Path.join(release_priv, "../ebin/Elixir.DesktopWebview.AppUserModelId.beam")
),
do: Path.join(release_priv, "native/windows")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIF staging skips apps without priv

Medium Severity

maybe_stage_aumid_nif! discovers the AppUserModelId app by globbing lib/*/priv and only then checking for the beam file. Mix releases omit priv when that app has none yet, which is likely for out-of-tree host builds whose NIF is the sibling this function is meant to copy. If aumid_nif.dll exists beside the host but priv does not, the wildcard is empty, staging is skipped with no log, and the packaged BEAM never gets the NIF.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 3c8c805. Configure here.

Mix releases omit an empty priv directory, so globbing lib/*/priv skipped
the out-of-tree sibling NIF. Search lib/*/ebin and create priv/native/windows.
@dominicletz
dominicletz merged commit 0b5fe51 into main Nov 25, 2026
2 checks passed
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