Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[data grid] Ability to let webworker handle serialization when exporting #16440

Open
Fronix opened this issue Feb 3, 2025 · 0 comments
Open
Labels
component: data grid This is the name of the generic UI component, not the React module! feature: Export new feature New feature or request plan: Premium Impact at least one Premium user status: waiting for maintainer These issues haven't been looked at yet by a maintainer

Comments

@Fronix
Copy link

Fronix commented Feb 3, 2025

Summary

As stated in #6772 there is an issue with exporting large amounts of rows, even when using a webworker the serialization can freeze the main thread.

I would like to be able to let the webworker handle serialization when using a webworker. It also hinders us to show the progress of the export, sometimes the alert renders in time, but sometimes it freezes before it can be shown.

Edit:
After some digging, this code seems to be in large part responsible for the freeze:

https://github.com/mui/mui-x/blob/7a960127e541f5c401ecf16e74b59eb351ac5ad5/packages/x-data-grid-premium/src/hooks/features/export/useGridExcelExport.tsx#L143C1-L151C37

      // Slow
      const serializedColumns = serializeColumns(exportedColumns, options.columnsStyles || {});

      apiRef.current.resetColSpan();
     // Slow
      const serializedRows = exportedRowIds.map((id) =>
        serializeRowUnsafe(id, exportedColumns, apiRef, valueOptionsData, {
          escapeFormulas: options.escapeFormulas ?? true,
        }),
      );
      apiRef.current.resetColSpan();

apiRef is used in serializeRowUnsafe so it can't be sent to the worker unless we can't send it the data it needs to run the functions.

Examples

Here's an example of 50 000 rows freezing the main thread https://stackblitz.com/edit/react-s1jtpzft

Motivation

Having a set limit of rows to be exportable without freezing doesn't seem userfriendly and since have webworker support, as much work as possible should be done by the worker.

Search keywords: datagrid, exporting

@Fronix Fronix added new feature New feature or request status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Feb 3, 2025
@KenanYusuf KenanYusuf added component: data grid This is the name of the generic UI component, not the React module! feature: Export plan: Premium Impact at least one Premium user labels Feb 4, 2025
@KenanYusuf KenanYusuf changed the title Ability to let webworker handle serialization when exporting [data grid] Ability to let webworker handle serialization when exporting Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module! feature: Export new feature New feature or request plan: Premium Impact at least one Premium user status: waiting for maintainer These issues haven't been looked at yet by a maintainer
Projects
None yet
Development

No branches or pull requests

2 participants