SerenityOS / serenity

The Serenity Operating System 🐞
https://serenityos.org
BSD 2-Clause "Simplified" License
30.56k stars 3.19k forks source link

LibLine: Use relative positioning instead of relying on DSR #3637

Open awesomekling opened 4 years ago

awesomekling commented 4 years ago

I frequently see the shell glitch out and lose track of where the cursor is, or how big the window is, etc.

It would be a much better design to stop spamming the terminal with DSR's and instead keeping track of where the cursor is, and just doing relative positioning.

alimpfard commented 4 years ago

"spamming" is such a cruel term, a DSR is requested only once at the start of editing, and it's all internal positioning after that

awesomekling commented 4 years ago

Fair enough :) Also of note: If you spawn TelnetServer and log in to the machine (via telnet localhost 8823 on host), the shell hangs in vt_dsr() after executing one command.)

alimpfard commented 4 years ago

Odd, I don't see this hang in vt_dsr(). I do however see a hang where the shell is waiting for the spawned child to exit:

0xc011f7d3  Kernel::Processor::switch_context(Kernel::Thread*&, Kernel::Thread*&) +181
0xc0166cc3  Kernel::Scheduler::context_switch(Kernel::Thread*) +181
0xc0167ecc  Kernel::Scheduler::pick_next() +1952
0xc0167ffa  Kernel::Scheduler::yield() +160
0xc0183670  Kernel::Thread::yield_without_holding_big_lock() +36
0xc01c7c18  Kernel::Thread::BlockResult Kernel::Thread::block<Kernel::Thread::SelectBlocker, AK::Vector<int, 64ul>&, AK::Vector<int, 64ul>&, AK::Vector<int, 64ul>&>(timespec*, AK::Vector<int, 64ul>&, AK::Vector<int, 64ul>&, AK::Vector<int, 64ul>&) +444
0xc0178c3f  Kernel::Process::sys$select(Kernel::Syscall::SC_select_params const*) +765
0xc016a10d  syscall_handler +1339
0xc0169b43  syscall_asm_entry +49
0x0809f20a  select +57
0x08073fb9  Core::EventLoop::wait_for_event(Core::EventLoop::WaitMode) +597
0x0807432b  Core::EventLoop::pump(Core::EventLoop::WaitMode) +23
0x080745c7  Core::EventLoop::exec() +43
0x08068a98  Shell::block_on_job(AK::RefPtr<Job>) +270
0x0806ea07  Shell::run_commands(AK::Vector<AST::Command, 0ul>&) +363
0x08055ee3  AST::Execute::for_each_entry(AK::RefPtr<Shell>, AK::Function<AK::IterationDecision (AK::NonnullRefPtr<AST::Value>)>) +1651
0x08056043  AST::Execute::run(AK::RefPtr<Shell>) +189
0x08068f8f  Shell::run_command(AK::StringView const&) +309
0x0806a692  Shell::read_single_line() +330
0x0806a707  Shell::custom_event(Core::CustomEvent&) +29
0x0807be7c  Core::Object::dispatch_event(Core::Event&, Core::Object*) +74
0x08074448  Core::EventLoop::pump(Core::EventLoop::WaitMode) +308
0x080745c7  Core::EventLoop::exec() +43
0x08048ca2  main +2234
0x080491ce  _start +94

which is another issue in and of itself

alimpfard commented 4 years ago

The hang with TelnetServer is very weird to me, here's a few things I've seen: