Skip to content

fix(monetization): reserve the banner slot height before the ad loads - #729

Merged
wei18 merged 1 commit into
mainfrom
fix/723-banner-slot-reserve
Jul 8, 2026
Merged

wei18 merged 1 commit into
mainfrom
fix/723-banner-slot-reserve

Conversation

@wei18

@wei18 wei18 commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Closes #723 — owner-observed: the Sudoku board shrank mid-game when the AdMob banner loaded (layout jump during play).

What (5 files, +/− small; AdGate + BannerSlotView + 3 test files)

  • AdGate (MonetizationCore): new lastKnownShouldShowBanner — a Mutex<Bool?>-backed nonisolated session hint recording the last authoritative shouldShowBanner resolution; recordBannerDismissed/recordPurchase eagerly flip it false. Decision logic char-identical — the 5-rule body moved verbatim into a private resolveShouldShowBanner; the public wrapper writes the hint at its single exit point.
  • BannerSlotView (MonetizationUI): init seeds shouldShow from the hint → once the session's gate has allowed, any later-mounted slot (Home→Board is the typical flow) reserves its 50pt from FIRST layout; the ad load only fills content. Gate-denied stays EmptyView. The hint never touches status, so a real ad can never mount ahead of the live gate resolution (architecturally proven by both reviewers).
  • First banner-visible snapshot coverage in the repo: 4 new fixtures (hasPurchasedRemoveAds: false, unloaded 50pt spinner state, light+dark, both apps) — closes the coverage gap recorded in chore(polish): dark banner seam, ms settings tint parity, sudoku pause a11y id (#688 items 2/5a/5b) #725's review. All existing baselines byte-untouched (every PNG in the stat is Bin 0 -> N).

Known residual (deliberate, documented in-code): the cold-launch FIRST screen still has one layout settle (no prior resolution exists to hint from). The reported in-game jump is eliminated.

Verification

  • AppMonetizationKit 120/120 (full) incl. new AdGateLayoutHintTests 6/6 (nil-before / mirror allow+deny / eager flips / day-rollover reopen); SudokuKit 270/270; MinesweeperKit 189/189; GameAppKit 29/29.
  • Real-sim walkthrough with live test ads: board cell + toolbar coordinates identical at t≈0.5s and t≈10s (frames in session scratchpad).
  • swiftlint --strict 0; import GoogleMobileAds still exactly one file (scan:admob invariant).

Review

Money-tier dual review (sonnet + opus), both approve, no BLOCKER/MAJOR. Sonnet verified the decision-logic move char-by-char and the shouldShow/status separation; opus exhaustively walked every purchaser/dismissed path (hint can never be true for them; a stale seed-true converges to a self-correcting blank, never an ad). Two MINOR observations recorded in the review thread, neither requiring change.

🤖 Generated with Claude Code

Owner-observed bug: on the Sudoku game screen the board frame shrank
when the AdMob banner appeared - a mid-game layout jump. The shared
BannerSlotView only entered layout after the async AdGate resolution
landed, so every screen reflowed when the slot materialized.

Fix (shared MonetizationUI/MonetizationCore, both apps):
- AdGate gains a synchronous session hint (lastKnownShouldShowBanner,
  Mutex-backed, nonisolated) recording the latest shouldShowBanner
  resolution; recordBannerDismissed/recordPurchase eagerly flip it to
  false. The decision logic itself is unchanged (split into
  resolveShouldShowBanner).
- BannerSlotView seeds its show/hide state from that hint at init, so
  any slot mounted after the gate has resolved once (Board entered
  from Home, hubs, Settings) reserves its 50pt from the very first
  layout; ad load only fills the already-reserved rect. Gate-denied
  (Remove Ads / dismissed today) still collapses to EmptyView, and the
  pre-first-resolution cold-launch default is unchanged - so all
  existing purchased-state snapshot baselines stay byte-identical.

Coverage:
- AdGateLayoutHintTests: 6 unit tests pinning the hint lifecycle.
- First ads-enabled (hasPurchasedRemoveAds: false) snapshot fixtures
  in the repo (per the #725 review note): Sudoku BoardViewBannerTests
  + MinesweeperBoardSnapshotTests, light + dark, unloaded spinner slot
  reserved at 50pt. All pre-existing baselines pass unchanged.
- Sim-verified on iPhone 17 Pro: board frame identical before/after
  the test ad loads (row-1 cell y=137.75, toolbar y=542 in both).

Closes #723

Co-Authored-By: Claude Fable 5 <[email protected]>
@wei18
wei18 enabled auto-merge (squash) July 8, 2026 02:52
@wei18
wei18 merged commit 4d8d40b into main Jul 8, 2026
4 checks passed
@wei18
wei18 deleted the fix/723-banner-slot-reserve branch July 8, 2026 02:52
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.

fix(monetization): banner load reflows the sudoku board — reserve the slot height up front

1 participant