From d06a7c174873ca67d053aaee915910eeae5b3548 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Mon, 11 Nov 2019 03:01:45 -0800 Subject: [PATCH] Erase ComponentDescriptorRegistry before inserting it to fix crash Summary: Changelog: [internal] if you called `ContextContainer.insert("key", )` and then again `ContextContainer.insert("key", )`, the old value will remain in `ContextContainer`. This seems to be by design however it causes crash when reloading surface that uses `ComponentDescriptorRegistry_DO_NOT_USE_PRETTY_PLEASE`. We fix it by erasing `ComponentDescriptorRegistry_DO_NOT_USE_PRETTY_PLEASE` in Scheduler before inserting a new one. Reviewed By: shergin Differential Revision: D18421153 fbshipit-source-id: a01e5f6ac864fd641674d84e97d447f8cb9114be --- ReactCommon/fabric/uimanager/Scheduler.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ReactCommon/fabric/uimanager/Scheduler.cpp b/ReactCommon/fabric/uimanager/Scheduler.cpp index 22c60cd295c..9ebb0cee1d3 100644 --- a/ReactCommon/fabric/uimanager/Scheduler.cpp +++ b/ReactCommon/fabric/uimanager/Scheduler.cpp @@ -72,8 +72,11 @@ Scheduler::Scheduler( uiManagerBinding->attach(uiManager); }); + auto componentDescriptorRegistryKey = + "ComponentDescriptorRegistry_DO_NOT_USE_PRETTY_PLEASE"; + schedulerToolbox.contextContainer->erase(componentDescriptorRegistryKey); schedulerToolbox.contextContainer->insert( - "ComponentDescriptorRegistry_DO_NOT_USE_PRETTY_PLEASE", + componentDescriptorRegistryKey, std::weak_ptr( componentDescriptorRegistry_));