wix-incubator / DetoxSync

Synchronization framework for Detox and other testing frameworks
MIT License
34 stars 16 forks source link

Fix race condition with Reanimated library. #70

Closed asafkorem closed 1 year ago

asafkorem commented 1 year ago

In the original code, the restoration of the original _mounting block occurs after the __detox_sync_waitAndMountWithTimeout:timeout method call. This leads to the original _mounting block being restored after it has potentially been altered by the __detox_sync_waitAndMountWithTimeout:timeout method, which is not the desired behavior.

The fix involves moving the restoration of the original _mounting block inside the swizzled block (swizzledMountingBlock). Now, whenever the swizzled block is executed, the original _mounting block is restored first, ensuring the original behavior is retained before any other operations within the swizzled block are performed.

This issue was reported here: https://github.com/wix/Detox/issues/4253 and was reproduced thanks to @ldalzottomp.