Skip to content

Conversation

@leaanthony
Copy link
Member

@leaanthony leaanthony commented Dec 17, 2025

Summary

  • Check current DPI awareness before calling SetProcessDpiAwarenessContext
  • Windows only allows setting DPI awareness once per process - either via manifest or API, not both
  • If already set (e.g., via application manifest in built binaries), skip the API call to avoid "Access is denied" errors

Problem

When using wails3 dev or running built binaries, users see the error:

SetProcessDpiAwarenessContext failed 0: 18446744073709551612 Access is denied.

This happens because:

  1. Built binaries have a manifest file that sets DPI awareness
  2. At runtime, setupDPIAwareness() tries to call SetProcessDpiAwarenessContext
  3. Windows rejects the API call since DPI awareness was already configured

Solution

Added GetProcessDpiAwareness() to query the current DPI awareness level before attempting to set it. If awareness is already configured (not PROCESS_DPI_UNAWARE), the API call is skipped.

Test plan

  • Build a Wails app with wails3 build and verify no DPI error appears
  • Run with go run and verify DPI awareness is correctly set via API
  • Test on Windows 10/11 with various DPI settings

Fixes #4803

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added runtime DPI-awareness detection so the app can determine current DPI configuration before adjusting settings.
  • Bug Fixes
    • Prevents an "Access is denied" error at startup when DPI awareness is already set (e.g., via application manifest) by skipping redundant reconfiguration.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 17, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adds a pre-check to skip setting DPI awareness if already configured (e.g., via app manifest) and exposes GetProcessDpiAwareness bindings to query current DPI awareness from shcore.dll, preventing "Access is denied" errors when DPI is pre-set.

Changes

Cohort / File(s) Summary
Changelog entry
v3/UNRELEASED_CHANGELOG.md
Documents bug fix: avoid "Access is denied" from SetProcessDpiAwarenessContext when DPI awareness is already set
DPI awareness pre-check
v3/pkg/application/application_windows.go
Adds early-return in setupDPIAwareness: if GetProcessDpiAwareness reports a set state (not PROCESS_DPI_UNAWARE), skip subsequent SetProcessDpiAwarenessContext/SetProcessDpiAwareness calls
Windows API bindings
v3/pkg/w32/shcore.go
Adds procGetProcessDpiAwareness, HasGetProcessDpiAwarenessFunc(), and GetProcessDpiAwareness() to query process DPI awareness at runtime

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

Bug, go, Windows, v3-alpha, size:M

Poem

🐰 I peeked at DPI with a twitchy nose,
If manifest set it, I quietly doze.
No more denied—just a gentle hop,
Skipping the call, and I’m off to the crop. 🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a check to skip DPI awareness API calls when already set via manifest, which directly addresses the fix for issue #4803.
Description check ✅ Passed The description includes a clear summary of the problem and solution, references the fixed issue (#4803), and provides a test plan. Most template sections are addressed, though some checklist items are not explicitly confirmed.
Linked Issues check ✅ Passed The PR successfully addresses issue #4803 by implementing GetProcessDpiAwareness() to check current DPI awareness and skip redundant API calls, preventing 'Access is denied' errors when DPI awareness is already set via application manifest.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the DPI awareness issue: additions to the Windows bindings (w32/shcore.go), modifications to DPI setup logic (application_windows.go), and changelog documentation.
✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Dec 17, 2025

Deploying wails with  Cloudflare Pages  Cloudflare Pages

Latest commit: a4a2fbe
Status:⚡️  Build in progress...

View logs

Check current DPI awareness before calling SetProcessDpiAwarenessContext.
Windows only allows setting DPI awareness once per process - either via
manifest or API, not both. If already set (e.g., via application manifest
in built binaries), skip the API call to avoid "Access is denied" errors.

Fixes #4803

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@sonarqubecloud
Copy link

@leaanthony leaanthony merged commit 8d28e2d into v3-alpha Jan 21, 2026
13 of 16 checks passed
@leaanthony leaanthony deleted the vk/e67e-setdpi-issue branch January 21, 2026 08:23
@sonarqubecloud
Copy link

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