OneSignal-Android-SDK icon indicating copy to clipboard operation
OneSignal-Android-SDK copied to clipboard

chore: [SDK-4213] remove background-threading FF, make async init default

Open abdulraqeeb33 opened this issue 5 months ago • 0 comments

Summary

The sdk_background_threading remote 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 the SDK_BACKGROUND_THREADING enum entry. The generic FeatureActivationMode framework and SDK_IDENTITY_VERIFICATION remain.
  • ThreadingMode.kt — deleted (it only existed to hold useBackgroundThreading).
  • ThreadUtils.kt — collapsed every if (ThreadingMode.useBackgroundThreading) … else … branch to the OneSignalDispatchers path, dropping the legacy thread { runBlocking { … } } / GlobalScope.launch fallbacks. Renamed runOnSerialIOIfBackgroundThreading → runOnSerialIO and updated all call sites.
  • OneSignalImp.kt — removed isBackgroundThreadingEnabled, the featureManager field, the injectable ioDispatcher constructor param, and the now-dead requireInitForOperation / warnIfBlockingOnMainThread. initWithContext always dispatches internalInit via suspendifyOnIO (never blocks the caller); login/logout/updateUserJwt/JWT-listener methods always use waitForInit; suspend accessors use OneSignalDispatchers.IO directly.
  • StartupService.kt — removed the IFeatureManager lookup; scheduleStart() always launches on OneSignalDispatchers.launchOnDefault.
  • OneSignalCrashUploaderWrapper.kt — removed the FF check in start(); always launches on IO (featureManager still injected for OTel telemetry).
  • FeatureManager.kt — removed the SDK_BACKGROUND_THREADING side-effect.

Test changes

  • Removed FF on/off matrix tests and ThreadingMode toggling across the affected suites.
  • Renamed ThreadUtilsFeatureFlagTests → ThreadUtilsDispatchTests (tests the now-unconditional dispatch contracts).
  • Re-pointed the saturated-IO waitForInit SUCCESS fast-path regression tests (Flutter #1163) to the default async path; removed the obsolete warnIfBlockingOnMainThread test.

Net: +274 / −1004 across 26 files.

Test plan

  • [x] compileDebugUnitTestKotlin green across all modules
  • [x] Affected unit tests pass (SDKInitTests, OneSignalImpTests, FeatureManagerTests, FeatureFlagTests, ThreadUtilsDispatchTests, BackgroundManagerTests, StartupServiceTests, OneSignalCrashUploaderWrapperTest, SessionServiceTests, FeatureFlagsRefreshServiceTests, NotificationsManagerTests, NotificationPermissionControllerTests)
  • [x] detekt passes for :core and :notifications
  • [ ] Full CI suite

Notes / follow-ups

  • The generic FeatureActivationMode.APP_STARTUP mode + latching logic in FeatureManager is retained but is now unused by any flag; could be removed in a follow-up if no APP_STARTUP flags are planned.
  • A few telemetry/config/parser tests still use the literal string "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

abdulraqeeb33 avatar Jun 23 '26 19:06 abdulraqeeb33