In a casual mobile game, the bundled ads SDK crashes at launch on one OS version; how would you design a kill switch for it?
answer
- the guard ships before the bug
- read from disk, then initialise
- narrow by OS and app version
- nothing stored yet on a fresh install
- every placement has a no-ads path
basics
~20 sGuard the SDK's start with a switch read from stored configuration before the SDK initialises, targeted by OS and app version, and make the game run without ads; add a local crash-loop guard for phones with nothing stored.
solid answer
~40 sThe switch has to be in the build before the crash is, wrapping the one place the SDK is started. At launch the app reads it from the configuration saved on disk, *before* initialising the SDK; a value arriving from the network a second later is too late when the crash happens during initialisation. The rule targets the OS version, the app version and, if needed, device models, so ads keep earning everywhere else. Every ad placement needs a no-ads path, so a rewarded-ad button disappears instead of spinning. For a fresh install that has nothing stored, start the SDK only after the first fetch attempt, and keep a local counter that skips it after repeated crashed starts.
code
pseudocode · 14 lineson launch:
config = stored_config_on_disk() or compiled_defaults()
crashed = read_counter("ads_crashed_starts")
if read_marker("ads_start_in_progress"): # last launch died inside the ads start
crashed = crashed + 1
save_counter("ads_crashed_starts", crashed)
clear_marker("ads_start_in_progress")
if config.ads_enabled_for(device_context()) == false or crashed >= 2:
use_no_ads_placements() # rewarded button hidden, no banners
else:
write_marker("ads_start_in_progress")
start_ads_sdk()
clear_marker("ads_start_in_progress")
save_counter("ads_crashed_starts", 0)go deeper
Recall that a kill switch is a remote value the shipped code checks before running a path, and that it only works where that check already exists.
Explain the launch order: stored configuration read from disk, the switch evaluated for this device, and only then the SDK's initialisation, plus the no-ads path for each placement.
Cover the fresh install with nothing stored: deferring the SDK until a fetch attempt and a local crash-loop counter, including the delayed-crash case the marker misses.
Argue for a rule that every third-party SDK ships behind a start-up guard, weighing the integration cost against the days a store fix takes to reach players.
## The switch exists before the crash does A **kill switch** is a remotely controlled value that the shipped code checks before running a path, so the team can turn that path off without a store release. It only works where the code already checks it. A casual game carries an ads SDK, a purchase store SDK and others; the time to wrap each third-party start-up in a guard is when the SDK is first integrated, not when one of them starts crashing after an OS update. A guard added in the fix release protects only players who install that release. ## Read before initialising The crash here happens *during* the SDK's initialisation, early in launch. That fixes the order of operations: 1. Load the stored configuration from disk (or compiled defaults when none exists). 2. Evaluate the ads switch for this device. 3. Only then decide whether to initialise the SDK. If the app instead fetches configuration and reads the switch from the response, the fetch is still in flight when the process dies, and every launch repeats the crash. A stored value means the fix that one launch fetched protects the next launch, even offline on the underground. ## Targeting keeps the fix narrow Turning ads off for everyone stops the crash and also stops the revenue on every phone that was fine. The rule should match only what is broken: - **OS version** — the crash appears on one release of the operating system; - **app version** — perhaps only builds bundling one SDK version are affected; - **device model** — sometimes needed when one manufacturer's build of the OS misbehaves. The device supplies these attributes as its evaluation context. Whether rules are evaluated on the server or on the device is a general flag-design question; what matters here is that OS version is part of the context at all. ## The phone with nothing stored A player who updates the OS and then installs the game for the first time has no stored configuration, so the compiled default applies, and for an ads SDK it is usually *on*. Two defences cover that gap: - **Start the SDK after the first fetch attempt.** Ads are not needed in the first seconds of a puzzle game; deferring the start until the fetch has succeeded, failed or timed out lets a fresh install learn the switch before the risky code runs. - **A local crash-loop guard.** Write a marker before starting the SDK and clear it once the start returns. If the next launch finds the marker, the previous launch died inside the start; after a small number of such launches (two, in this design's assumption) the app skips the SDK on its own, with no network at all. Reset the counter when the app version changes. An SDK that crashes a few seconds later on its own thread needs the marker cleared after a survival window instead. ## The game without the SDK The switch is only half the design; the other half is a game that still works with the SDK absent. | Placement | With the SDK off | |---|---| | Banner between levels | no banner, layout closes the gap | | Interstitial after a level | skipped, play continues | | "Watch an ad for extra moves" | button hidden; an in-app purchase offer may stand in | | Daily challenge reward ad | reward granted another way or offer withdrawn | A placement that waits forever for an ad that will never load is a second bug introduced by the fix. ## What the switch cannot do - It cannot reach builds that have no guard around the SDK; for those, only a fixed release or a minimum-version gate helps. - It cannot patch the SDK; the real fix is a store release with a corrected SDK version, and the switch buys the days that release needs. - It does not detect the crash. Seeing the spike on one OS version comes from crash reporting split by version; the switch is the lever the team pulls afterwards. A useful habit is to record, with each launch's diagnostics, whether the guarded SDK was started, skipped by the switch or skipped by the crash-loop guard, so the team can tell a fixed crash from one that was merely avoided.
- The SDK crashes on its own background thread a few seconds after a successful start; does the marker still work?Not as written, because the marker is cleared as soon as the start call returns. Clear it only after the app has survived a short window after the start, or after the first ad loads, so a delayed crash still leaves the marker set. The window length is a design assumption, tuned against how quickly the crash appears in reports.
- When should the team turn the SDK back on for the affected OS version?Only once a build with a fixed SDK exists, and then by narrowing the rule to the old app versions instead of deleting it: builds that still bundle the broken SDK must stay switched off. Re-enable for the fixed version on a small share first and watch crash reports for that OS and app version before widening.
- Read the kill switch from the fetch response so the value is the newest.
- A kill switch added in the fix release also protects players on older builds.
- Switch the SDK off for every player; the narrow rule is not worth the effort.
- The crash-reporting service will disable a crashing SDK by itself.
- Keep the ad placements unchanged; they will simply load nothing.