Skip to content

chore: Add coordinator to prevent push delivery metrics loss#951

Draft
mahmoud-elmorabea wants to merge 1 commit intomainfrom
fix-push-metrics-race-condition
Draft

chore: Add coordinator to prevent push delivery metrics loss#951
mahmoud-elmorabea wants to merge 1 commit intomainfrom
fix-push-metrics-race-condition

Conversation

@mahmoud-elmorabea
Copy link
Contributor

@mahmoud-elmorabea mahmoud-elmorabea commented Aug 28, 2025

Why?

Some delivery metrics are lost because we don't wait for that request to finish. The previous implementation had two independent async operations (metrics tracking and rich push processing) and only rich push processing called contentHandler upon completion. When rich push is faster, it would call contentHandler and terminate the NSE, killing the in-flight metrics request even when plenty of NSE time remained.

How we solve?

Add NSEOperationCoordinator to wait for both async calls or NSE call that it will expire. The coordinator ensures contentHandler is called exactly once only after:

  • Both operations complete (success or failure), OR
  • serviceExtensionTimeWillExpire is called by iOS
    This maximizes delivery metrics success by using the full available NSE execution time instead of terminating prematurely when only one operation completes.

Note: Moved Synchronized<T> utility to Common module for reuse

@github-actions
Copy link

Sample app builds 📱

Below you will find the list of the latest versions of the sample apps.
It's recommended to always download the latest builds to test this PR accurately.

@github-actions
Copy link

Messages
📖 ✅ Firebase version bounds are consistent: 8.7.0 to 13.0.0

Generated by 🚫 dangerJS against 9f3e92b

@mahmoud-elmorabea mahmoud-elmorabea changed the title chore: Initial implementation of NSE coordinator chore: Add coordinator to prevent push delivery metrics loss Aug 28, 2025
@github-actions
Copy link

SDK binary size reports 📊

