Commit 26c3aef
Handle OutOfMemoryError in NetworkingModule response processing
Summary:
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: D1022368691 parent c20a58a commit 26c3aef
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