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

  • Bug Fixes
    • Fixed "Access is denied" error that occurred during application startup when DPI awareness was already configured through the application manifest. The application now checks for existing DPI awareness settings before attempting reconfiguration, preventing redundant configuration attempts and associated access denial errors.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 17, 2025

Warning

Rate limit exceeded

@leaanthony has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 20 minutes and 22 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between d216776 and 9d82164.

📒 Files selected for processing (3)
  • v3/UNRELEASED_CHANGELOG.md (1 hunks)
  • v3/pkg/application/application_windows.go (1 hunks)
  • v3/pkg/w32/shcore.go (1 hunks)

Walkthrough

This PR fixes an "Access is denied" error in SetProcessDpiAwarenessContext by adding a pre-check to determine if DPI awareness is already set via application manifest. If detected, the setup returns early, preventing redundant configuration. The fix includes new Windows API bindings for GetProcessDpiAwareness.

Changes

Cohort / File(s) Summary
Changelog entry
v3/UNRELEASED_CHANGELOG.md
Documents bug fix for SetProcessDpiAwarenessContext "Access is denied" error
DPI awareness pre-check
v3/pkg/application/application_windows.go
Adds early-return logic in setupDPIAwareness to skip DPI configuration if awareness is already set via manifest
Windows API bindings
v3/pkg/w32/shcore.go
Introduces HasGetProcessDpiAwarenessFunc() and GetProcessDpiAwareness() to query current DPI awareness state from shcore.dll

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Windows API binding declarations in shcore.go should be verified for correctness and proper error handling
  • Early-return logic in application_windows.go should be confirmed to handle all DPI awareness states correctly

Suggested labels

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

Poem

🐰 Hop, check, and return!
When DPI awareness is already set,
No need to call again with regret—
A pre-flight check saves the day,
No more "Access denied" in the way! ✨

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.

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: d216776
Status:🚫  Build failed.

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 <[email protected]>
@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