marionebl / svg-term-cli

Share terminal sessions via SVG and CSS
MIT License
3.52k stars 118 forks source link

Node is freezing #15

Open henryruhs opened 6 years ago

henryruhs commented 6 years ago

Hello,

svg-term works perfect on my machine with the given 113643 example cast.

There seems to be an issue with new formats. I had to download my new cast in the version 1 syntax as svg-term told me that only version 1 and version 2 syntax are supported.

Watch cast: https://asciinema.org/a/znqFxSzM9CmIJINrmn2IzPX5g Download JSON: https://asciinema.org/a/znqFxSzM9CmIJINrmn2IzPX5g.cast?dl=true

Setup

svg-term: 2.0.3 NodeJS: 8.7.0 NPM: 5.6.0 OS: Ubuntu 17.04

Command

svg-term --in 156579.json --out 156579.svg
svg-term --cast znqFxSzM9CmIJINrmn2IzPX5g --out 156579.svg

Issue

The terminal and sometimes my whole machine is freezing - there is no way to cancle it using CTRL+C. No output is being processed.

marionebl commented 6 years ago

Thanks for reporting, I'll investigate this over the next days

marionebl commented 6 years ago

Did the first steps to debug this, seems like load-asciicast enters an infinite loop for your asciicast. Will investigate further...

henryruhs commented 6 years ago

Great, it felt like a infinite loop :-) Looking forward to a fix, thank you man.

marionebl commented 6 years ago

Did a quick dirty test setup in svg-term

// svg-term/index.tsx#L81
console.log('load');
const cast = load(json, options.width, typeof options.height === 'number' ? options.height + 1 : undefined);
console.log('load', process.hrtime(start));

logs load and then freezes the process.

bunopus commented 6 years ago

Looks like it happens with the all new casts :-(

UPD: it's not true, not all casts affected

marionebl commented 6 years ago

@bunopus That’s not what I experience in daily usage. Could you provide the version of your asciinema cli and links to affected uploaded casts?

bunopus commented 6 years ago

@marionebl it's very strange

asciinema --version asciinema 1.4.0

I have two casts with almost the same content, but one is working, second - not. https://asciinema.org/a/eUnQPgWgKFVl4WUqinKbX7Qze - not working, svg-term-cli freezes https://asciinema.org/a/D3qhyP1ORhqwL3yllRnnzHIbN - almost the same content - working

🤔

marionebl commented 6 years ago

Spent some more time on this. load-asciicast indeed does not enter an infinite loop, it just gets very very slow for certain casts:

cast width height size render time
156787 208 58 29K 145s
156838 112 32 28K 13s
156579 155 43 59K > 300s

What jumped at me is the big dimensions. Forcing down the screen buffer size leads to notable speed increases:

cast width height size render time
156787 80 25 29K 5s
156838 80 25 28K 5s
156579 80 25 59K 11s

I'll create an issue with asciinema about this. For the time being you can force the screen buffer down via svg-term-cli:

svg-term --cast eUnQPgWgKFVl4WUqinKbX7Qze --out 156787.svg --width=80 --height=25
svg-term --cast znqFxSzM9CmIJINrmn2IzPX5g --out 156579.svg --width=120 --height=25