Fix blurred Google Sheets canvas rendering

Merged
AU
4mo ago
+37-12

Summary

  • stop forcing standalone Safari identity onto embedded WKWebViews, which made Google Sheets choose a half-resolution canvas rendering path
  • restore the native embedded WebKit identity at WebView creation, top-level navigation, reload preparation, and popup creation
  • keep the Safari-style user agent only for auxiliary URLSession requests
  • remove the earlier reveal-geometry policy changes after controlled experiments disproved geometry as the cause
  • add a runtime regression test that seeds a legacy custom identity and verifies navigation clears it

Closes #8657

Root cause evidence

The same public Google Sheet was loaded in controlled stock WKWebViews:

  • native embedded WebKit identity: devicePixelRatio 2 and canvas backing/CSS ratio 2.0 (sharp)
  • cmux forced Safari identity: devicePixelRatio 2 but canvas backing/CSS ratio 0.5 (blurred)

Layer wrapping, synchronous geometry nudging, and hide/resize/reveal remained sharp in isolation, so the prior geometry hypothesis was rejected.

Validation

  • tagged Debug build succeeded with scripts/reload.sh --tag issue8657-fix --launch --swift-frontend-workaround
  • live tagged-app evaluation on the reported Sheet: visible canvas 2166 x 1232 for 1083 x 616 CSS, ratio 2.0 on both axes
  • captured a 2190 x 1920 browser screenshot showing crisp grid and text
  • swiftc frontend parse passed for the changed Swift and test files
  • git diff --check passed
  • focused app-host XCTest was not run locally because this shared Mac had multiple Xcode build-service deadlocks; CI is the runtime test authority

Review notes

  • CodeRabbit suggestion about making browserPortalAllowsFirstSizedRevealGeometryNudge default false is superseded: the current head removes that property and its configuration function entirely with the disproven geometry-policy approach
  • regression test is commit b71e98d77a; implementation is commit 6b55250b68
  • no user-facing strings changed; localization audit found no changed localized surfaces