Skip to content

fix(desktop): resync device scale after display changes - #218

Merged
kolkov merged 2 commits into
gogpu:mainfrom
besmpl:agent/fix-device-scale-sync
Aug 11, 2026
Merged

fix(desktop): resync device scale after display changes#218
kolkov merged 2 commits into
gogpu:mainfrom
besmpl:agent/fix-device-scale-sync

Conversation

@besmpl

@besmpl besmpl commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • synchronize the UI canvas device scale from the current gogpu frame before the idle-render gate
  • invalidate scale-dependent retained scenes, repaint boundaries, overlays, textures, and layer state when the scale changes
  • add focused regressions for scale-only display transitions in both the app and desktop layers

Why

A window moving between displays with different scale factors can retain its logical size. In that case the resize path does not run, and RenderDirectWithDamageRects bypasses ggcanvas's later provider-scale check. The old device scale, boundary textures, and retained scene content can therefore survive the transition.

The new frame-level synchronization updates scale-dependent state before deciding that a frame is idle, ensuring the scale-change redraw produces correctly rasterized content.

Verification

  • go test ./... -count=1
  • go build ./...
  • CGO_ENABLED=0 go build ./...
  • focused app/desktop scale tests, including repeated and shuffled runs
  • focused race tests
  • go vet ./...
  • git diff --check

The broad go test -race ./app ./desktop run still reports the repository's pre-existing mockWindowProvider.RequestRedraw race in TestWindow_AnimPumper_StartsOnInvalidation; the changed desktop tests pass under -race.

Fixes #172

Local CI and Codecov preflight

  • rebased onto current main (273cc1e)
  • go test ./... -count=1 with an atomic coverage profile: pass
  • focused changed-behavior race suites: pass; the broad app/desktop race remains blocked only by the pre-existing TestWindow_AnimPumper_StartsOnInvalidation mock race noted above
  • go build ./..., go vet ./..., gofmt, and diff checks: pass
  • local Codecov-equivalent changed-production coverage: 30/30 statements (100%) (app/window.go 21/21, desktop/desktop.go 9/9); overall coverage 86.4%

Upstream CI run approval is still external to this branch: GitHub marked the fork workflow action_required with zero jobs (run 31434862113). A gogpu maintainer must approve the workflow before Actions and the configured Codecov upload/bot can run.

@besmpl
besmpl marked this pull request as ready for review August 10, 2026 17:04
@besmpl
besmpl requested a review from kolkov as a code owner August 10, 2026 17:04
@besmpl
besmpl force-pushed the agent/fix-device-scale-sync branch from 2857fda to c9d493c Compare August 10, 2026 21:39
@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@kolkov kolkov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

APPROVE

Well-structured two-layer fix:

  1. desktop/desktop.go:syncDeviceScale -- frame-level sync placed correctly before the O(1) idle gate and before boundary texture allocation. Releases boundary textures, resets canvas scale, delegates to Window.HandleScaleChange.

  2. app/window.go:HandleScaleChange + invalidateScenesInTree -- widget-level invalidation covering ADR-024 boundaries, legacy RepaintBoundaryMarker, and overlay content widgets.

Test coverage is thorough: 6 tests covering boundary invalidation (including the needsRedraw+cleanScene edge case), nil root safety, non-positive scale rejection, texture release + layer tree reset, and integration-level placement in the render loop.

The reflect+unsafe usage in device_scale_sync_test.go is consistent with the existing pattern in gpu_work_test.go -- acceptable for test code that has no alternative since gogpu.Context is only fully populated during a live frame.

CI green (9/9 checks pass). No blocking issues.

@kolkov
kolkov merged commit 2e83060 into gogpu:main Aug 11, 2026
9 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.

desktop: device scale never re-synced after a cross-display drag — window keeps rendering at the old display's scale (blurry / oversized)

2 participants