SDK binary size of this PR
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  16.6%   149Ki  16.6%   149Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/autogenerated/AutoMockable.generated.swift
   4.3%  38.7Ki   4.3%  38.7Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Communication/EventBusHandler.swift
   4.0%  35.9Ki   4.0%  35.9Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/autogenerated/AutoMockable.generated.swift
   3.2%  28.9Ki   3.2%  28.9Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/autogenerated/AutoMockable.generated.swift
   2.8%  25.4Ki   2.8%  25.4Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/State/InAppMessageManager.swift
   2.8%  24.9Ki   2.8%  24.9Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/DataPipeline/DataPipelineImplementation.swift
   2.5%  22.5Ki   2.5%  22.5Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Background Queue/QueueStorage.swift
   2.2%  20.1Ki   2.2%  20.1Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Migration/autogenerated/AutoMockable.generated.swift
   2.0%  17.7Ki   2.0%  17.7Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Communication/Event.swift
   1.9%  16.9Ki   1.9%  16.9Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/State/InAppMessageMiddleware.swift
   1.8%  16.6Ki   1.8%  16.6Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/EngineWeb/AnyEncodable.swift
   1.7%  15.7Ki   1.7%  15.7Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPushAPN/autogenerated/AutoMockable.generated.swift
   1.6%  14.7Ki   1.6%  14.7Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/autogenerated/AutoDependencyInjection.generated.swift
   1.6%  14.4Ki   1.6%  14.4Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/State/InAppMessageState.swift
   1.6%  14.4Ki   1.6%  14.4Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/Type/PushNotification.swift
   1.5%  13.4Ki   1.5%  13.4Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Communication/EventStorage.swift
   1.3%  11.5Ki   1.3%  11.5Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Communication/EventMemoryStorage.swift
   1.1%  10.3Ki   1.1%  10.3Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Managers/MessageManager.swift
   1.1%  10.1Ki   1.1%  10.1Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/PushHandling/PushEventHandlerProxy.swift
   1.0%  9.47Ki   1.0%  9.47Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/Integration/CioProviderAgnosticAppDelegate.swift
   1.0%  9.42Ki   1.0%  9.42Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/State/InAppMessageReducer.swift
   1.0%  9.34Ki   1.0%  9.34Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/DataPipeline/DataPipeline.swift
   1.0%  9.31Ki   1.0%  9.31Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/EngineWeb/EngineWeb.swift
   1.0%  9.16Ki   1.0%  9.16Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/JsonAdapter.swift
   0.9%  8.31Ki   0.9%  8.31Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Service/Request/TrackDeliveryEventRequestBody.swift
   0.9%  8.17Ki   0.9%  8.17Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/CustomerIOInstance.swift
   0.9%  7.79Ki   0.9%  7.79Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/Log.swift
   0.8%  7.39Ki   0.8%  7.39Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Migration/DataPipelineMigrationAssistant.swift
   0.8%  7.32Ki   0.8%  7.32Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Background Queue/Type/QueueTaskMetadata.swift
   0.8%  7.31Ki   0.8%  7.31Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/UserNotificationsFramework/Wrappers.swift
   0.8%  7.11Ki   0.8%  7.11Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Views/UIKitInline.swift
   0.8%  6.99Ki   0.8%  6.99Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/RichPush/RichPushHttpClient.swift
   0.8%  6.80Ki   0.8%  6.80Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Managers/ModalViewManager.swift
   0.7%  6.73Ki   0.7%  6.73Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Views/GistInlineInAppMessageView.swift
   0.7%  6.60Ki   0.7%  6.60Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/DataPipeline/Plugins/AutoTrackingScreenViews.swift
   0.7%  6.52Ki   0.7%  6.52Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/Store/PushHistory.swift
   0.7%  6.19Ki   0.7%  6.19Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Gist.swift
   0.7%  6.15Ki   0.7%  6.15Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Utilities/URLComponents.swift
   0.7%  6.12Ki   0.7%  6.12Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/KeyValueStorage.swift
   0.7%  6.05Ki   0.7%  6.05Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/RichPush/MessagingPush+RichPush.swift
   0.6%  5.55Ki   0.6%  5.55Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/autogenerated/AutoDependencyInjection.generated.swift
   0.6%  5.54Ki   0.6%  5.54Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/autogenerated/AutoDependencyInjection.generated.swift
   0.6%  5.43Ki   0.6%  5.43Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Background Queue/Type/QueueTask.swift
   0.6%  5.30Ki   0.6%  5.30Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/RichPush/NSEOperationCoordinator.swift
   0.6%  5.14Ki   0.6%  5.14Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Migration/TrackEventMigrationType.swift
   0.6%  5.12Ki   0.6%  5.12Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Views/SwiftUIInline.swift
   0.6%  5.02Ki   0.6%  5.02Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/State/InAppMessageAction.swift
   0.5%  4.91Ki   0.5%  4.91Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Service/Response/ErrorMessageResponse.swift
   0.5%  4.84Ki   0.5%  4.84Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/DataPipeline/Config/SDKConfigBuilder.swift
   0.5%  4.78Ki   0.5%  4.78Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/DataPipeline/autogenerated/AutoMockable.generated.swift
   0.5%  4.66Ki   0.5%  4.66Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Managers/Models/Message.swift
   0.5%  4.52Ki   0.5%  4.52Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Background Queue/Queue.swift
   0.5%  4.36Ki   0.5%  4.36Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Communication/EventBus.swift
   0.5%  4.26Ki   0.5%  4.26Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/Config/MessagingPushConfigBuilder.swift
   0.5%  4.16Ki   0.5%  4.16Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Service/Request/MetricRequest.swift
   0.5%  4.15Ki   0.5%  4.15Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Views/InlineMessageBridgeView.swift
   0.4%  3.87Ki   0.4%  3.87Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Service/HttpRequestRunner.swift
   0.4%  3.87Ki   0.4%  3.87Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/PushHandling/iOSPushEventListener.swift
   0.4%  3.59Ki   0.4%  3.59Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/GistDelegate.swift
   0.4%  3.57Ki   0.4%  3.57Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Network/GistQueueNetwork.swift
   0.4%  3.52Ki   0.4%  3.52Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/EngineWeb/EngineWebConfiguration.swift
   0.4%  3.48Ki   0.4%  3.48Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/MessagingPush.swift
   0.4%  3.46Ki   0.4%  3.46Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Views/GistModalViewController.swift
   0.4%  3.37Ki   0.4%  3.37Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Managers/ModalMessageManager.swift
   0.4%  3.36Ki   0.4%  3.36Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Extensions/StringExtensions.swift
   0.4%  3.32Ki   0.4%  3.32Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Module/ModuleTopLevelObject.swift
   0.4%  3.32Ki   0.4%  3.32Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/Atomic.swift
   0.4%  3.22Ki   0.4%  3.22Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/DataPipeline/Plugins/DataPipelinePublishedEvents.swift
   0.3%  3.16Ki   0.3%  3.16Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/FileStorage.swift
   0.3%  3.10Ki   0.3%  3.10Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/DataPipeline/Plugins/DeviceContexualAttributes.swift
   0.3%  3.09Ki   0.3%  3.09Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/StringAnyEncodable.swift
   0.3%  3.02Ki   0.3%  3.02Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Managers/InlineMessageManager.swift
   0.3%  2.95Ki   0.3%  2.95Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/DataPipeline/Plugins/Context.swift
   0.3%  2.91Ki   0.3%  2.91Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Managers/QueueManager.swift
   0.3%  2.90Ki   0.3%  2.90Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/EngineWeb/EngineEventHandler.swift
   0.3%  2.78Ki   0.3%  2.78Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/SystemLogger.swift
   0.3%  2.78Ki   0.3%  2.78Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Network/BaseNetwork.swift
   0.3%  2.62Ki   0.3%  2.62Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Background Queue/Task Data/DeletePushNotificationQueueTaskData.swift
   0.3%  2.61Ki   0.3%  2.61Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Service/HttpRequestParams.swift
   0.3%  2.44Ki   0.3%  2.44Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Service/HttpRequestError.swift
   0.3%  2.41Ki   0.3%  2.41Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/DataPipeline/Util/DeviceAttributesProvider.swift
   0.2%  2.21Ki   0.2%  2.21Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPushAPN/Integration/CioAppDelegateAPN.swift
   0.2%  2.12Ki   0.2%  2.12Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Background Queue/Task Data/IdentifyProfileQueueTaskData.swift
   0.2%  2.12Ki   0.2%  2.12Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/DeviceInfo.swift
   0.2%  2.12Ki   0.2%  2.12Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/RichPush/RichPushDeliveryTracker.swift
   0.2%  2.11Ki   0.2%  2.11Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/DIManager.swift
   0.2%  2.10Ki   0.2%  2.10Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/State/Core/Subscription.swift
   0.2%  2.09Ki   0.2%  2.09Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/UserNotificationsFramework/UserNotificationsFrameworkAdapter.swift
   0.2%  1.98Ki   0.2%  1.98Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/DataPipeline/Util/DictionarySanitizer.swift
   0.2%  1.97Ki   0.2%  1.97Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Background Queue/Type/QueueTaskRunResults.swift
   0.2%  1.93Ki   0.2%  1.93Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/MessagingPushImplementation.swift
   0.2%  1.87Ki   0.2%  1.87Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/MessagingInAppImplementation.swift
   0.2%  1.86Ki   0.2%  1.86Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Background Queue/Task Data/RegisterPushNotificationQueueTaskData.swift
   0.2%  1.78Ki   0.2%  1.78Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/LockManager.swift
   0.2%  1.71Ki   0.2%  1.71Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/DataPipeline/autogenerated/AutoDependencyInjection.generated.swift
   0.2%  1.70Ki   0.2%  1.70Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Extensions/DictionaryExtension.swift
   0.2%  1.70Ki   0.2%  1.70Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/DataPipeline/CustomerIO+Events.swift
   0.2%  1.68Ki   0.2%  1.68Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/Synchronized.swift
   0.2%  1.61Ki   0.2%  1.61Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Background Queue/Task Data/TrackEventQueueTaskData.swift
   0.2%  1.57Ki   0.2%  1.57Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Config/MessagingInAppConfigBuilder.swift
   0.2%  1.53Ki   0.2%  1.53Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/PushHandling/PushClickHandler.swift
   0.2%  1.46Ki   0.2%  1.46Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Extensions/DateExtensions.swift
   0.2%  1.43Ki   0.2%  1.43Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Views/GistView.swift
   0.2%  1.43Ki   0.2%  1.43Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/PushHandling/ManualPushHandling+UserNotifications.swift
   0.2%  1.42Ki   0.2%  1.42Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Extensions/ArrayExtensions.swift
   0.2%  1.37Ki   0.2%  1.37Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Extensions/GistExtensions.swift
   0.2%  1.37Ki   0.2%  1.37Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Utilities/UIColor+Hex.swift
   0.1%  1.33Ki   0.1%  1.33Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Service/Request/PushMetric.swift
   0.1%  1.33Ki   0.1%  1.33Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/MessagingInApp.swift
   0.1%  1.30Ki   0.1%  1.30Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/RichPush/RichPushRequest.swift
   0.1%  1.29Ki   0.1%  1.29Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Network/Models/UserQueueResponse.swift
   0.1%  1.28Ki   0.1%  1.28Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/SdkClient.swift
   0.1%  1.26Ki   0.1%  1.26Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPushAPN/MessagingPushAPN.swift
   0.1%  1.23Ki   0.1%  1.23Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/SdkCommonLoggerLogger.swift
   0.1%  1.21Ki   0.1%  1.21Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/ThreadUtil.swift
   0.1%  1.21Ki   0.1%  1.21Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/UIKitWrapper.swift
   0.1%  1.18Ki   0.1%  1.18Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/Mocks.swift
   0.1%  1.15Ki   0.1%  1.15Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Service/Request/InAppMetric.swift
   0.1%  1.14Ki   0.1%  1.14Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/DataPipeline/CustomerIO.swift
   0.1%  1.11Ki   0.1%  1.11Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Extensions/DeviceExtension.swift
   0.1%  1.08Ki   0.1%  1.08Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Service/CIOApiEndpoint.swift
   0.1%  1.06Ki   0.1%  1.06Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Store/SdkConfig.swift
   0.1%  1.03Ki   0.1%  1.03Ki    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Type/ScreenView.swift
   0.1%    1020   0.1%    1020    /Users/runner/work/customerio-ios/customerio-ios/Sources/DataPipeline/CustomerIO+Segment.swift
   0.1%    1012   0.1%    1012    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Store/GlobalDataStore.swift
   0.1%    1008   0.1%    1008    /Users/runner/work/customerio-ios/customerio-ios/Sources/DataPipeline/Config/DataPipelineConfigOptions.swift
   0.1%     892   0.1%     892    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPushAPN/MessagingPush+APN.swift
   0.1%     880   0.1%     880    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Service/UserAgentUtil.swift
   0.1%     868   0.1%     868    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPushAPN/MessagingPushAPN+PushConfigs.swift
   0.1%     860   0.1%     860    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Background Queue/Type/QueueTaskType.swift
   0.1%     836   0.1%     836    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/State/Core/Synchronized.swift
   0.1%     804   0.1%     804    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/KeyValueStorageKey.swift
   0.1%     800   0.1%     800    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/AnyEncodable.swift
   0.1%     708   0.1%     708    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/Type/CustomerIOParsedPushPayload.swift
   0.1%     704   0.1%     704    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Type/Region.swift
   0.1%     632   0.1%     632    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/DeepLinkUtil.swift
   0.1%     556   0.1%     556    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Service/Request/EmptyRequestBody.swift
   0.1%     548   0.1%     548    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/Config/MessagingPushConfigOptions.swift
   0.1%     548   0.1%     548    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/Util/PushNotificationLogger.swift
   0.1%     532   0.1%     532    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Network/Utilities/HTTPMethod.swift
   0.1%     512   0.1%     512    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Extensions/UIKitExtensions.swift
   0.1%     488   0.1%     488    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Background Queue/Type/QueueStatus.swift
   0.1%     464   0.1%     464    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Utilities/Encodable.swift
   0.0%     456   0.0%     456    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Network/Endpoints/LogEndpoint.swift
   0.0%     440   0.0%     440    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Store/ProfileStore.swift
   0.0%     432   0.0%     432    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/RingBuffer.swift
   0.0%     428   0.0%     428    /Users/runner/work/customerio-ios/customerio-ios/Sources/DataPipeline/Util/DataPipelinesLogger.swift
   0.0%     424   0.0%     424    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Managers/LogManager.swift
   0.0%     416   0.0%     416    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Network/Utilities/ElapsedTimer.swift
   0.0%     396   0.0%     396    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Utilities/Environment.swift
   0.0%     392   0.0%     392    /Users/runner/work/customerio-ios/customerio-ios/Sources/DataPipeline/Plugins/Logger.swift
   0.0%     388   0.0%     388    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/State/Core/Store.swift
   0.0%     380   0.0%     380    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/State/Core/StoreSubscriber.swift
   0.0%     364   0.0%     364    /Users/runner/work/customerio-ios/customerio-ios/Sources/DataPipeline/Plugins/ScreenFilterPlugin.swift
   0.0%     296   0.0%     296    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Type/InAppMessage.swift
   0.0%     292   0.0%     292    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Network/Endpoints/QueueEndpoint.swift
   0.0%     244   0.0%     244    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/DIGraphShared.swift
   0.0%     228   0.0%     228    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Service/DownloadFileType.swift
   0.0%     228   0.0%     228    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Network/Endpoints/Utilities/GistNetworkRequestError.swift
   0.0%     228   0.0%     228    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Network/SessionManager.swift
   0.0%     220   0.0%     220    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/Util/NotificationCenterWrapper.swift
   0.0%     200   0.0%     200    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Extensions/LoggerExtensions.swift
   0.0%     196   0.0%     196    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/RichPush/RichPushRequestHandler.swift
   0.0%     180   0.0%     180    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/DeviceMetricsGrabber.swift
   0.0%     164   0.0%     164    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Store/QueueInventoryMemoryStore.swift
   0.0%     148   0.0%     148    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingPush/PushHandling/AutomaticPushClickHandling.swift
   0.0%     140   0.0%     140    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/Lock.swift
   0.0%     128   0.0%     128    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/Timer.swift
   0.0%     120   0.0%     120    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Extensions/DataExtensions.swift
   0.0%     116   0.0%     116    /Users/runner/work/customerio-ios/customerio-ios/Sources/DataPipeline/Plugins/CustomerIODestination.swift
   0.0%     108   0.0%     108    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/State/Aliases.swift
   0.0%      48   0.0%      48    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/Network/NetworkSettings.swift
   0.0%      44   0.0%      44    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Config/MessagingInAppConfigOptions.swift
   0.0%      36   0.0%      36    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/DateUtil.swift
   0.0%      36   0.0%      36    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/Time.swift
   0.0%      32   0.0%      32    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Util/SingleScheduleTimer.swift
   0.0%      32   0.0%      32    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/Gist/EngineWeb/EngineWebProvider.swift
   0.0%      32   0.0%      32    /Users/runner/work/customerio-ios/customerio-ios/Sources/MessagingInApp/State/InAppMessageStore.swift
   0.0%      28   0.0%      28    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Version.swift
   0.0%       8   0.0%       8    /Users/runner/work/customerio-ios/customerio-ios/Sources/Common/Extensions/ErrorExtension.swift
 100.0%   904Ki 100.0%   904Ki    TOTAL
