Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add atomic registerSegment method to test
Summary: In the top js errors there are 2 mids related to segment fetching: - requireForFacebook.js:unknownModuleError (https://www.internalfb.com/logview/details/facebook_android_javascripterrors/ba11461526aff8a6842401b35b02f5a4), 11.64 K vs. 524 - asyncRequire.js:verifySegment (https://www.internalfb.com/logview/details/facebook_android_javascripterrors/5452ba893b8d9ba8e97e070cf6976b65) 5.39 K vs. 180 Both errors will result in surface not loading. A lot of traces have logs similar with the following: ```11-01 19:57:51.166 27735 7626 W fb4a.BridgelessReact: registerSegment(segmentId = "1090", path = "/data/data/com.facebook.katana/app_overtheair/resources/412137089/414433453/hbc-seg-1090__DELIM__main.jsbundle") 11-01 19:57:51.167 27735 7445 I ReactNativeJS: Module 39122 in segment 0 doesn not exist moduleDefiner 11-01 19:57:51.171 27735 7445 E ReactNativeJS: Error: Requiring unknown module "39122"., js build: 414433453 11-01 19:57:51.175 27735 7445 E ReactNativeJS: Error: Segment meta module is not setup properly. Details: segmentId = 1090, metaModule === undefined 11-01 19:57:51.175 27735 7445 E ReactNativeJS: 11-01 19:57:51.175 27735 7445 E ReactNativeJS: This error is located at: ``` RegisterSegment lives through 3 threads while in bridge there are only 2 threads involved (native & JS): - Native thread, log printed (fb4a.BridgelessReact: registerSegment...) - Background thread: no log, added in this diff (Finish registerSegment...) - JS thread: logs not printed, should print logs here: https://www.internalfb.com/code/fbsource/[60521987354ed1ef9a0d10bafc60db3c25302ab4]/xplat/ReactNative/venice/ReactInstance.cpp?lines=308-330 Since the JS thread logs aren't printed and there are segment errors right after calling registerSegemnt, I think registerSegment is not done. It could be caused by: - ReactInstance being null, I added logs in background thread to verify (Finish registerSegment...) since dispatching to background thread relies on non-nullable ReactInstance. - Work on JS thread hasn't been executed when trying to use/verify the segment. I added atomic method ```registerSegmentAtomic``` to make sure JS thread is blocked until segment is fully registered. ```registerSegmentAtomic``` will be tested behind gating added in D40917444. Changelog: [Android][Changed] - Add feature flag enableAtomicRegisterSegment Reviewed By: RSNara Differential Revision: D40921759 fbshipit-source-id: 84221aa81f0c549f931a4847b154187299639ef4
- Loading branch information