Fabric: Lazy initialization of RCTSurfaceTouchHandler on the main thread

Summary:
RCTSurfaceTouchHandler is not a thread-safe object and must be used (and initialized) on the main thread. Therefore we need to move the initialization to `view` method which is guaranteed to be called on the main thread.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D24290776

fbshipit-source-id: fc1f2f157599aff6fca053451f89bf7cca3c812a
This commit is contained in:
Valentin Shergin 2020-10-15 10:44:29 -07:00 коммит произвёл Facebook GitHub Bot
Родитель 668cc2fbde
Коммит fe8cd5cf3e
1 изменённых файлов: 1 добавлений и 2 удалений

Просмотреть файл

@ -58,8 +58,6 @@ using namespace facebook::react;
_maximumSize = CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX);
_touchHandler = [RCTSurfaceTouchHandler new];
_stage = RCTSurfaceStageSurfaceDidInitialize;
}
@ -106,6 +104,7 @@ using namespace facebook::react;
if (!_view) {
_view = [[RCTSurfaceView alloc] initWithSurface:(RCTSurface *)self];
_touchHandler = [RCTSurfaceTouchHandler new];
[_touchHandler attachToView:_view];
}