Repository navigation
[release/11.0.1xx] [tests] Backport bounded-copy upload test - #13751
jonathanpeppers merged 1 commit into
Conversation
Backport only the AndroidMessageHandlerUploadTests change from 9d70f2f (#13110). Bound each upload write to avoid exhausting small Java heaps. Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the test-only bounded-copy upload change.
No open issues 🎉
What changed in this PR
Backports the bounded-copy upload test change to release/11.0.1xx to address emulator out-of-memory crashes tracked in #13716. The change is limited to test code.
Changes:
- Uses
BoundedCopyMemoryStreamfor the connection-reset test’s 16 MiB request body. - Overrides asynchronous copying to write in buffer-sized chunks instead of one large write across JNI, while forwarding cancellation.
| File | Description |
|---|---|
tests/Mono.Android-Tests/Mono.Android-Tests/Xamarin.Android.Net/AndroidMessageHandlerUploadTests.cs |
Adds and uses a bounded-copy stream to limit individual upload writes. |
Review effort: Balanced
|
@dalexsoto review |
dalexsoto
left a comment
There was a problem hiding this comment.
Reviewed 7ddbbb0a against release/11.0.1xx at bdbe0a66 (merge base 6066c2d2). This is a static, read-only review; nothing was built or run.
The test file at this head is byte-identical to main after #13110, and it starts from the same blob, so this is an exact backport. The only target commit since the merge base (#13571) is a dependency update and doesn't touch this file.
I traced the upload path on this branch to confirm the override is actually reached:
AndroidMessageHandler.SetupRequestBodysets fixed-length streaming, so the Java connection doesn't buffer the body.WriteRequestContentToOutputcallsReadAsStreamAsyncand thenCopyToAsync (httpConnection.OutputStream, 4096, cancellationToken)(AndroidMessageHandler.cs:1074-1075).StreamContent's read-only wrapper forwardsCopyToAsyncwith the buffer size, soBoundedCopyMemoryStream.CopyToAsyncruns with 4096.- Each
OutputStreamInvoker.Writegoes throughJNIEnv.NewArrayfor the whole managed buffer, so this replaces one 16 MiB Java allocation with 4 KiB ones.
The asserted exception chain and the Position == 0 rewind come from unchanged handler code, the 16 MiB body is still far larger than the server reads before the reset, and the file compiles under this branch's settings (it already uses primary constructors; LangVersion is latest).
Non-blocking:
- The override isn't strictly needed:
MemoryStream.CopyToAsyncalready falls back toStream's chunked loop for subclasses, so the subclass alone would bound the writes. Keeping it identical tomainis reasonable. - #13716 pairs this with #13310 (
SharedPreferencesTestheap pressure), which isn't onrelease/11.0.1xxyet, so that out-of-memory crash may still show up on this branch until it is backported too.
LGTM.
Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
7ddbbb0ae0745e91032a2c4ff0cc442e83170ba3↓ Android workload unavailable locally.
↓ No local reproduction.
↓ Not confirmed with this change in CI.
Backport of the
AndroidMessageHandlerUploadTestschange from #13110.UploadConnectionResetThrowsHttpRequestExceptioncrashes withOutOfMemoryErroron CI emulators, becauseMemoryStream.CopyToAsyncwrites the 16 MiB body in one call. Copy in chunks instead.Context: #13716
Validation:
build.cmdfailed on locked files.dotnet-local.cmd build tests\Mono.Android-Tests\Mono.Android-Tests\Mono.Android.NET-Tests.csproj --no-restore -nodeReuse:false -v:minimalfailed with NETSDK1147: the Android workload is missing. The device test was not run.Pull Request
title and
description
should follow the
commit-messages.mdworkflow documentation, and in particular should include: