Handle OutOfMemoryError in NetworkingModule response processing#56630
Closed
shubhamksavita wants to merge 1 commit intofacebook:mainfrom
Closed
Handle OutOfMemoryError in NetworkingModule response processing#56630shubhamksavita wants to merge 1 commit intofacebook:mainfrom
shubhamksavita wants to merge 1 commit intofacebook:mainfrom
Conversation
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: D102236869
|
@shubhamksavita has exported this pull request. If you are a Meta employee, you can view the originating Diff in D102236869. |
cortinico
approved these changes
Apr 28, 2026
Contributor
cortinico
left a comment
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
Collaborator
|
This pull request was successfully merged by @shubhamksavita in 0c153e2 When will my fix make it into a release? | How to file a pick request? |
|
This pull request has been merged in 0c153e2. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Catch
OutOfMemoryErrorin theonResponsecallback's response processing try-catch block inNetworkingModule.kt. Previously, onlyIOExceptionwas caught —OutOfMemoryError(which extendsError, notException) 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.igvrMID:
024a57cfb70eef9a61af42d845c981a1— 246 crashes in 7 daysTask: T212267841
Logview link: 024a57cfb70eef9a61af42d845c981a1
Changelog: [Android][Fixed] - Catch OutOfMemoryError in NetworkingModule response processing to prevent app crashes
Reviewed By: cortinico
Differential Revision: D102236869