feat(volkskrant): stop ad SDK initialisation at startup #24

Closed
opened 2026-10-10 12:22:31 +02:00 by midas · 0 comments
Owner

Part of #16.

Feature description

Hide ads stops every ad request, but the ad SDKs are still initialised at app start (already noted in docs/apps/volkskrant.md under "Not covered"). Skipping that init saves startup time, memory and network traffic. Extend Hide ads, or add it as an option there.

Findings (7.52.0)

  • nl.persgroep.edition.application.startup.task.AdvertisementStartupTask.onStartup() does almost nothing. It only calls userProfileSynchronizer.updateUserIds() and logs "StartupTask#onStartup advertisement completed".
  • The real initialisation is a side effect of Hilt injection:
    1. nl.persgroep.edition.di.AdvertisementModule$Companion.provideAdvertisementInitConfigHandler(...) builds be.persgroep.advertising.banner.config.InitConfigHandler.
    2. The constructor's coroutine InitConfigHandler$1 loads the shipped, cached or fetched init config.
    3. That calls SDKsInitializer.init(Context, InitConfig, CoroutineScope, Continuation), which initialises Xandr (initializeXandr, log "Xandr initialization timed out after") and the OptOut SDK (OptOutSDKConfigurator.initialize).
  • Prebid warm-up runs in HeaderBiddingWarmUp / PrebidHeaderBiddingSideEffect.
  • AdvertisementModule.provideAdManager returns initConfigHandler.getAdManager(), which Hide ads' AdManager.load path no longer reaches.
  • Google Mobile Ads auto-initialises through the manifest com.google.android.gms.ads.MobileAdsInitProvider (initOrder 100). There is no explicit MobileAds.initialize call.
  • IMA lives in the video SDK and in puzzles (GameAdPlayerImaModuleKt). It is already covered for video by the shared video-ads patch.

Approach

  • Short-circuit SDKsInitializer.init (return Unit; it is a suspend function, so check its return convention) and the Prebid warm-up.
  • Remove MobileAdsInitProvider with a resource patch on the manifest, or disable it through its meta-data.
    • Verify the app doesn't call MobileAds APIs anywhere else at startup; that would crash with the provider removed.
  • Keep InitConfigHandler constructible: getAdManager() must still return an object, because Hilt injects it.

Risk

The puzzles/games SDK may expect an initialised IMA or ad stack. Test a puzzle.

Done when

  • Build passes; patch applied on 7.52.0.
  • Device check (after asking): app start, home, an article, a video and a puzzle all work; logcat shows no Xandr or GMA init.
  • docs/apps/volkskrant.md: move the item out of "Not covered".
Part of #16. ## Feature description **Hide ads** stops every ad request, but the ad SDKs are still initialised at app start (already noted in `docs/apps/volkskrant.md` under "Not covered"). Skipping that init saves startup time, memory and network traffic. Extend **Hide ads**, or add it as an option there. ## Findings (7.52.0) - `nl.persgroep.edition.application.startup.task.AdvertisementStartupTask.onStartup()` does almost nothing. It only calls `userProfileSynchronizer.updateUserIds()` and logs "StartupTask#onStartup advertisement completed". - The real initialisation is a side effect of Hilt injection: 1. `nl.persgroep.edition.di.AdvertisementModule$Companion.provideAdvertisementInitConfigHandler(...)` builds `be.persgroep.advertising.banner.config.InitConfigHandler`. 2. The constructor's coroutine `InitConfigHandler$1` loads the shipped, cached or fetched init config. 3. That calls `SDKsInitializer.init(Context, InitConfig, CoroutineScope, Continuation)`, which initialises Xandr (`initializeXandr`, log "Xandr initialization timed out after") and the OptOut SDK (`OptOutSDKConfigurator.initialize`). - Prebid warm-up runs in `HeaderBiddingWarmUp` / `PrebidHeaderBiddingSideEffect`. - `AdvertisementModule.provideAdManager` returns `initConfigHandler.getAdManager()`, which **Hide ads**' `AdManager.load` path no longer reaches. - Google Mobile Ads auto-initialises through the manifest `com.google.android.gms.ads.MobileAdsInitProvider` (initOrder 100). There is no explicit `MobileAds.initialize` call. - IMA lives in the video SDK and in puzzles (`GameAdPlayerImaModuleKt`). It is already covered for video by the shared video-ads patch. ## Approach - Short-circuit `SDKsInitializer.init` (return `Unit`; it is a suspend function, so check its return convention) and the Prebid warm-up. - Remove `MobileAdsInitProvider` with a resource patch on the manifest, or disable it through its meta-data. - Verify the app doesn't call `MobileAds` APIs anywhere else at startup; that would crash with the provider removed. - Keep `InitConfigHandler` constructible: `getAdManager()` must still return an object, because Hilt injects it. ## Risk The puzzles/games SDK may expect an initialised IMA or ad stack. Test a puzzle. ## Done when - [ ] Build passes; patch applied on 7.52.0. - [ ] Device check (after asking): app start, home, an article, a video and a puzzle all work; logcat shows no Xandr or GMA init. - [ ] `docs/apps/volkskrant.md`: move the item out of "Not covered".
midas closed this issue 2026-10-10 23:26:46 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
midas/midas-patches#24
No description provided.