Commit 0c153e2
Handle OutOfMemoryError in NetworkingModule response processing (#56630)
Summary:
Pull Request resolved: #56630
Catch `OutOfMemoryError` in the `onResponse` callback's response processing try-catch block in `NetworkingModule.kt`. Previously, only `IOException` was caught — `OutOfMemoryError` (which extends `Error`, not `Exception`) would propagate uncaught and crash the app.
When the Java heap is near its limit (e.g., 256MB with <1% free), any allocation during response processing (buffer creation in `readWithProgress`, `responseBody.bytes()`, `responseBody.string()`) can trigger OOM. The fix converts this to a network request error event sent to JS, allowing the app to handle the failure gracefully (retry, show error message) instead of crashing.
**Crash:** `android_crash:java.lang.OutOfMemoryError:com.oculus.igvr`
**MID:** `024a57cfb70eef9a61af42d845c981a1` — 246 crashes in 7 days
**Task:** T212267841
Logview link: [024a57cfb70eef9a61af42d845c981a1](https://www.internalfb.com/logview/system_vros_crashes/024a57cfb70eef9a61af42d845c981a1)
Changelog: [Android][Fixed] - Catch OutOfMemoryError in NetworkingModule response processing to prevent app crashes
Reviewed By: cortinico
Differential Revision: D102236869
fbshipit-source-id: de6624640b3f2343ca8e516fe7677eecae23a9321 parent c20a58a commit 0c153e2
1 file changed
Lines changed: 8 additions & 0 deletions
File tree
- packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/network
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
773 | 773 | | |
774 | 774 | | |
775 | 775 | | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
776 | 784 | | |
777 | 785 | | |
778 | 786 | | |
| |||
0 commit comments