[iOS] Crash "attempt to insert nil object from objects[3]" in RCTNetworking handlers provider when a request runs after reload (BlobModule is nil)
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 66/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- ios, objective-c, react-native
- 領域
- mobile
調査の方向性
Start with the default handlers provider in packages/react-native/Libraries/AppDelegate/RCTAppSetupUtils.mm and the handler lookup in packages/react-native/Libraries/Network/RCTNetworking.mm; read how the provider handles absent modules. Reproduce with the supplied reload and multipart request loop, then run the relevant iOS networking tests. Done when a request queued during reload no longer crashes if BlobModule is unavailable, while normal Blob URL handling still works.
索引モデルが issue の本文から書いたものです。
説明
Description
On iOS (New Architecture, bridgeless), the app can crash during a host reload with:
NSInvalidArgumentException: -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[3]
objects[3] is BlobModule in the default RCTNetworking handlers provider (RCTAppSetupUtils.mm:87):
return [@[
[RCTHTTPRequestHandler new],
[RCTDataRequestHandler new],
[RCTFileRequestHandler new],
[moduleRegistry moduleForName:"BlobModule"],
] arrayByAddingObjectsFromArray:URLRequestHandlerModules];
What happens:
- A reload (in our case
RCTTriggerReloadCommandListenersfrom a CodePush restart →RCTHost _reloadWithShouldRestartSurfaces) invalidates the oldRCTNetworking, which sets_handlers = nil(RCTNetworking.mm:204), and the oldRCTTurboModuleManager. Once_invalidatingis set,moduleForName:returns nil (RCTTurboModuleManager.mm:910). - A request that was already queued on the old networking method queue still runs afterwards.
prioritizedHandlerssees_handlers == niland calls the provider again. - The provider asks the dead registry for BlobModule, gets nil, and the array literal throws.
extractModuleConformingToProtocol in the same file already tolerates nil modules; only the BlobModule literal does not.
The code is unchanged in v0.88.1 and on main. We see it in production on 0.83.4 (about 85 crash events from 55 users over 5 months).
Proposed fix (we ship this as a local patch and it removes the crash in our repro):
NSMutableArray<id<RCTURLRequestHandler>> *handlers = [NSMutableArray
arrayWithObjects:[RCTHTTPRequestHandler new], [RCTDataRequestHandler new], [RCTFileRequestHandler new], nil];
id<RCTURLRequestHandler> blobModule = [moduleRegistry moduleForName:"BlobModule"];
if (blobModule != nil) {
[handlers addObject:blobModule];
} else {
RCTLogWarn(@"RCTNetworking: BlobModule is nil; blob URLs have no handler");
}
[handlers addObjectsFromArray:URLRequestHandlerModules];
return handlers;
Steps to reproduce
It is a race, so it needs a loop:
- Release build on the iOS simulator, New Architecture on (default).
- In JS, keep sending multipart
fetchrequests whose FormData has a part with auri(for exampledata:text/plain;base64,...). This starts a nestedRCTNetworkTask, which widens the window. Plain POSTs did not reproduce it for us in ~140 reloads. - Every ~2.5 s, trigger a host reload (we used
CodePush.restartApp(false); any trigger ofRCTTriggerReloadCommandListenersshould hit the same path, but I only tested CodePush). - Without the fix the app crashed after ~50 reloads (~150 s). With the fix: ~290 reloads, no crash.
React Native Version
0.83.4 (code unchanged in 0.88.1)
Affected Platforms
Runtime - iOS
Output of npx @react-native-community/cli info
react-native: 0.83.4
react: 19.2.4
Xcode: 27.2/27B52
iOS: hermesEnabled: true, newArchEnabled: true
Stacktrace or Logs
Crashed thread (RCTNetworking method queue):
-[__NSPlaceholderArray initWithObjects:count:]
+[NSArray arrayWithObjects:count:]
RCTAppSetupDefaultModuleFromClass block (RCTAppSetupUtils.mm) // handlers provider
-[RCTNetworking prioritizedHandlers]
-[RCTNetworking handlerForRequest:]
-[RCTNetworking networkTaskWithDevToolsRequestId:request:completionBlock:]
-[RCTNetworking sendRequest:callback:] block_invoke_2
Main thread at the same time:
-[CodePush loadBundle]
RCTTriggerReloadCommandListeners
-[RCTHost _reloadWithShouldRestartSurfaces:]
MANDATORY Reproducer
I can't share the app. The steps above reproduce it on a new-arch app with a JS loop and a reload trigger. I can build a minimal public reproducer if needed.
- 主要言語
- C++
- スター
- 127k
- フォーク
- 25.5k
- 平均マージ
- 3日 22時間
- マージ済み PR(30日)
- 235
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
react/react-native のほかの issue
-
Needs: Author Feedback Needs: Repro
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
react/react-native#60059 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
Needs: Triage :mag:
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
react/react-native#60000 ·
メンテナーはふだん 2 日以内に返信
-
`yarn test-ios` exits before building RNTester: `objc-test.sh` launches the WebSocket server script #59433 deleted対応中かも @lazerg が 4 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
react/react-native#59939 ·
メンテナーはふだん 2 日以内に返信
-
iOS Fabric pointer-handler reset leaves the next lone touch non-primary対応中かも @alleneubank が 6 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
react/react-native#59919 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
react/react-native#59722 ·
メンテナーはふだん 2 日以内に返信
react/react-native の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
petercorke/robotics-toolbox-python#943 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area:build bug
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
NatronGitHub/openfx-arena#71 ·
メンテナーはふだん 1 日以内に返信
-
upstream-watcher: Netflix/vmaf cf677baaa039 is not ported対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンupstream-blocked
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
ROCm/FastFlowLM#1057 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
NatronGitHub/openfx-gmic#45 ·
メンテナーはふだん 1 日以内に返信