fix: Make setSessionId synchronous to prevent race with MPRoktLayout#734
fix: Make setSessionId synchronous to prevent race with MPRoktLayout#734nickolas-dimitrakas wants to merge 1 commit intoworkstation/8.x-Maintenancefrom
Conversation
setSessionId was using two async main queue hops (via forwardSDKCall) before reaching the Rokt SDK, causing a race condition when followed immediately by MPRoktLayout which reads the session synchronously. Use the same direct kit access pattern as getSessionId, falling back to forwardSDKCall only when kits haven't initialized yet. Made-with: Cursor
PR SummaryMedium Risk Overview If the Rokt kit isn’t available yet, Reviewed by Cursor Bugbot for commit c480e95. Bugbot is set up for automated code reviews on this repo. Configure here. |
📦 SDK Size Impact ReportMeasures how much the SDK adds to an app's size (with-SDK minus without-SDK).
➡️ SDK size impact change is minimal. Raw measurementsTarget branch (workstation/8.x-Maintenance): {"baseline_app_size_kb":84,"baseline_executable_size_bytes":75464,"with_sdk_app_size_kb":1948,"with_sdk_executable_size_bytes":76360,"sdk_impact_kb":1864,"sdk_executable_impact_bytes":896,"xcframework_size_kb":9736}This PR: {"baseline_app_size_kb":84,"baseline_executable_size_bytes":75464,"with_sdk_app_size_kb":1948,"with_sdk_executable_size_bytes":76360,"sdk_impact_kb":1864,"sdk_executable_impact_bytes":896,"xcframework_size_kb":9732} |
Summary
setSessionIdwas delivered asynchronously (twodispatch_async(main)hops viaforwardSDKCall) whileMPRoktLayoutreads the session synchronously fromUserDefaults, causing the session ID to be missing on the execute request.getSessionIdalready uses, matching Android's synchronous behavior.forwardSDKCallwhen kits haven't initialized yet.Test plan
testSetSessionIdIsReceivedByKitSynchronously-- confirms the kit receives the session ID synchronouslytestSetSessionIdSynchronousDoesNotUseForwardSDKCall-- confirmsforwardSDKCallis bypassed when kit is activetestSetSessionIdFallsBackToForwardSDKCallWhenKitNotAvailable-- confirms fallback queuing behaviortrunk checkcleanMade with Cursor