René's URL Explorer Experiment


Title: perf(http): native buffer copies for Android request and response bodies by edusperoni · Pull Request #11636 · NativeScript/NativeScript · GitHub

Open Graph Title: perf(http): native buffer copies for Android request and response bodies by edusperoni · Pull Request #11636 · NativeScript/NativeScript

X Title: perf(http): native buffer copies for Android request and response bodies by edusperoni · Pull Request #11636 · NativeScript/NativeScript

Description: PR Checklist The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md#commit-messages. There is an issue for the bug/feature this PR is for. To avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it. You have signed the CLA. All existing tests are passing: https://github.com/NativeScript/NativeScript/blob/master/tools/notes/DevelopmentWorkflow.md#unit-testing. Tests for the changes are included - https://github.com/NativeScript/NativeScript/blob/master/tools/notes/WritingUnitTests.md. What is the current behavior? Two Android HTTP paths move bodies across JNI one element at a time: HttpContent.toArrayBuffer() (http/http-request/index.android.ts) runs Uint8Array.from(raw.toByteArray()). Each read of a Java byte[] element goes through an interceptor and a JNI call, so this costs one JNI round trip per byte. It runs for every toArrayBuffer() call and every XHR/fetch arraybuffer or blob response. ArrayBuffer request bodies (http/http-request-internal/index.android.ts) are sent with ByteBuffer.wrap(Array.from(typedArray)). That builds a JS array of N numbers, then converts it to byte[] one element at a time. What is the new behavior? 1. Response bodies to ArrayBuffer in native code toArrayBuffer() now returns ArrayBuffer.from(java.nio.ByteBuffer.wrap(bytes)). The runtime's ArrayBuffer.from (a runtime global since 2016, so every supported Android runtime has it) copies a heap ByteBuffer's remaining bytes with one memcpy. ArrayBuffer.from also sets a nativeObject property on the result, pointing back to the source ByteBuffer. The new code deletes it, so the result stays a plain ArrayBuffer as before. It matters for two reasons: it would keep the Java byte[] copy alive for as long as the ArrayBuffer lives; the runtime's copy already drained that ByteBuffer, and FileSystemAccess.getBuffer() prefers nativeObject. Without the delete, File.writeSync(response.content.toArrayBuffer()) would write 0 bytes. 2. ArrayBuffer request bodies without a JS array, on newer runtimes NativeScript/android#2102 (merged, on the runtime's next tag) makes the runtime copy a typed array passed to a byte[] parameter with one memcpy. With that runtime, ByteBuffer.wrap(typedArray) is correct and fast. On older runtimes the same call hands a direct ByteBuffer to a byte[] parameter, which is type confusion and corrupts memory in release builds. That rules out a runtime probe, since trying the call on an old runtime is the bug itself. The fast path is gated on the runtime version instead: A new helper, utils/android-runtime-version.ts, checks global.__runtimeVersion once and caches the result. The fast path is used only when the version parses as major.minor.patch[-prerelease] and is strictly greater than 9.1.2. 9.1.2-next.* counts as lower than 9.1.2; 9.1.3-alpha.1, 9.2.0 and 10.0.0 count as greater. A missing, non-string or unparsable version keeps the existing Array.from path. The helper is pure JS, so it is safe to import anywhere. Unit tests cover the version parsing. Verification core:test passes, including the new utils/android-runtime-version.spec.ts. It covers undefined, null, a number, "", "garbage", 9.1.1, 9.1.2, 9.1.2-next.2026-11-11-1, 9.1.3, 9.1.3-alpha.1, 9.2.0, 9.10.0, 10.0.0 and a few malformed strings. apps/automated on an Android emulator (API 36) passes on @nativescript/android 9.1.1 and on a runtime built from android#2102 (__runtimeVersion 9.1.3-pr2102). A temporary benchmark module (not committed): before after toArrayBuffer(), 1 MiB body 268–315 ms ~1 ms (0.6–2.4 ms over 20 runs) request body, 1 MiB, on the android#2102 runtime 31–40 ms 0.33–0.46 ms The benchmark also checked: toArrayBuffer() returns the same bytes as before for a real HTTPS response and for a synthetic 1 MiB body; an empty body gives an empty ArrayBuffer with no nativeObject; writeBufferSync() of the result writes all 1 MiB. On the android#2102 runtime, http.request, XMLHttpRequest.send and fetch with ArrayBuffer bodies (empty, all 256 byte values, 1 MiB) reached a local echo server byte-identical. Blob and typed-array request bodies are sent empty on main; #11654 (stacked on this one) fixes that. Split out of the original version of this PR, which also carried #11652, #11651 and #11653.

