Stop blindly extracting uint8array.buffer after calling compress()#5753
Merged
mstange merged 3 commits intofirefox-devtools:mainfrom Jan 19, 2026
Merged
Stop blindly extracting uint8array.buffer after calling compress()#5753mstange merged 3 commits intofirefox-devtools:mainfrom
mstange merged 3 commits intofirefox-devtools:mainfrom
Conversation
We were re-wrapping the Buffer into a Uint8Array but discarding the byteOffset and byteLength, so we expanded the returned array to include garbage data. We can just return the Buffer itself, it is a Uint8Array.
We were assuming that the Uint8Array returned from compress() is a view of the entirety of its underlying ArrayBuffer. But that's not necessarily true. Specifically it's not true if gz.ts takes the "node" code path where it uses the node zlib module. We haven't run into this before because our jest environment has browser-like Worker APIs available, so we test the browser code path and the node path doesn't get exercised. But if I change it so that we go down the node path in the tests, then multiple tests in receive-profile.test.ts fail because we pass around compressed buffers with extra garbage bytes at the end. So this fix replaces each of those `.buffer` accesses with a potential copy if that's needed to make sure that the ArrayBuffer doesn't contain any extra data. A cleaner solution might be to stop using ArrayBuffer so much in these tests, but in some of them we simulate the response from a fetch() which definitely has an arrayBuffer() accessor and not a byteArray() accessor.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5753 +/- ##
==========================================
+ Coverage 85.67% 85.69% +0.02%
==========================================
Files 315 315
Lines 31110 31122 +12
Branches 8560 8564 +4
==========================================
+ Hits 26654 26671 +17
+ Misses 4026 4021 -5
Partials 430 430 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
canova
added a commit
that referenced
this pull request
Jan 27, 2026
Lots of exciting changes 🎉: [arai-a] Put radio buttons into labels (#5738) [DaniPopes] Update comment for "unique-string" (#5741) [Karan Pradhan] Hide tooltip filter button in non-sticky tooltips and add hideFilterButton tests (#5718) [arai-a] Add a menu to copy the Marker Table as text (#5732) [arai-a] Make the entire list item clickable for the "Full Range" (#5742) [Markus Stange] Move symbol table demangling out of SymbolStore into SymbolProvider (#5746) [Markus Stange] Remove SVG asset imports from profile-data.ts (#5747) [arai-a] Do not apply sticky tooltip on double click (#5754) [arai-a] Skip the ChartCanvas redraw on the Viewport's internal default state usage (#5744) [Markus Stange] Stop blindly extracting uint8array.buffer after calling compress() (#5753) [Markus Stange] In the assembly view state, refer to the current symbol by index (#5755) [Markus Stange] Fix "scroll to hotspot" functionality in the source view + assembly view (#5759) [Markus Stange] Keep the colorField markerSchema field when processing profiles in the gecko format (#5760) [Markus Stange] Implement dark mode (#5740) [Markus Stange] Fix light-mode colors (#5765) [Markus Stange] Tweak dark mode colours. (#5767) [Nazım Can Altınova] Enable some basic type-aware lints (#5775) [Markus Stange] Allow seeing different assembly code for the same function (#5349) [fatadel] Refine tree view a11y (#5779) [fatadel] Align double-click behavior of stack chart with flame graph (#5782) [Markus Stange] Split gz.ts properly into node and browser variants (#5764) [Markus Stange] Simplify and optimize the computation of per-call-node line and address timings (#5770) [Nazım Can Altınova] Move the dark mode toggle to devtools console (#5783) [Nazım Can Altınova] 🔃 Sync: l10n -> main (Jan 27, 2026) (#5785) [Nazım Can Altınova] Improve Chrome importer marker payload logic (#5717) [Markus Stange] Add a Focus Self transform (#5774) [Nazım Can Altınova] Enable the Turkish locale in production (#5786) And huge thanks to our localizers 🎉 : be: Mikalai Udodau de: Ger de: Michael Köhler el: Jim Spentzos en-CA: chutten en-CA: Saurabh en-GB: Ian Neal en-GB: Saurabh es-CL: ravmn fy-NL, nl: Fjoerfoks fr: Skywarp fr: Théo Chevalier fur: Fabio Tomat fy-NL: Fjoerfoks ia: Melo46 it: Francesco Lodolo [:flod] nl: Fjoerfoks nl: Mark Heijl pt-BR: Marcelo Ghelman ru: berry ru: Valery Ledovskoy sv-SE: Andreas Pettersson tr: Grk zh-CN: Olvcpr423 zh-CN: wxie zh-TW: Pin-guang Chen
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.
We have a node zlib based compression / decompression code path in gz.ts. This path is currently not exercised by our tests. But if I change our Jest environment so that it exercises the node zlib code path, there are test failures in receive-profile.test.ts, for two reasons:
compress/decompresswere discarding thebyteOffsetandbyteLengthof the returned typed array and re-wrapping the entire underlying ArrayBuffer, including potential garbage bytes at the start or at the end. (In practice just at the end.)receive-profile.test.tswere accessing.bufferon the array returned bycompress(), and assuming that the buffer didn't contain any extra data beyond the Uint8Array.So this fix removes the rewrapping, and replaces each of those
.bufferaccesses with a potential copy if that's needed to make sure that the ArrayBuffer doesn't contain any extra data.A cleaner solution might be to stop using ArrayBuffer so much in these tests, but in some of them we simulate the response from a fetch() which definitely has an arrayBuffer() accessor and not a byteArray() accessor.