Skip to content

[Due for payment 2026-05-07] [$250] Report- Something when wrong when resize to fullscreen in bar or line view of expense report #87066

Closed

Description

@mitarachim

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: v9.3.52-0
Reproducible in staging?: Yes
Reproducible in production?: N/A - new feature, doesn't exist in prod
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #85829
Email or phone of affected tester (no customers): N/A
Issue reported by: Applause Internal Team
Bug source: Pull Request QA execution
Device used: Windows 10
App Component: Other

Action Performed:

Precondition: Log in an account with many expense reports.

  1. Go to reports tab
  2. Select type:expense
  3. Select group-by:merchant
  4. Resize window in multiple times
  5. Maximize the window
    Result: Ocasionally when resizing to fullscreen app crashes

Expected Result:

When maximizing the window the app must run and display the content

Actual Result:

Ocasionally when resizing to fullscreen app crashes

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

Bug7120391_1775186981774.bandicam_2026-04-02_20-40-16-534.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @borys3kk
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022040007211317396839
  • Upwork Job ID: 2040007211317396839
  • Last Price Increase: 2026-04-03

Activity

  1. added
    Daily
    Bug
    on Apr 3, 2026
  2. MelvinBot commented on Apr 3, 2026

    @MelvinBot
    Contributor

    Proposal

    Problem: The app crashes intermittently when resizing the browser window to fullscreen while viewing bar/line charts in the reports tab.

    Root Cause: The crash is caused by a combination of two issues introduced in PR #85829:

    1. Chart mount/unmount cycle during resize — Both BarChartContent.tsx:258 and LineChartContent.tsx:256 use {chartWidth > 0 && (<CartesianChart ...>)}. When the browser window resizes rapidly, chartWidth can momentarily hit 0 via onLayout, causing the entire CartesianChart (and all its Skia resources) to unmount and immediately remount. This intermittent teardown/rebuild is the trigger.

    2. Unprotected Skia Paragraph API calls during render — buildChartParagraph (utils.ts:54-65) is called directly during render in ChartXAxisLabels.tsx:41-48, ChartYAxisLabels.tsx:38-43, and useChartLabelLayout.ts:54. These calls create Skia paragraph objects via Skia.ParagraphBuilder.Make() with no error handling. If the fontMgr or CanvasKit context is in a transitional state during the mount/unmount cycle, the native Skia call throws an unhandled exception that crashes the app.

    Solution:

    1. Replace the chartWidth > 0 conditional mount with a style-based approach (e.g., opacity: 0 or pointerEvents: 'none') so the CartesianChart stays mounted during resize transitions, avoiding the Skia resource teardown/rebuild cycle.
    2. Add a try/catch around buildChartParagraph in utils.ts to gracefully handle Skia failures during transitional states, returning a fallback (null paragraph with width 0).
    3. Optionally debounce the handleLayout callback in both BarChartContent.tsx:88 and LineChartContent.tsx to reduce the frequency of layout-triggered re-renders during rapid resize.
    Supporting evidence

    Mount/unmount cycle:

    • BarChartContent.tsx:258: {chartWidth > 0 && (<CartesianChart ...>)}
    • LineChartContent.tsx:256: Same pattern
    • handleLayout at BarChartContent.tsx:88-90 sets chartWidth from onLayout, which can report 0 during rapid window transitions

    Skia paragraph creation during render (no error handling):

    • utils.ts:54-65: buildChartParagraph calls Skia.ParagraphBuilder.Make() directly
    • ChartXAxisLabels.tsx:41-48: Creates paragraphs for every label in the render body
    • ChartYAxisLabels.tsx:38-43: Same pattern
    • useChartLabelLayout.ts:54: measureTextWidth calls buildChartParagraph for every data point on each state change

    Additional NaN/Infinity risk:

    • BarChartContent.tsx:135: calculatedBarWidth = ((1 - BAR_INNER_PADDING) * domainWidth) / data.length — if handleChartBoundsChange fires before early-return guard at line 248, data.length === 0 produces Infinity
    • Victory-native's CartesianChart.js:116-119: When size.width - padding.right < padding.left during resize, output window inverts and d3 scales can produce NaN values

    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.

  3. added
    External
    on Apr 3, 2026
  4. added
    Help Wanted
    on Apr 3, 2026
  5. melvin-bot commented on Apr 3, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @DylanDylann (External)

  6. changed the title [-]Report- Something when wrong when resize to fullscreen in bar or line view of expense report[/-] [+][$250] Report- Something when wrong when resize to fullscreen in bar or line view of expense report[/+] on Apr 3, 2026
  7. melvin-bot commented on Apr 3, 2026

    @melvin-bot
  8. KJ21-ENG commented on Apr 3, 2026

    @KJ21-ENG
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    When the window is repeatedly resized and then maximized on Reports → Expenses (Bar/Line view), the app intermittently crashes and shows the “Uh-oh, something went wrong!” page.

    From the attached video, the chart is visible during resize, and after several size transitions the app lands on the global error page.

    What is the root cause of that problem?

    Both chart implementations mount/unmount CartesianChart based on chartWidth > 0, while chartWidth is continuously driven by onLayout during window resizing. During rapid resize/maximize transitions, width can transiently cross zero/non-zero boundaries, causing repeated chart teardown/recreation.

    Bar chart conditional mount and resize handler:

    const handleLayout = useCallback((event: LayoutChangeEvent) => {
    setChartWidth(event.nativeEvent.layout.width);
    }, []);

    {chartWidth > 0 && (
    <CartesianChart
    xKey="x"
    padding={CHART_PADDING}
    yKeys={['y']}
    domainPadding={domainPadding}
    actionsRef={actionsRef}
    customGestures={customGestures}
    onChartBoundsChange={handleChartBoundsChange}
    onScaleChange={handleScaleChange}
    xAxis={{
    font,
    tickCount: data.length,
    labelColor: theme.textSupporting,
    lineWidth: X_AXIS_LINE_WIDTH,
    // Victory-native positions x-axis labels at: chartBounds.bottom + labelOffset + fontSize.
    // We subtract descent (fontSize - ascent) so the gap from chart to the ascent line equals AXIS_LABEL_GAP.
    labelOffset: AXIS_LABEL_GAP - Math.abs(font?.getMetrics().descent ?? 0),
    formatXLabel: formatLabel,
    labelRotate: labelRotation,
    labelOverflow: 'visible',
    }}
    yAxis={[
    {
    font,
    labelColor: theme.textSupporting,
    formatYLabel: formatValue,
    tickCount: Y_AXIS_TICK_COUNT,
    lineWidth: Y_AXIS_LINE_WIDTH,
    lineColor: theme.border,
    labelOffset: AXIS_LABEL_GAP,
    domain: yAxisDomain,
    },
    ]}
    frame={{lineWidth: 0}}
    data={chartData}
    >
    {({points, chartBounds}) => <>{points.y.map((point) => renderBar(point, chartBounds, points.y.length))}</>}
    </CartesianChart>
    )}

    Line chart uses the same pattern:

    const handleChartBoundsChange = useCallback((bounds: ChartBounds) => {
    setPlotAreaWidth(bounds.right - bounds.left);

    {chartWidth > 0 && (
    <CartesianChart
    xKey="x"
    padding={{top: CHART_PADDING, left: CHART_PADDING, right: CHART_PADDING, bottom: (xAxisLabelHeight ?? 0) + CHART_PADDING}}
    yKeys={['y']}
    domainPadding={domainPadding}
    actionsRef={actionsRef}
    customGestures={customGestures}
    onChartBoundsChange={handleChartBoundsChange}
    renderOutside={renderOutsideComponents}
    xAxis={{
    tickCount: data.length,
    lineWidth: X_AXIS_LINE_WIDTH,
    }}
    yAxis={[
    {
    font,
    labelColor: theme.textSupporting,
    formatYLabel: formatValue,
    tickCount: Y_AXIS_TICK_COUNT,
    lineWidth: Y_AXIS_LINE_WIDTH,
    lineColor: theme.border,
    labelOffset: AXIS_LABEL_GAP,
    domain: yAxisDomain,
    },
    ]}
    frame={{lineWidth: 0}}
    data={chartData}
    >
    {({points}) => (
    <Line
    points={points.y}
    color={DEFAULT_CHART_COLOR}
    strokeWidth={2}
    curveType="linear"
    />
    )}
    </CartesianChart>
    )}

    This resize-driven remount cycle is the unstable part that aligns with the intermittent crash behavior captured in media.

    What changes do you think we should make in order to solve the problem?

    1. Remove chartWidth > 0 conditional mounting for CartesianChart in both Bar and Line chart components; keep charts mounted once data/font are ready.
    2. Guard width-sensitive calculations and rendering with safe fallbacks (e.g., minimum width / no-op gesture math) rather than unmounting the whole chart tree.
    3. If needed for visual polish, hide chart content with style (opacity or placeholder layer) while width is invalid, but avoid component teardown/recreation during resize.
    4. Add regression coverage for rapid resize/maximize on web reports chart view to verify no crash and stable chart rendering.

    What alternative solutions did you explore? (Optional)

    • Debouncing onLayout can reduce update frequency but does not remove mount/unmount churn by itself.
    • Wrapping more chart internals in guards helps, but the highest-impact fix is to stop full chart remounting on transient layout values.
  9. borys3kk commented on Apr 3, 2026

    @borys3kk
    Contributor

    Hello, this was most likely caused by my PR, I'm looking into it

  10. trasnake87 commented on Apr 3, 2026

    @trasnake87
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    The app intermittently crashes with "Something went wrong" when rapidly resizing or maximizing the browser window while viewing bar or line chart views in the reports tab.

    What is the root cause of that problem?

    The crash is caused by uncontrolled parent-driven re-renders cascading into the chart components during resize. SearchChartView (https://github.com/Expensify/App/blob/main/src/components/Search/SearchChartView.tsx#L46) is not memoized and creates a fresh handleItemPress callback on every render (line 52). Since it is a child of the Search component which re-renders on every window resize event (via useWindowDimensions → useResponsiveLayout), each resize frame triggers a full re-render cascade: SearchChartView → SearchBarChart (https://github.com/Expensify/App/blob/main/src/components/Search/SearchBarChart.tsx#L8) which creates new chartData and handleBarPress references each render (lines 10, 21) → down into the chart content. These parent-driven re-renders overlap with the chart's own layout-driven re-renders (from onLayout), creating a race condition where concurrent Skia CanvasKit paragraph operations corrupt the WASM module's internal state and throw an unhandled exception.

    What changes do you think we should make in order to solve the problem?

    We should memoize SearchChartView with React.memo and stabilize its internal callback with useCallback. Since its props (queryJSON, view, groupBy, data, isLoading) are all referentially stable during resize, this blocks the entire parent-driven re-render cascade from reaching the chart, leaving only the sequential layout-driven re-renders which don't race with each other.

    In src/components/Search/SearchChartView.tsx:

    function SearchChartView({queryJSON, view, groupBy, data, isLoading}: SearchChartViewProps) {
        const {preferredLocale} = useLocalize();
    
        const {getLabel, getFilterQuery} = CHART_GROUP_BY_CONFIG[groupBy];
        const ChartComponent = CHART_VIEW_TO_COMPONENT[view];
    
        const handleItemPress = useCallback((filterQuery: string) => {
            const currentQueryString = buildSearchQueryString(queryJSON);
            const newQueryJSON = buildSearchQueryJSON(`${currentQueryString} ${filterQuery}`);
            if (!newQueryJSON) {
                Log.alert('[SearchChartView] Failed to build search query JSON from filter query');
                return;
            }
            newQueryJSON.groupBy = undefined;
            newQueryJSON.view = CONST.SEARCH.VIEW.TABLE;
            newQueryJSON.sortBy = CONST.SEARCH.TABLE_COLUMNS.DATE;
            newQueryJSON.sortOrder = CONST.SEARCH.SORT_ORDER.DESC;
            const newQueryString = buildSearchQueryString(newQueryJSON);
            Navigation.navigate(ROUTES.SEARCH_ROOT.getRoute({query: newQueryString}));
        }, [queryJSON]);
    
        // ... rest unchanged
    }
    
    export default React.memo(SearchChartView);
  11. trasnake87 commented on Apr 3, 2026

    @trasnake87
    Contributor

    Contributor details
    Your Expensify account email: trasnake87@gmail.com
    Upwork Profile Link: https://www.upwork.com/freelancers/~010f770315ab181656

  12. melvin-bot commented on Apr 3, 2026

    @melvin-bot

    ✅ Contributor details stored successfully. Thank you for contributing to Expensify!

  13. 30 remaining items

  14. added
    Weekly
    and removed
    Daily
    on May 4, 2026
  15. DylanDylann commented on May 4, 2026

    @DylanDylann
    Contributor

    @MelvinBot Could you find the PR that caused this issue?

  16. MelvinBot commented on May 4, 2026

    @MelvinBot
    Contributor

    The PR that caused this issue is #85829 ("Add paragraph api to skia") by borys3kk, merged on 2026-04-02. This is confirmed by:

    1. The issue body itself, which links to that PR under "caught during regression testing"
    2. borys3kk's own comment: "this was most likely caused by my PR, I'm looking into it"

    The fix was shipped in #87084, also by borys3kk.

  17. added
    Daily
    Awaiting Payment
    and removed
    Weekly
    on May 6, 2026
  18. melvin-bot commented on May 6, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  19. melvin-bot commented on May 7, 2026

    @melvin-bot

    Payment Summary

    Upwork Job

    BugZero Checklist (@mallenexpensify)

    • (if NewFeature) I have created a PR for any necessary HelpDot updates, or I confirmed no updates are necessary.
    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/2040007211317396839/hired)
    • I have verified the PR was not reverted
    • I have applied any discounts due to bugs/regressions introduced by this PR
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  20. mallenexpensify commented on May 8, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @DylanDylann due $250 via NewDot

  21. quinthar commented on May 30, 2026

    @quinthar
    Contributor

    Approved $250 to @DylanDylann

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentBugDailyExternal

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions