re-thinking the CAAnimation spy logic, crash during caanimation object release, support-case-#692#99
Open
markdevocht wants to merge 2 commits into
Open
Conversation
…ase, support-case-#692
asafkorem
reviewed
Feb 1, 2026
asafkorem
left a comment
Contributor
There was a problem hiding this comment.
Generally this should work, but wrote a few concerns I had while reading.. We can discuss this tomorrow and consider not replacing the delegate object and instead tracking via a CAAnimation lifecycle hook (or at least masking proxy identity/protocol checks) to avoid subtle behavior changes
asafkorem
approved these changes
Feb 11, 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.
The problem was that the self object (delegate) was no longer valid when calling the origional method and thus crashed.
There was no way to check this validity.
The old approach:
Original: 1-to-Many (Class-level swizzling)
───────────────────
UIViewAnimationBlockDelegate CLASS
(modified once, affects ALL instances)
animationDidStart: ──swizzled──▶ __detox_sync_animationDidStart:
animationDidStop: ──swizzled──▶ __detox_sync_animationDidStop:
delegate A (instance) ─▶ Animation1
delegate B (instance) ─▶ Animation2
delegate C (instance) ─▶ Animation3
The new approach:
New: 1-to-1 (Instance-level proxy)
───────────────────
Animation1 delegate ─▶ Proxy 1 origionalDelegate (weak) ─▶ delegate A (origional)
Animation2 delegate ─▶ Proxy 2 origionalDelegate (weak) ─▶ delegate B (DEALLOC!)
Animation3 delegate ─▶ Proxy 3 origionalDelegate (weak) ─▶ delegate C (origional)
Safety: If delegate B is deallocated:
Proxy 2's originalDelegate becomes nil (weak reference)
Proxy 2's animationDidStop: checks if (delegate) → false → no call → no crash
Animations 1 and 3 are unaffected