Skip to content

feat(admob): add dispose(handle:) for live banner cleanup (#221) - #275

Merged
wei18 merged 1 commit into
mainfrom
feat/admob-dispose-handle-221
Jun 3, 2026
Merged

wei18 merged 1 commit into
mainfrom
feat/admob-dispose-handle-221

Conversation

@wei18

@wei18 wei18 commented Jun 3, 2026

Copy link
Copy Markdown
Owner

Closes #221.

Threads dispose(handle:) async through AdProvider + the internal AdMobBridge seam, with real GADBannerView teardown in LiveAdMobBridge (drop the liveBanners retain, then delegate = nil + removeFromSuperview() on the main actor) and no-op/record impls in Noop/Fake. Call sites: BannerSlotView (Sudoku) + MinesweeperBannerSlotView (MS mirror) .onDisappear. Removes the NOTE(#221) placeholder.

Verification: AppMonetizationKit swift test → 103 tests in 16 suites pass; AdMob isolation audit import GoogleMobileAds count = 1; SudokuUI + MinesweeperUI build (both call sites).

Code Review verdict: APPROVE-WITH-NITS. Concurrency confirmed race-free (the removeValue-then-MainActor.run hop hands a sole-owned reference across, identical to the established loadBanner precedent); idempotency holds across all five impls. Two non-blocking nits deferred to a follow-up:

  • (Med) .onDisappear dispose timing: paired with .task, so transient SwiftUI teardowns (tab switch, list recycling, split-pane churn) trigger dispose→.task-reload thrash — safe (idempotent, handle never stale) but spends redundant ad requests + re-flickers on return. Mitigation (gate dispose on gate-close/handle-change) tracked in follow-up.
  • (Low) post-dispose status .notInitialized is semantically loose (SDK stays started); harmless because refreshBanner() guards on didStart, not status, and the view doesn't re-read bannerStatus after dispose.
  • (Med) coverage gap: the live #if canImport(GoogleMobileAds) teardown isn't exercised in SwiftPM macOS CI (only the fake bridge path is). Verified by reasoning; teardown is 3 trivial main-actor lines mirroring the load path.

🤖 Generated with Claude Code

LiveAdMobBridge retained every BannerView in liveBanners for the handle's
lifetime. Add a dispose(handle:) path so consumers (BannerSlotView on
disappear) can release the entry + tear down the view on the main actor.
Removes the NOTE(#221) placeholder. AdMob SDK isolation unchanged (1 import).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@wei18
wei18 merged commit d67574f into main Jun 3, 2026
@wei18
wei18 deleted the feat/admob-dispose-handle-221 branch June 3, 2026 08:46
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.

AdMob: implement dispose(handle:) accessor for liveBanners cleanup

1 participant