lagrange icon indicating copy to clipboard operation
lagrange copied to clipboard

Long wrapped paragraphs in input fields cause slowdown

Open stacksmith opened this issue 3 years ago • 6 comments

I accidentally pasted a very long bunch of garbage (maybe a few hundred words from a dictionary by the looks of it) directly into the url bar, causing:

  1. Longish delay while chewing on it;
  2. An error message indicating a bad URL;
  3. What appeared to be a UI lockup - I was unable to enter a different url into the now-blank URL bar, or even close the window with the 'x' immediately (it did close after a bit).

Upon reopening Lagrange attempted to fetch the same URL, again incapacitating the window. This time I switched to another tab and x'ed the bad tab. I was afraid to experiment too much with this.

stacksmith avatar Feb 19 '22 18:02 stacksmith

The input fields do get inefficient with long text, especially when it needs to be wrapped a lot. The URL field in particular is a little problematic as it is restricted to a single visible line. I've toyed with an expanding input field in the past; maybe I'll try that again, or perhaps some popup that has room for a larger edit field. In any case, I'll still need to optimize the input widget.

You can delete the "state.lgr" file if you ever need to reset the persistent app state, including the open tabs.

skyjake avatar Feb 20 '22 05:02 skyjake

Thanks, it's good to know how to clear state.
Isn't there a hard limit on the size of the request? It's hard to imagine a single line of a couple of Kb causing this much trouble... Also, I imagine it's an easy check for a valid URL or at least a heuristic (invalid characters such as spaces, lack of slashes, no protocol at the start, etc)...

stacksmith avatar Feb 22 '22 14:02 stacksmith

Gemini URLs do have a limit of 1024 bytes. However, at the moment all text fields work pretty much the same in the app: either a fixed-length mode that is meant for very short input (~10 chars; numbers), or unlimited length mode with line wrapping. Adding a third mode specifically for URLs would make sense.

The implementation is quite inefficient when it comes to line wrapping. I can definitely see a few KB causing problems if it has to wrap a lot... The input widget is one of the most complex UI elements, and definitely could use more work. See also: gemini://skyjake.fi/gemlog/2021-08_complexity-of-input.gmi

skyjake avatar Feb 22 '22 14:02 skyjake

It seems pretty extreme! 1K, say 600 words to wrap should not bring an 4-core 4GHz machine with gobs of RAM down to its knees. Something is seriously wrong with the wrap algo...

stacksmith avatar Feb 22 '22 17:02 stacksmith

Does the same happen if you paste the words in the Upload dialog text editor?

What is the width of your browser window?

skyjake avatar Feb 22 '22 17:02 skyjake

Version 1.12 will include a few optimizations that improve performance of long wrapped text lines in input fields.

skyjake avatar Mar 18 '22 14:03 skyjake