Skip to content

UI unresponsive when sketch has a very long line #1343

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

Closed
3 tasks done
per1234 opened this issue Aug 21, 2022 · 1 comment · Fixed by #1450
Closed
3 tasks done

UI unresponsive when sketch has a very long line #1343

per1234 opened this issue Aug 21, 2022 · 1 comment · Fixed by #1450
Assignees
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@per1234
Copy link
Contributor

per1234 commented Aug 21, 2022

Describe the problem

Arduino sketches may contain large machine generated arrays for data such as images. These may span many columns, using a block that follows the dimensions of the source data (e.g., an array with 320 elements per line might be generated for a 320x240 pixel image), or even be all on a single long line.

🐛 The Arduino IDE UI becomes noticeably laggy or even completely unresponsive when the sketch contains a long line

To reproduce

  1. Download the following demonstration sketch, which contains a line 18432 characters long:
    LongLine.zip
  2. Unzip the downloaded file.
  3. Open the "LongLine" sketch in the Arduino IDE.
    🐛 The IDE UI is completely unresponsive.
  4. Force close the Arduino IDE.
  5. Start the Arduino IDE (making sure it loads an innocuous sketch on startup).
  6. Open the "Command Palette" via the Ctrl+Shift+P shortcut (Command+Shift+P for macOS users).
  7. Select the "Preferences: Open Settings (UI)" command.
  8. In the "Search Settings" field, type editor.maxTokenizationLineLength
  9. Change the value of the "Editor: Max Tokenization Line Length" setting from the default 20000 to 500
  10. Open the "LongLine" sketch in the Arduino IDE.
    🙂 The IDE remains perfectly responsive.

Expected behavior

IDE is usable when the sketch contains long lines.

Arduino IDE version

2.0.0-rc9.2.snapshot-de32bdd

Operating system

Windows

Operating system version

10

Additional context

I am able reproduce the issue in Theia Blueprint (but not in VS Code), so the inability to handle such content is not a bug in the Arduino IDE codebase.

I see that this was reported in the Theia project and fixed by reducing the default value of the editor.maxTokenizationLineLength to 400: eclipse-theia/theia#8021

So a similar change should be made in Arduino IDE as well.


I used a ridiculously long line in the demo sketch (though it was generated from an image of only 32x32 px, using an established tool). More reasonable line lengths result in less dramatic impact, but still make the IDE unpleasant to use. A real world file was provided here:

https://forum.arduino.cc/t/2-0-slows-down-if-very-long-lines-but-ok-with-crs-line-feeds-inserted/1021335/5


It seems that changes to the editor.maxTokenizationLineLength setting are not applied to sketches which have already been "tokenized", so make sure to reload the sketch if you are experimenting with the setting.


The issue is not related to the Arduino Language Server because it occurs even when the language server is not running due to not having a board open.


Originally reported at https://forum.arduino.cc/t/2-0-slows-down-if-very-long-lines-but-ok-with-crs-line-feeds-inserted/1021335

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the latest nightly build
  • My report contains all necessary details
@per1234 per1234 added topic: infrastructure Related to project infrastructure type: imperfection Perceived defect in any part of project topic: theia Related to the Theia IDE framework labels Aug 21, 2022
@kittaakos
Copy link
Contributor

I see that this was reported in the Theia project and fixed by reducing the default value of the editor.maxTokenizationLineLength to 400: eclipse-theia/theia#8021

https://github.com/eclipse-theia/theia/blob/2289366b82f6d013fd4de7b990b21d9037a74c32/packages/editor/src/browser/editor-generated-preference-schema.ts#L118-L124

We should add a default preference in IDE2. I will take care of it.

@kittaakos kittaakos added topic: code Related to content of the project itself and removed topic: infrastructure Related to project infrastructure topic: theia Related to the Theia IDE framework labels Sep 14, 2022
@kittaakos kittaakos assigned kittaakos and unassigned AlbyIanna Sep 14, 2022
kittaakos pushed a commit that referenced this issue Sep 16, 2022
kittaakos pushed a commit that referenced this issue Sep 19, 2022
@per1234 per1234 added the conclusion: resolved Issue was resolved label Sep 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants