From cade29797183b8f67c538f9aa343728c374c9986 Mon Sep 17 00:00:00 2001 From: Kevin Gozali Date: Wed, 7 Mar 2018 10:20:52 -0800 Subject: [PATCH] iOS Surface: properly reset some internal states when JS reloads Summary: There are a few important states that didn't reset correctly when reloading JS: * the RCTSurfaceStage was stuck at all bits enabled, hence no further stage change happened (even though the state "reset" to `RCTSurfaceStageBridgeDidLoad`) * the RCTSurfaceView didn't get recreated, because the _view ivar was never cleared * similarly, the _touchHandler ivar attached to the _view was never re-setup --> all touches after JS reload were dropped before this diff Reviewed By: mmmulani Differential Revision: D7178038 fbshipit-source-id: ba49bc205f8bf43842471b7ab748cef8549ea212 --- React/Base/Surface/RCTSurface.mm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/React/Base/Surface/RCTSurface.mm b/React/Base/Surface/RCTSurface.mm index 5bc3de232..30110ceae 100644 --- a/React/Base/Surface/RCTSurface.mm +++ b/React/Base/Surface/RCTSurface.mm @@ -186,6 +186,10 @@ { RCTAssertMainQueue(); + // Reset states because the bridge is reloading. This is similar to initialization phase. + _stage = RCTSurfaceStageSurfaceDidInitialize; + _view = nil; + _touchHandler = nil; [self _setStage:RCTSurfaceStageBridgeDidLoad]; }