Filtering enabled (source_filter); omitted file = 1.93Mi, vm = 2.01Mi of entries

SDK binary size diff report vs. main branch
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL
Filtering enabled (source_filter); omitted file = 1.93Mi, vm = 2.01Mi of entries

@mahmoud-elmorabea mahmoud-elmorabea marked this pull request as ready for review August 28, 2025 18:17
@mahmoud-elmorabea mahmoud-elmorabea requested a review from a team as a code owner August 28, 2025 18:17
} else {
// Fallback to original behavior if no coordinator
RichPushRequestHandler.shared.stopAll()
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Stale Coordinator Causes Incorrect Timeout Handling

The currentCoordinator isn't cleared when autoTrackPushEvents is false or after a coordinator successfully completes its operations. This can cause serviceExtensionTimeWillExpire() to operate on a stale coordinator from a previous push, leading to incorrect timeout handling, and may also result in unnecessary memory usage.

Fix in Cursor Fix in Web

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like a valid concern, we should set currentCoordinator = nil on didRecieve

Copy link
Contributor

@Shahroz16 Shahroz16 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we need to add tests for this Coordinator race/timeout cases.

} else {
// Fallback to original behavior if no coordinator
RichPushRequestHandler.shared.stopAll()
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like a valid concern, we should set currentCoordinator = nil on didRecieve

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i still see a reference in MessagingInApp can we remove that too, please

private func callContentHandler(with content: UNNotificationContent, reason: String) {
logger.info("NSE operations complete (\(reason)). Calling content handler.")

contentHandler(content)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be done on main thread? did you check with wrappers? they often require NSE operation to be done on main

@mahmoud-elmorabea mahmoud-elmorabea marked this pull request as draft October 7, 2025 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants