mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-23 20:01:01 +08:00
Implementation of JS reload without crashing
Summary: On JS reload the FabricUIManager and EventDispatcher didn't get release due to a retain cycle. This breaks the cycle. In addition, force release the Scheduler on reload so that the stale classes get cleaned up properly, avoiding crashes. Also the surface now remounts the content correctly Reviewed By: shergin Differential Revision: D8414916 fbshipit-source-id: 4b14031f29b3bc9987d7aa765dc0d930a7de2b1e
This commit is contained in:
committed by
Facebook Github Bot
parent
2ca4770011
commit
cb19621dfe
@@ -35,6 +35,7 @@ Scheduler::Scheduler() {
|
||||
|
||||
Scheduler::~Scheduler() {
|
||||
uiManager_->setDelegate(nullptr);
|
||||
eventDispatcher_->setUIManager(nullptr);
|
||||
}
|
||||
|
||||
void Scheduler::registerRootTag(Tag rootTag) {
|
||||
|
||||
@@ -22,7 +22,7 @@ static std::string normalizeEventType(const std::string &type) {
|
||||
return prefixedType;
|
||||
}
|
||||
|
||||
void SchedulerEventDispatcher::setUIManager(std::shared_ptr<const FabricUIManager> uiManager) {
|
||||
void SchedulerEventDispatcher::setUIManager(std::shared_ptr<const FabricUIManager> uiManager) const {
|
||||
uiManager_ = uiManager;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ class SchedulerEventDispatcher final:
|
||||
|
||||
public:
|
||||
|
||||
void setUIManager(std::shared_ptr<const FabricUIManager> uiManager);
|
||||
void setUIManager(std::shared_ptr<const FabricUIManager> uiManager) const;
|
||||
|
||||
#pragma mark - EventDispatcher
|
||||
|
||||
@@ -42,7 +42,8 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
std::shared_ptr<const FabricUIManager> uiManager_;
|
||||
// TODO: consider using std::weak_ptr<> instead for better memory management.
|
||||
mutable std::shared_ptr<const FabricUIManager> uiManager_;
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
|
||||
Reference in New Issue
Block a user