fix: run embedded CardView native lifecycle on main thread#1161
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces thread-safety improvements to CardComponentViewProxy by ensuring that both dispose() and initializeComponentIfNeeded() are executed on the main thread, and adds corresponding unit tests to verify these behaviors. The feedback recommends capturing self strongly in the dispose() thread-safety block to prevent silent cleanup failures if the proxy is deallocated prematurely. Additionally, it suggests refactoring the new unit tests to use an onSend callback on the mock emitter instead of a hardcoded delay, making the tests deterministic and faster.
|
nauaros
reviewed
Jul 9, 2026
erenbesel
reviewed
Jul 9, 2026
nauaros
approved these changes
Jul 9, 2026
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
Fixes a residual iOS crash:
C++ Exception: AdyenComponentBus.unsubscribe raised an exception: Call must be made on main thread, still occurring on 2.11.1 despite the earlier fix in c143c27.Root cause
The 2.11.1 fix hardened only the
AdyenComponentBusmodule's JS-facing entry points (subscribe/unsubscribe/handleetc.) withensureMainThread. It did not cover the native Fabric view path:CardComponentViewProxy(backingADYCardView) still called Adyen SDK APIs directly fromdispose()(cancelIfNeeded(),EmbeddedComponentBusModule.unregister) andinitializeComponentIfNeeded()(CardComponent/AdyenActionComponentconstruction) with no main-thread guarantee. When Fabric drives view teardown/mount off the main thread, the Adyen SDK's main-thread assertion fires.Fix
Wrap
dispose()andinitializeComponentIfNeeded()inCardComponentViewProxywith the existingensureMainThread(_:)helper, matching the pattern already used inEmbeddedComponentBusModule.Tests
Added two regression tests to
ThreadingSafetyTests.swift:test_cardComponentViewProxyDispose_fromBackgroundThread_doesNotCrashtest_cardComponentViewProxyInitialize_fromBackgroundThread_reportsErrorOnMainThreadTicket
COSDK-1355