mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Breaking a retain cycle between RCTSurfaceTouchHandler and RCTFabricSurface (another approach)
Summary: This is a different approach to break the retain cycle: instead of detaching a view manually, we store a pointer to a view weakly. I am working on some change that will make possible (and make use of it) to call `start` and `stop` on Surface objects mutiple times, so to make it happens we need to remove detaching from `stop` method. Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D24041524 fbshipit-source-id: 700b13d715d2eb84d52bf3e51e0fd2896a55baf8
This commit is contained in:
committed by
Facebook GitHub Bot
parent
16afda2282
commit
61cfa97067
@@ -11,6 +11,10 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface RCTSurfaceTouchHandler : UIGestureRecognizer
|
||||
|
||||
/*
|
||||
* Attaches (and detaches) a view to the touch handler.
|
||||
* The receiver does not retain the provided view.
|
||||
*/
|
||||
- (void)attachToView:(UIView *)view;
|
||||
- (void)detachFromView:(UIView *)view;
|
||||
|
||||
|
||||
@@ -159,7 +159,10 @@ struct PointerHasher {
|
||||
std::unordered_map<__unsafe_unretained UITouch *, ActiveTouch, PointerHasher<__unsafe_unretained UITouch *>>
|
||||
_activeTouches;
|
||||
|
||||
UIView *_rootComponentView;
|
||||
/*
|
||||
* We hold the view weakly to prevent a retain cycle.
|
||||
*/
|
||||
__weak UIView *_rootComponentView;
|
||||
IdentifierPool<11> _identifierPool;
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,6 @@ using namespace facebook::react;
|
||||
}
|
||||
|
||||
[_surfacePresenter unregisterSurface:self];
|
||||
[_touchHandler detachFromView:_view];
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user