Skip to content

Commit c233191

Browse files
janicduplessisfacebook-github-bot
authored andcommitted
Animated - Add missing super calls to fix native animated crash
Summary: There was some missing super.__detach calls in some Animated nodes, we rely on the base class being called to drop the node in the native implementation, not doing so will cause some nodes to leak. It also resulted in a crash when removing certain nodes because they would get updated after being detached. **Test plan** Reproduced the crash by unmounting a view that uses a DiffClamp node and made sure this fixes it. Also tested that other native animations still worked properly. Fixes #11317 Closes #12910 Differential Revision: D4718188 Pulled By: javache fbshipit-source-id: 179ec1334532152c124a9c0f447f488311925d0a
1 parent 673093e commit c233191

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Libraries/Animated/src/AnimatedImplementation.js

+4
Original file line numberDiff line numberDiff line change
@@ -1327,6 +1327,7 @@ class AnimatedModulo extends AnimatedWithChildren {
13271327
13281328
__detach(): void {
13291329
this._a.__removeChild(this);
1330+
super.__detach();
13301331
}
13311332
13321333
__getNativeConfig(): any {
@@ -1377,6 +1378,7 @@ class AnimatedDiffClamp extends AnimatedWithChildren {
13771378
13781379
__detach(): void {
13791380
this._a.__removeChild(this);
1381+
super.__detach();
13801382
}
13811383
13821384
__getNativeConfig(): any {
@@ -1460,6 +1462,7 @@ class AnimatedTransform extends AnimatedWithChildren {
14601462
}
14611463
}
14621464
});
1465+
super.__detach();
14631466
}
14641467
14651468
__getNativeConfig(): any {
@@ -1567,6 +1570,7 @@ class AnimatedStyle extends AnimatedWithChildren {
15671570
value.__removeChild(this);
15681571
}
15691572
}
1573+
super.__detach();
15701574
}
15711575
15721576
__makeNative() {

Libraries/Animated/src/__tests__/AnimatedNative-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ describe('Native Animated', () => {
281281
);
282282

283283
expect(nativeAnimatedModule.disconnectAnimatedNodes).toHaveBeenCalledTimes(2);
284-
expect(nativeAnimatedModule.dropAnimatedNode).toHaveBeenCalledTimes(2);
284+
expect(nativeAnimatedModule.dropAnimatedNode).toHaveBeenCalledTimes(3);
285285
});
286286

287287
it('sends a valid description for value, style and props nodes', () => {

0 commit comments

Comments
 (0)