Repository navigation
[Tests] Avoid Java heap OOM in upload-reset test - #13270
Closed
simonrozsival wants to merge 1 commit into
Closed
simonrozsival wants to merge 1 commit into
simonrozsival wants to merge 1 commit into
Conversation
MemoryStream.CopyToAsync writes the entire 16 MiB backing array at once. JNI marshals that array into Java, exceeding the small app heap on CI devices before the intended connection reset can be asserted. Use a test-only stream that copies through the requested buffer size. Retain the full payload, seekability, repeated completion-option cases, and the existing reset, exception-chain, and rewind assertions. Extract only the upload-test repair from b2ff9d7 in PR #13110. Leave that PR unchanged and exclude its device-launch timeout changes. Prior validation of this identical patch passed make prepare, make all, and all 22 upload tests in Debug, Release AAB, and APK-only Release on an API 35 arm64 emulator with a 16 MiB Java app heap. Co-authored-by: Copilot App <[email protected]> Copilot-Session: b454c3dd-5c23-44f1-9492-868b00d4021a
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The narrow test-only change preserves regression coverage, has reported prior device validation of the identical patch, and has no unresolved findings.
No open issues 🎉
What changed in this PR
This test-only fix prevents Java heap exhaustion during the upload connection-reset regression test introduced in #13125, without changing production behavior.
Changes:
- Adds
BoundedCopyMemoryStreamto copy through a buffer of the requested size rather than writing the entire backing array. - Preserves the 16 MiB payload, seekability, cancellation propagation, repeated completion-option cases, and existing assertions.
| File | Description |
|---|---|
| tests/Mono.Android-Tests/Mono.Android-Tests/Xamarin.Android.Net/AndroidMessageHandlerUploadTests.cs | Uses bounded upload buffers to avoid Java heap exhaustion during reset testing. |
Review effort: Balanced
Member
Author
|
#13110 is closed |
6 tasks
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.
UploadConnectionResetThrowsHttpRequestExceptioncan abort before reaching its connection-reset assertions on CI devices with a 16 MiB Java application heap.System.IO.MemoryStream.CopyToAsync()bypasses the requested copy-buffer size and writes its full 16 MiB backing array.OutputStreamInvokermarshals that entire array through JNI, requiring a 16,777,232-byte Java allocation and triggeringOutOfMemoryErrorfollowed by JNISIGABRT.Use a test-only
BoundedCopyMemoryStreamwhoseCopyToAsync()reads and writes through an actualbyte[bufferSize]. Keep the full 16 MiB payload, seekability, bothHttpCompletionOptioncases,[Repeat (3)], and all existing connection-reset, exception-chain, caller-cancellation, and rewind assertions.This is the exact single-file OOM repair extracted from commit b2ff9d7 in #13110. It deliberately remains in that PR until this standalone fix merges. The test is already on
mainvia #13125, so this repair has no dependency on the signing/resource-designer changes. No product changes, test disabling, orInstallAndRunTests.cstimeout changes are included.Validation
The following build and device-test results are prior validation of the identical patch in the source worktree, not newly executed tests in this extraction worktree. All 22
AndroidMessageHandlerUploadtests passed in each configuration on a temporary API 35 arm64 emulator withdalvik.vm.heapgrowthlimit=16manddalvik.vm.heapsize=576m. The larger absolute heap maximum kept Android system processes operational while ordinary application heaps retained the 16 MiB growth limit. Both connection-reset completion options retained[Repeat (3)].Fresh extraction checks:
git diff --checkpassed; the single-file diff and complete file content match the source commit byte-for-byte. The change is exactly 13 additions and 1 deletion in one file. No build/test suite was rerun for this extraction, and no CI rerun was requested.Exact prior local commands and results
Result: both passed. The prior build required generating missing API 37.1/37.2 reference/documentation outputs and temporarily withholding an old stock Android workload registration during dependency installation; the registration was restored afterward, without repository build-configuration changes.
Result: Debug build/install passed; 22 passed, 0 failed, 0 skipped.
Result: Release AAB build/install passed; 22 passed, 0 failed, 0 skipped.
Result: APK-only Release build/install passed; 22 passed, 0 failed, 0 skipped. Release builds emitted existing trim-analysis warnings but no errors.
Pull Request
title and
description
should follow the
commit-messages.mdworkflow documentation, and in particular should include:No separate issue is associated with this extraction; related PRs are linked above.