Skip to content

Commit 7445af3

Browse files
alanjhughesreact-native-bot
authored andcommitted
Fix stuck loading banner after a reload (#56452)
Summary: Fixes an issue on iOS where the "Loading from Metro..." banner can remain stuck on screen after a reload. `RCTInstance._loadScriptFromSource` posts `RCTInstanceDidLoadBundle`, not `RCTJavaScriptDidLoadNotification`. The legacy notification is never posted, so the existing native hide path is dead. Also, `RCTDevLoadingView` has no cleanup. Without hiding the window and clearing it's reference, it remains alive and stuck on screen. ## Changelog: [IOS] [FIXED] - Fix "Loading from Metro..." banner getting stuck after reloads in quick succession. Pull Request resolved: #56452 Test Plan: 1. Launch an app on iOS 2. Trigger a reload while the "Loading from Metro..." banner is still visible. Bundle cache should be empty so it takes some time. 3. Immediately trigger a second reload while the banner is visible 4. Confirm: banner is gone once the new bundle finishes loading (previously it would remain stuck indefinitely) Reviewed By: emily8rown Differential Revision: D101004084 Pulled By: huntie fbshipit-source-id: de6446a522f80c5a8a0953303fb03fa65c6b698b
1 parent 5aee11b commit 7445af3

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

packages/react-native/React/CoreModules/RCTDevLoadingView.mm

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,27 @@ - (instancetype)init
5050
selector:@selector(hide)
5151
name:RCTJavaScriptDidFailToLoadNotification
5252
object:nil];
53+
[[NSNotificationCenter defaultCenter] addObserver:self
54+
selector:@selector(hide)
55+
name:@"RCTInstanceDidLoadBundle"
56+
object:nil];
5357
}
5458
return self;
5559
}
5660

61+
- (void)dealloc
62+
{
63+
[self clearInitialMessageDelay];
64+
[[NSNotificationCenter defaultCenter] removeObserver:self];
65+
UIWindow *window = _window;
66+
_window = nil;
67+
if (window) {
68+
RCTExecuteOnMainQueue(^{
69+
window.hidden = YES;
70+
});
71+
}
72+
}
73+
5774
+ (void)setEnabled:(BOOL)enabled
5875
{
5976
RCTDevLoadingViewSetEnabled(enabled);

0 commit comments

Comments
 (0)