From b1c4fee6af956e03b2a199dbf32f90414e14c22c Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Fri, 22 Jun 2018 11:54:03 -0700 Subject: [PATCH] Fabric: Consistency assurance asserts in RCTComponentViewRegistry Summary: @public We have found that because of some bugs Mounting Manager can request creation of views with same tag several times (which should not happen). Now, we can fail earlier in such cases. Reviewed By: fkgozali Differential Revision: D8585164 fbshipit-source-id: 63c6391de5adfe711552918a20a18396f54ec201 --- React/Fabric/Mounting/RCTComponentViewRegistry.mm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/React/Fabric/Mounting/RCTComponentViewRegistry.mm b/React/Fabric/Mounting/RCTComponentViewRegistry.mm index 635a8e1dc..81816f1ea 100644 --- a/React/Fabric/Mounting/RCTComponentViewRegistry.mm +++ b/React/Fabric/Mounting/RCTComponentViewRegistry.mm @@ -87,6 +87,10 @@ const NSInteger RCTComponentViewRegistryRecyclePoolMaxSize = 256; tag:(ReactTag)tag { RCTAssertMainQueue(); + + RCTAssert(![_registry objectForKey:(__bridge id)(void *)tag], + @"RCTComponentViewRegistry: Attempt to dequeue already registered component."); + UIView *componentView = [self _dequeueComponentViewWithName:componentName]; componentView.tag = tag; @@ -105,6 +109,9 @@ const NSInteger RCTComponentViewRegistryRecyclePoolMaxSize = 256; { RCTAssertMainQueue(); + RCTAssert([_registry objectForKey:(__bridge id)(void *)tag], + @"RCTComponentViewRegistry: Attempt to enqueue unregistered component."); + #ifdef LEGACY_UIMANAGER_INTEGRATION_ENABLED [RCTUIManager unregisterView:componentView]; #endif