Repository navigation
[Payment due @bernhardoj] [No QA] Cap victory chart canvas size and axis tick count - #106557
Conversation
|
@bernhardoj Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
No product review needed. |
|
@puneetlath Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb Safari |
|
@NicolasBonet how to have the concierge send a chart? I asked, "Give me a spend analysis chart," but it gives me a link to the Insight page. |
|
@bernhardoj Concierge only draws charts for analytical questions that break spend down by month, category, merchant, submitter or tag. It always has that ability in a workspace's #admins room, and the workspace needs expenses. For example, try asking in #admins: "What was my monthly spend for the last 6 months?" or "What are my top spending categories this year?" I've updated step 5 of the test steps with this too. |
|
@NicolasBonet hmm, I got the breakdown in text
|
|
It shows a chart now after I asked it to draw a chart |
|
🎯 @bernhardoj, thanks for reviewing and testing this PR! 🎉 A payment issue will be created for your review once this PR is deployed to production. If payment is not needed (e.g., regression PR review fix etc), react with 👎 to this comment to prevent the payment issue from being created. |
|
@ZhenjaHorbach Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the changes limiting canvas dimensions and axis tick counts.
No open issues 🎉
What changed in this PR
This PR limits memory usage from oversized chart markup in the headless renderer and shared axis parser, while preserving normal chart sizes and tick counts.
Changes:
- Reject canvas dimensions above 4096 pixels per side.
- Cap explicit axis
tickcountvalues at 100. - Add boundary and regression tests, plus Bun typings for parameterized tests.
| File | Description |
|---|---|
tests/unit/components/HTMLEngineProvider/VictoryChartParsers.test.ts |
Tests oversized and normal tick counts. |
src/components/HTMLEngineProvider/HTMLRenderers/VictoryChartRenderer/parsers/victoryAxisParser.ts |
Caps explicit tick counts at the shared maximum. |
src/components/HTMLEngineProvider/HTMLRenderers/VictoryChartRenderer/constants.ts |
Defines the 100-tick limit. |
server/victory-chart-renderer/tests/resolveCanvasSize.test.ts |
Tests acceptance at 4096 and rejection above it. |
server/victory-chart-renderer/src/types/bun.d.ts |
Adds typing for test.each. |
server/victory-chart-renderer/src/resolveCanvasSize.ts |
Rejects canvas dimensions exceeding 4096 pixels. |
Review effort: Balanced
|
🚧 NicolasBonet has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/NicolasBonet in version: 9.5.41-0 🚀
|
|
No help site update needed — this PR only adds internal chart-rendering safeguards against excessive memory use, without introducing a feature, changing the normal user workflow, or making an existing article inaccurate. |
|
🚀 Deployed to production by https://github.com/marcaaron in version: 9.5.41-2 🚀
Bundle Size Analysis (Sentry): |
|
🤖 Payment issue created: #107321 |


Explanation of Change
The headless chart renderer creates a surface of whatever
width×heightthe<victorychart>asks for, and the shared axis parser passes anytickcountto victory-native, which generates one tick per count. Very large values let a single chart use gigabytes of memory.This caps the canvas at 4096 px per side, rejecting larger charts with the same kind of error as the existing size validation, and limits the axis tick count to 100. Real charts are 680 px wide and use fewer than ten ticks, so they are unaffected.
Fixed Issues
$ https://github.com/Expensify/Expensify/issues/702554
PROPOSAL: N/A
Tests
npm run server:vcr:test.resolveCanvasSizecases that reject 4097, 16000 and1e9and accept 4096.npx jest tests/unit/components/HTMLEngineProvider/VictoryChartParsers.test.ts.tickcount="1000000000"at 100 and keeptickcount="5".Verified locally:
npm run server:vcr:testpasses (37 tests), including byte-identical golden images for the existing fixtures.Built the Linux renderer from this branch and ran it in the dev VM: a 680x430 chart renders in 0.26s and a 4096x4096 chart still renders, while a 16000x16000 chart is rejected in 0.2s at about 190 MB instead of taking 7s and 2.2 GB. A chart with
tickcount="1000000000"renders in 0.25s.On web, chart comments in a chat render as before, including a chat with 13 charts, and the page stays responsive.
Verify that no errors appear in the JS console
Offline tests
N/A, this only changes how chart markup is parsed and rendered.
QA Steps
[No QA] The renderer change only affects charts larger than any we generate, and existing charts render byte-identical golden images in the renderer tests.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Not tested. The only client change is the
tickcountcap in the shared axis parser, which is covered by unit tests and does not depend on the platform.Android: mWeb Chrome
Not tested. The only client change is the
tickcountcap in the shared axis parser, which is covered by unit tests and does not depend on the platform.iOS: Native
Not tested. The only client change is the
tickcountcap in the shared axis parser, which is covered by unit tests and does not depend on the platform.iOS: mWeb Safari
Not tested. The only client change is the
tickcountcap in the shared axis parser, which is covered by unit tests and does not depend on the platform.MacOS: Chrome / Safari
Chart comment rendered on web (Chromium) with this branch: