Repository navigation
Size the Skia web surface to the chart's painted box - #101291
Conversation
Charts are laid out at their authored design width and fitted to the chat column or the expand modal with a CSS transform. react-native-skia sizes the canvas backing store from clientWidth, which does not include that transform, so the surface is rasterised for the design box and the browser resamples it onto a differently sized area. Text inside the chart ends up softer than the chat text next to it. Patch the web renderer to derive the pixel ratio from the painted width over the layout width, and mount the inline chart only after its column has been measured, since the surface is created on the canvas's first layout and would otherwise be sized before the transform is applied.
|
@abdulrahuman5196 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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5dd910841f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| + const paintedWidth = canvas.getBoundingClientRect().width; | ||
| + const ratio = canvas.clientWidth > 0 && paintedWidth > 0 ? this.pd * (paintedWidth / canvas.clientWidth) : this.pd; |
There was a problem hiding this comment.
Recompute the surface after responsive scale changes
When the window, RHP, or modal is resized after the chart mounts, VictoryChartContainerResponsive updates only the ancestor's CSS transform while the canvas retains its fixed design-size clientWidth. Because this ratio is calculated only in Skia's canvas ResizeObserver callback, and CSS transform changes do not trigger that observer, this.ratio and the backing-store dimensions remain at their initial values and the browser resumes resampling the chart. The renderer needs to be explicitly resized or notified whenever the responsive scale changes.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
@abdulrahuman5196 i think makes sense. what do you think? i mean without a remount a narrow-then-wide resize leaves the surface upscaled, so i would add key={scale} back in both places, it is the only resize handling here. cost is very cheap, i think, it's a remount per layout tick while someone drags the window edge
There was a problem hiding this comment.
it seems we don't need it anymore. I merged main and already done good job there
There was a problem hiding this comment.
I merged main and already done good job there
I don't understand this, could you kindly explain
There was a problem hiding this comment.
I mean upstream main zoom rewrite renders it natively at the zoom-headroom size on a static bitmap and shows it minified until you zoom, so the old upscale blur is gone and we don't need key={scale} workaroundd
|
Hi, will check on this tomorrow morning IST. |
The Skia surface is sized from the painted box only when the canvas first lays out, and a change to the fit transform never re-lays it out. Keying the inline chart and the expanded chart on their scale re-creates the surface at the new painted size after a resize, instead of leaving the browser to stretch the old one.
# Conflicts: # src/components/HTMLEngineProvider/HTMLRenderers/VictoryChartRenderer/components/VictoryChartExpandModal.tsx
|
@codex review |
| return ( | ||
| <View | ||
| style={styles.mw100} | ||
| style={styles.w100} |
There was a problem hiding this comment.
because the chart now mounts only after the container is measured. with mw100 the wrapper shrinks to its children, and there are no children yet at that point, so it measures 0 wide, containerWidth stays 0 and the chart never mounts. w100 makes it measure the column on its own.
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppandroidHybrid-0-Screen_Recording_2026-09-24_at_9.41.37.PM.movAndroid: mWeb ChromeandroidMWeb-0-Screen_Recording_2026-09-24_at_9.28.33.PM.moviOS: HybridAppiosHybrid-0-Screen_Recording_2026-09-24_at_9.16.29.PM.moviOS: mWeb SafariiosMWeb-0-Screen_Recording_2026-09-24_at_9.14.52.PM.movMacOS: Chrome / SafarimacOS-0-Screen_Recording_2026-09-24_at_8.54.46.PM.mov |
abdulrahuman5196
left a comment
There was a problem hiding this comment.
Changes looks good and works well. Reviewers checklist is also complete.
All yours. @roryabraham
🎀 👀 🎀
C+ Reviewed
| Untransformed canvases keep the previous ratio, so nothing else changes. | ||
| ``` | ||
|
|
||
| - Upstream PR/issue: |
There was a problem hiding this comment.
@mukhrr Please create an upstream issue and PR for the patch. Any time you introduce a patch, it's implied that an upstream issue and PR, along with the upgrade to later remove the patch after the fix is merged upstream is in-scope.
Not going to block the bug fix on this, but the issue should stay open until this is done. Payment should be withheld at least until the issue/PR is created.
There was a problem hiding this comment.
@roryabraham thanks for great advice. Here is upstream issue and PR. Now do you think we should raise a mini expensify PR to include these in patch details?
There was a problem hiding this comment.
thanks for opening those! Yes, a PR to update details.md would be great, thanks!
There was a problem hiding this comment.
here it is #102407
@roryabraham lets get it merged. thanks
|
🚧 roryabraham has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/roryabraham in version: 9.4.94-0 🚀
|
|
No help site changes are needed for this PR, so I didn't create a docs PR. This PR fixes blurry chart text on web. It sizes the Skia canvas to the size actually painted on screen, and it waits to mount the inline chart until its column width is measured. It doesn't add or rename any feature, setting, button, or step. Charts just look sharper. What I checked
|
|
@mukhrr We will skip step 7 as we don't have access to DEV
|
|
🚀 Deployed to production by https://github.com/Julesssss in version: 9.4.94-0 🚀
Bundle Size Analysis (Sentry): |
Explanation of Change
Chart text on web looks blurry: the Skia canvas is sized for the chart's design width, but a CSS transform paints it at a different size, so the browser resamples it. The web renderer now sizes the canvas to what is actually painted, and the inline chart waits for its column to be measured before mounting so that size is known when the surface is created.
Fixed Issues
$ #95221
PROPOSAL: #95221 (comment)
Tests
Precondition: a chat containing a chart message (an admins room summary), on a HiDPI screen.
[...document.querySelectorAll('canvas')].at(-1)and compare itswidthwithMath.round(getBoundingClientRect().width * devicePixelRatio). Verify the two numbers are equal.Offline tests
Charts render from data already in the message, so the network state cannot affect this change. Run steps 1 to 6 while offline and verify the same results.
QA Steps
Same as tests.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))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
Web-only change (the patched file is
SkiaPictureView.web.jsand native charts are not transform-scaled).Android: mWeb Chrome
iOS: Native
Web-only change (the patched file is
SkiaPictureView.web.jsand native charts are not transform-scaled).iOS: mWeb Safari
MacOS: Chrome / Safari
Chart title inside the expand modal, 1440px window, before and after (4x crop of the same device pixels):
Inline chart in the chat column, 1440px window, before and after: