Comments (5)
@bitspittle friendly poke in case your email settings are still swallowing issues ^^
from kotter.
Thanks for the poke! I did indeed miss it, and you are welcome to poke like this anytime I don't respond within 48 hours.
I probably won't be able to take a close look at this until after my talk on June 7 (well and a few days after, which I'll be spending with friends in the Bay Area), but my intention is to prioritize after that. Worst case there's actually a threading issue in core Kotter itself, which would be worth understanding.
I do appreciate you bringing this up; I won't push out 1.1.3 until we either fix this or understand it better.
from kotter.
Just an FYI, finally back from my talk and getting back into working on stuff again. Will probably be busy today and tomorrow but plan on looking into this flaky issue this week. Thanks for your patience!
from kotter.
I am able to repro this issue locally. Coincidentally enough, it may be related to the same bug opened by another user around this same time, see also: #116
Hopefully we can figure things out tomorrow. It sure seems like occasionally the keyboard input flow from the previous section doesn't shut down early enough and therefore the next section tries to start up and therefore briefly sees some of its keys getting swallowed.
"Good news" is that this is the sort of thing that in practice would only happen at the speeds of a computer running tests in a tight loop; it would not be expected for any user to notice this themselves (and even if they somehow did, it would be a single character missed at the beginning of what they were typing, which would be easy to retype)
from kotter.
Been a week since my last reply, but I got hit with a bunch of Kobweb stuff, sorry for yet another delay! Finally had some time to dig today.
So looking into this, this is really tricky. The issue is fundamentally dealing with subhuman speeds and coroutine timing. Basically when you call input
we do two things:
- create a Kotlin flow that read bytes from the terminal and convert them to Kotter
Key
instances. This flow is tied to the session lifecycle. - launch a Kotlin coroutine job that collects input
Key
events and updates a bunch of state that ends up in the final output that you see rendered on the screen, e.g. this is where cursor presses, the ENTER key, and etc. are handled. This work is tied to the section lifecycle.
With the flake you are seeing, what's happening is:
- You start the first section, which spins up the "byte to
Key
" flow and shortly after launches the "processKey
" job. - Eventually, the first section exits. The "byte to
Key
" flow is left alive while the "processKey
" job is cancelled. - You run the second section, which launches a second "process
Key
" job. During this time, you immediately start sending keypresses. - The "byte to
Key
" flow handles these key presses, converting them toKey
instances and sending them off. However... - The "process
Key
" job is not ready yet, so some of those initialKey
events are dropped in that brief window.
I'm still hoping to fix this in a clean way, but so far my efforts have all failed.
I tried tying the "byte to Key
" flow to the section lifecycle instead of the session lifecycle, but it's not easy -- it's tricky to cancel and then restart the flow. Meanwhile, tying the "process Key
" job to the session lifecycle caused at least one of my other input tests to hang. Neat.
If you want a temporary fix, you can do something like this:
onInputEntered {
signal()
userInput = input
}
+ delay(16) // Give Kotter some time to set up `input` machinery
callback()
from kotter.
Related Issues (20)
- Higher level API for building console applications HOT 1
- Section created as extension function does not update when livevar changes HOT 1
- can't write to last row of terminal HOT 1
- onKeyPressed doesn't listen for modified (e.g. ctrl-u, alt-a, etc.) characters HOT 1
- Windows Virtual Terminal Incorrectly Sizes Border HOT 7
- Request for Information on Sidebar's creation Using Off-Screen Api. HOT 3
- Add support for row-span / col-span in grid HOT 1
- Opening two session after another results in undefined behaviour of user input HOT 9
- Testing of extension methods HOT 25
- terminal.assertMatches not behaving as expected when testing input HOT 1
- Strange behaviour with key presses after using onKeyPressed or runUntilKeyPressed HOT 1
- Can't use Kotter without virtual terminal HOT 18
- Kotter is missing my native target
- Windows flickers if the content being redrawn is larger than the entire screen HOT 2
- K/N repaints duplicate lines if any particular line is too long horizontally HOT 2
- Add a test for Terminal#width HOT 1
- Windows + Kotlin/Native: Repaint issues reported (on legacy OS versions?) HOT 2
- K/N: Arithmetic Exception HOT 13
- Allow configuring fonts if possible
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kotter.