CSV rendering hangs viewer for large files
Summary
The feature added to render CSV content as tables should apply a limit to the number of rows visualized.
Feature was added via #14174 (closed)
For files with (for example) 50000 rows (packed in about 1 MiB), the web page load entirely freezes and the page goes unresponsive and does not load even after several minutes. The browser's CPU use goes very high during this.
Steps to reproduce
- In any project, add the following file content with a CSV extension (say
foo.csv
): https://gitlab.com/-/snippets/2175107/raw/main/50k-rows-save-with-csv-extension.txt to the repository as a new file (this file contains 50k random rows) - In the repository file browser, attempt to view this file by clicking on it in the tree
- The page loaded attempts to begin rendering the CSV as a table but never does
- The browser begins warning about page slowing it down, CPU hits the roof, etc.
- Wait 5 minutes, page has still not loaded.
- Consequently, observe that the other UI items (such as pipeline state of commit, etc.) are also awaiting on the completion of the rendering and keep spinning on the UI.
- Also observe that no UI controls work on the page anymore. If I wanted to 'escape' the situation by clicking the raw link, the click does not respond due to the synchronous block that appears to be occurring.
Example Project
https://gitlab.com/gitlab-gold/hchouraria/sample-ci/-/blob/csv-test/foo.csv
What is the current bug behavior?
Browser tab hangs when trying to view CSV file. CSV file is never rendered.
What is the expected correct behavior?
Fall back to non-rendered CSV view (plaintext), or attempt to render only limited number of rows.
Relevant logs and/or screenshots
Visit https://gitlab.com/gitlab-gold/hchouraria/sample-ci/-/blob/csv-test/foo.csv
Output of checks
This bug happens on GitLab.com
Possible fixes
Some ideas:
- Avoid rendering the table beyond a hundred rows (showing a message indicating a partial display)
- A disadvantage of this method is that it forces the user to use a raw view to see all the rows, but a raw view lacks the standard view's line numbering that they were benefiting from
- Use paparender dependency library's fast parsing mode, although this doesn't work for quoted data files
Workarounds
The Web IDE mode is unaffected by this file type rendering and can be used to browse and operate over the file.