Skip to content

Commit faff19a

Browse files
RSNarafacebook-github-bot
authored andcommitted
De-jank DevLoadingView
Summary: ## Problems Repro steps: 1. Disable Fabric (because CMD + R doesn't work with Fabric right now). 2. Open up Marketplace and hit `CMD + OPT + R` 3. **Observe:** The progress bar doesn't show up right away. It also doesn't actually show progress. https://pxl.cl/140g1 RN Support post: https://fb.workplace.com/groups/rn.support/permalink/3437652016283389/ ## Fixes The first problem is that progress bar doesn't actually show progress. **Fix:** Bundle load progress is updated in `RCTCxxBridge`, where we first require `RCTDevLoadingView`, and then call its `updateProgress` method. Previously, we wouldn't lazily load `RCTDevLoadingView`, it already didn't exist. Lazily loading `RCTDevLoadingView` causes the progress view to show up. Here: https://pxl.cl/140gt If you look at the above video, you'll notice there are two stages to the progress bar: stage 1 displays the actual progress. Stage 2 prompts that we're downloading the JS bundle. As you can see, stage 1 and stage 2 have different background colors, even though both of them are green. **Fix:** I adjusted the JS to match the Native color. Here: https://pxl.cl/140gT We're almost there, but the progress bar is dismissed twice? **Fix:** I dug into the code, and the reason why was because when we hit `CMD + R`, we invalidate the bridge, and immediately re-initialize it. This means that we asynchronously invalidate the old TurboModuleManager, and immediately create a brand new one. Therefore, two `RCTDevLoadingView` modules can (and do) exist at once. So, I moved `RCTDevLoadingView` to be an instance member of `FBReactModule`, to ensure that it doesn't get cleaned up and re-created when TurboModuleManager is deleted and re-created. This finally fixed the progress bar jank: https://pxl.cl/140hn Changelog: [iOS][Fixed] - Remove RCTDevLoadingView jank Reviewed By: rickhanlonii Differential Revision: D20607815 fbshipit-source-id: 05825c67adaf3cfda70be0fa2dc92d413dc8921b
1 parent 421bc5f commit faff19a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Libraries/Utilities/LoadingView.ios.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import NativeDevLoadingView from './NativeDevLoadingView';
1616
module.exports = {
1717
showMessage(message: string, type: 'load' | 'refresh') {
1818
if (NativeDevLoadingView) {
19-
const green = processColor('#275714');
19+
const green = processColor('#005a00');
2020
const blue = processColor('#2584e8');
2121
const white = processColor('#ffffff');
2222

React/CxxBridge/RCTCxxBridge.mm

+2-2
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,8 @@ - (void)start
377377
}
378378
onProgress:^(RCTLoadingProgress *progressData) {
379379
#if (RCT_DEV | RCT_ENABLE_LOADING_VIEW) && __has_include(<React/RCTDevLoadingViewProtocol.h>)
380-
// Note: RCTDevLoadingView should have been loaded at this point, so no need to allow lazy loading.
381-
id<RCTDevLoadingViewProtocol> loadingView = [weakSelf moduleForName:@"DevLoadingView" lazilyLoadIfNecessary:NO];
380+
id<RCTDevLoadingViewProtocol> loadingView = [weakSelf moduleForName:@"DevLoadingView"
381+
lazilyLoadIfNecessary:YES];
382382
[loadingView updateProgress:progressData];
383383
#endif
384384
}];

0 commit comments

Comments
 (0)