Open Graph Description: PR Checklist The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md#commit-messages. There is an issue for the bug/feature this...

X Description: PR Checklist The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md#commit-messages. There is an issue for the bug/feature this...

Opengraph URL: https://github.com/NativeScript/NativeScript/pull/11636

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:ddbe42bc-f693-c481-17c5-41f1ac73b4e6
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id9DF4:4279A:12B4144:192B3DC:6B012E07
html-safe-noncee68675afdb4353a6a1834c375454d714321cb53c9a349fe01ad155e121062225
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5REY0OjQyNzlBOjEyQjQxNDQ6MTkyQjNEQzo2QjAxMkUwNyIsInZpc2l0b3JfaWQiOiI2NTk2MDczNzA5NzAwNzIyMTgzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacf6ab0b186081630ab448141aa15f339927db82bc248a5f7fd3c7cd62d1f0476b
hovercard-subject-tagpull_request:5253819351
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/NativeScript/NativeScript/pull/11636/files
twitter:imagehttps://avatars.githubusercontent.com/u/4061767?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/4061767?s=400&v=4
og:image:altPR Checklist The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md#commit-messages. There is an issue for the bug/feature this...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/NativeScript/NativeScript git https://github.com/NativeScript/NativeScript.git
octolytics-dimension-user_id7392261
octolytics-dimension-user_loginNativeScript
octolytics-dimension-repository_id31492490
octolytics-dimension-repository_nwoNativeScript/NativeScript
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id31492490
octolytics-dimension-repository_network_root_nwoNativeScript/NativeScript
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/NativeScript/NativeScript/pull/11636/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FNativeScript%2FNativeScript%2Fpull%2F11636%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FNativeScript%2FNativeScript%2Fpull%2F11636%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=NativeScript%2FNativeScript
Reloadhttps://github.com/NativeScript/NativeScript/pull/11636/files
Reloadhttps://github.com/NativeScript/NativeScript/pull/11636/files
Reloadhttps://github.com/NativeScript/NativeScript/pull/11636/files
NativeScripthttps://github.com/NativeScript
NativeScripthttps://github.com/NativeScript/NativeScript
Codehttps://github.com/NativeScript/NativeScript
Issues231 (231)https://github.com/NativeScript/NativeScript/issues
Pull requests107 (107)https://github.com/NativeScript/NativeScript/pulls
Discussionshttps://github.com/NativeScript/NativeScript/discussions
Actionshttps://github.com/NativeScript/NativeScript/actions
Projectshttps://github.com/NativeScript/NativeScript/projects
Wikihttps://github.com/NativeScript/NativeScript/wiki
Security and qualityhttps://github.com/NativeScript/NativeScript/security
Insightshttps://github.com/NativeScript/NativeScript/insights
Sign up for GitHub https://github.com/signup?return_to=%2FNativeScript%2FNativeScript%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2FNativeScript%2FNativeScript%2Fissues%2Fnew%2Fchoose
edusperonihttps://github.com/edusperoni
mainhttps://github.com/NativeScript/NativeScript/tree/main
perf/android-buffers-readtexthttps://github.com/NativeScript/NativeScript/tree/perf/android-buffers-readtext
Conversation 4 https://github.com/NativeScript/NativeScript/pull/11636
Commits 2 https://github.com/NativeScript/NativeScript/pull/11636/commits
Checks 9 https://github.com/NativeScript/NativeScript/pull/11636/checks
Files changed 4 https://github.com/NativeScript/NativeScript/pull/11636/files
perf(http): native buffer copies for Android request and response bodies https://github.com/NativeScript/NativeScript/pull/11636/files#top
Show all changes 2 commits https://github.com/NativeScript/NativeScript/pull/11636/files
857a39f perf(http): convert Android response bodies to ArrayBuffer natively edusperoni Nov 11, 2026 https://github.com/NativeScript/NativeScript/pull/11636/commits/857a39fde20e6846ce62a1efb89b47491d08812e
2a5156d perf(http): pass ArrayBuffer request bodies to Java without a JS arra… edusperoni Nov 11, 2026 https://github.com/NativeScript/NativeScript/pull/11636/commits/2a5156df2117fbded0a68e7087a2783d6fa652f5
Clear filters https://github.com/NativeScript/NativeScript/pull/11636/files
Please reload this pagehttps://github.com/NativeScript/NativeScript/pull/11636/files
Please reload this pagehttps://github.com/NativeScript/NativeScript/pull/11636/files
index.android.ts https://github.com/NativeScript/NativeScript/pull/11636/files#diff-5570277e416590db705250da970784cccb5522dd365b87ff1c1f0b500e3b0802
index.android.ts https://github.com/NativeScript/NativeScript/pull/11636/files#diff-4d054ecb5212b0652ddcec2d28d4175035c6bcf31d117822db740bb0e133ef59
android-runtime-version.spec.ts https://github.com/NativeScript/NativeScript/pull/11636/files#diff-ed3a1da8e6da02749ec35f1b2538acc46e03ee13aef0f3a57579ff32b34f1803
android-runtime-version.ts https://github.com/NativeScript/NativeScript/pull/11636/files#diff-2ce703865879c7c9cb420ce4cf75f6f51895e07da88e42189cdda317be903de9
packages/core/http/http-request-internal/index.android.tshttps://github.com/NativeScript/NativeScript/pull/11636/files#diff-5570277e416590db705250da970784cccb5522dd365b87ff1c1f0b500e3b0802
View file https://github.com/NativeScript/NativeScript/blob/2a5156df2117fbded0a68e7087a2783d6fa652f5/packages/core/http/http-request-internal/index.android.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/NativeScript/NativeScript/pull/11636/{{ revealButtonHref }}
https://github.com/NativeScript/NativeScript/pull/11636/files#diff-5570277e416590db705250da970784cccb5522dd365b87ff1c1f0b500e3b0802
https://github.com/NativeScript/NativeScript/pull/11636/files#diff-5570277e416590db705250da970784cccb5522dd365b87ff1c1f0b500e3b0802
https://github.com/NativeScript/NativeScript/pull/11636/files#diff-5570277e416590db705250da970784cccb5522dd365b87ff1c1f0b500e3b0802
https://github.com/NativeScript/NativeScript/pull/11636/files#diff-5570277e416590db705250da970784cccb5522dd365b87ff1c1f0b500e3b0802
packages/core/http/http-request/index.android.tshttps://github.com/NativeScript/NativeScript/pull/11636/files#diff-4d054ecb5212b0652ddcec2d28d4175035c6bcf31d117822db740bb0e133ef59
View file https://github.com/NativeScript/NativeScript/blob/2a5156df2117fbded0a68e7087a2783d6fa652f5/packages/core/http/http-request/index.android.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/NativeScript/NativeScript/pull/11636/{{ revealButtonHref }}
https://github.com/NativeScript/NativeScript/pull/11636/files#diff-4d054ecb5212b0652ddcec2d28d4175035c6bcf31d117822db740bb0e133ef59
https://github.com/NativeScript/NativeScript/pull/11636/files#diff-4d054ecb5212b0652ddcec2d28d4175035c6bcf31d117822db740bb0e133ef59
packages/core/utils/android-runtime-version.spec.tshttps://github.com/NativeScript/NativeScript/pull/11636/files#diff-ed3a1da8e6da02749ec35f1b2538acc46e03ee13aef0f3a57579ff32b34f1803
View file https://github.com/NativeScript/NativeScript/blob/2a5156df2117fbded0a68e7087a2783d6fa652f5/packages/core/utils/android-runtime-version.spec.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/NativeScript/NativeScript/pull/11636/{{ revealButtonHref }}
packages/core/utils/android-runtime-version.tshttps://github.com/NativeScript/NativeScript/pull/11636/files#diff-2ce703865879c7c9cb420ce4cf75f6f51895e07da88e42189cdda317be903de9
View file https://github.com/NativeScript/NativeScript/blob/2a5156df2117fbded0a68e7087a2783d6fa652f5/packages/core/utils/android-runtime-version.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/NativeScript/NativeScript/pull/11636/{{ revealButtonHref }}
Please reload this pagehttps://github.com/NativeScript/NativeScript/pull/11636/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.