chore: [SDK-4213] remove background-threading FF, make async init default#2668
Open
abdulraqeeb33 wants to merge 10 commits into
Open
chore: [SDK-4213] remove background-threading FF, make async init default#2668abdulraqeeb33 wants to merge 10 commits into
abdulraqeeb33 wants to merge 10 commits into
Conversation
…ault The sdk_background_threading remote flag is fully rolled out, so the background/async path is now the unconditional default and all FF gating is removed: - Drop SDK_BACKGROUND_THREADING from FeatureFlag and its FeatureManager side-effect; delete ThreadingMode. - Collapse all ThreadUtils branches to the OneSignalDispatchers path and rename runOnSerialIOIfBackgroundThreading -> runOnSerialIO. - OneSignalImp: remove isBackgroundThreadingEnabled, the featureManager field, the injectable ioDispatcher param, and the now-dead requireInitForOperation / warnIfBlockingOnMainThread. initWithContext always dispatches init asynchronously, eliminating the FF/cached-config read from the init decision path. - StartupService / OneSignalCrashUploaderWrapper: always run async. - Update tests to the default async behavior; rename ThreadUtilsFeatureFlagTests -> ThreadUtilsDispatchTests. Co-authored-by: Cursor <cursoragent@cursor.com>
…#2653) Co-authored-by: Nan <nan@onesignal.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: AR Abdul Azeez <abdul@onesignal.com> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Fadi George <fadii925@gmail.com>
…SDK-4803] (#2667) Co-authored-by: AR Abdul Azeez <abdul@onesignal.com>
Co-authored-by: github-actions[bot] <noreply@onesignal.com>
origin/main already modernized ThreadUtils/OneSignalDispatchers and removed ThreadingMode; fix the remaining stale ThreadingMode doc reference in OneSignalDispatchers.prewarm now that background dispatch is unconditional. Co-authored-by: Cursor <cursoragent@cursor.com>
With background threading now unconditional, all dispatch routes through the shared OneSignalDispatchers pool. Fix the resulting unit-test fallout: - OneSignalDispatchers: add a test-only resetForTest() backed by a swappable Pools holder so each spec starts with a clean pool (shutdownNow + recreate executors/dispatchers/scopes), preventing cross-spec pool saturation. - OneSignalTestProjectConfig: new Kotest AbstractProjectConfig that calls resetForTest() before/after every spec for process-wide isolation. - FeatureFlagsRefreshServiceTests: wrap the launchOnIO no-op stub in try/finally so the mock no longer leaks into HttpClientTests/OperationRepoTests. - SessionServiceTests: register IOMockHelper so runOnSerialIO dispatch is inline and the focus/duration assertions are deterministic. - SDKInitTests: mark test-spawned threads as daemon so a stray blocked init thread can never keep the JVM alive (fixes the 6h CI hang). Production waitForInit semantics unchanged. - NotificationGenerationProcessorTests: dispatch launchOnIO on a real Dispatchers.IO-backed scope (mirroring the prior GlobalScope path) so the withTimeout-guarded external callbacks can be cancelled instead of hanging inside IOMockHelper's inline runBlocking. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com> # Conflicts: # OneSignalSDK/onesignal/core/src/main/java/com/onesignal/common/threading/OneSignalDispatchers.kt
Contributor
📊 Diff Coverage ReportDiff Coverage Report (Changed Lines Only)Gate: aggregate coverage on changed executable lines must be ≥ 80% (JaCoCo line data for lines touched in the diff). Changed Files Coverage
Overall (aggregate gate)127/183 touched executable lines covered (69.4% — requires ≥ 80%) Per-file detail (informational; gate is aggregate above):
❌ Coverage Check FailedAggregate coverage on touched lines is 69.4% (minimum 80%). |
… comments Make OneSignalImp.ioDispatcher a get() accessor instead of an eagerly captured val. The eager field forced the lazy pools.IO executor/dispatcher to construct during OneSignalImp construction (on the main thread, before initWithContext's prewarm() runs), partially defeating SDK-4507/4794, and pinned the instance to a single pool generation so a reused instance could dispatch onto a shutdownNow()'d executor after resetForTest() swaps pools. Also remove stale feature-flag comments left over from the background- threading FF removal: BackgroundManager.onFocus's "FF gates the rollout" note and internalInit's catch block describing the removed two-arm FF-on/FF-off design. Document that the synchronous initWithContext always returns true and does not reflect init success. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
sdk_background_threadingremote feature flag is fully rolled out (100%), so this removes the flag entirely and makes the background/async init path the unconditional default. This eliminates the FF/cached-config read from the init decision path (the StrictMode bootstrap disk-read goal) and removes the legacy synchronous-blocking code path.Resolves SDK-4213.
Production changes
FeatureFlag.kt— removed theSDK_BACKGROUND_THREADINGenum entry. The genericFeatureActivationModeframework andSDK_IDENTITY_VERIFICATIONremain.ThreadingMode.kt— deleted (it only existed to holduseBackgroundThreading).ThreadUtils.kt— collapsed everyif (ThreadingMode.useBackgroundThreading) … else …branch to theOneSignalDispatcherspath, dropping the legacythread { runBlocking { … } }/GlobalScope.launchfallbacks. RenamedrunOnSerialIOIfBackgroundThreading→runOnSerialIOand updated all call sites.OneSignalImp.kt— removedisBackgroundThreadingEnabled, thefeatureManagerfield, the injectableioDispatcherconstructor param, and the now-deadrequireInitForOperation/warnIfBlockingOnMainThread.initWithContextalways dispatchesinternalInitviasuspendifyOnIO(never blocks the caller);login/logout/updateUserJwt/JWT-listener methods always usewaitForInit; suspend accessors useOneSignalDispatchers.IOdirectly.StartupService.kt— removed theIFeatureManagerlookup;scheduleStart()always launches onOneSignalDispatchers.launchOnDefault.OneSignalCrashUploaderWrapper.kt— removed the FF check instart(); always launches on IO (featureManagerstill injected for OTel telemetry).FeatureManager.kt— removed theSDK_BACKGROUND_THREADINGside-effect.Test changes
ThreadingModetoggling across the affected suites.ThreadUtilsFeatureFlagTests→ThreadUtilsDispatchTests(tests the now-unconditional dispatch contracts).waitForInitSUCCESS fast-path regression tests (Flutter Remove OSNotificationPayload #1163) to the default async path; removed the obsoletewarnIfBlockingOnMainThreadtest.Net: +274 / −1004 across 26 files.
Test plan
compileDebugUnitTestKotlingreen across all modulesSDKInitTests,OneSignalImpTests,FeatureManagerTests,FeatureFlagTests,ThreadUtilsDispatchTests,BackgroundManagerTests,StartupServiceTests,OneSignalCrashUploaderWrapperTest,SessionServiceTests,FeatureFlagsRefreshServiceTests,NotificationsManagerTests,NotificationPermissionControllerTests)detektpasses for:coreand:notificationsNotes / follow-ups
FeatureActivationMode.APP_STARTUPmode + latching logic inFeatureManageris retained but is now unused by any flag; could be removed in a follow-up if no APP_STARTUP flags are planned."sdk_background_threading"as an arbitrary remote-flag fixture (no longer maps to any enum) — left as-is since they exercise generic plumbing.Made with Cursor