Skip to content
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

osc: add parsing for Kitty desktop notifications (OSC 99) #2126

Closed

Conversation

jcollie
Copy link
Member

@jcollie jcollie commented Aug 20, 2024

Adds the ability to parse Kitty desktop notifications but doesn't do anything with them yet.

Copy link
Contributor

@mitchellh mitchellh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. One comment specific to this but see some of the changes I made to the Kitty Color Protocol parser.

Additionally, I'm starting to think the Kitty-specific structs should PROBABLY move to src/terminal/kitty/ since that's where we put everything else. Including the color protocol. I'll make that move later.

That'll make it easier to read these structs (less indentation) and easier to isolate tests for them for any logic we might have.

@jcollie
Copy link
Member Author

jcollie commented Aug 21, 2024

Additionally, I'm starting to think the Kitty-specific structs should PROBABLY move to src/terminal/kitty/ since that's where we put everything else. Including the color protocol. I'll make that move later.

There are probably lots of cases where splitting things out into individual files makes sense, especially the Kitty stuff. Do you want me to split this out in this PR, or in a follow-up PR?

@mitchellh
Copy link
Contributor

There are probably lots of cases where splitting things out into individual files makes sense, especially the Kitty stuff. Do you want me to split this out in this PR, or in a follow-up PR?

Let me do it in the color one first and then you can follow suit!

@mitchellh
Copy link
Contributor

Okay I just merged #2113. Please take a look there to see some of the tweaks I made. I made small commits so you can see at an individual commit level for me. I'd love to see those same tweaks here because I'm likely to do the same thing otherwise. 😄

@mitchellh
Copy link
Contributor

This has some conflicts with main do you mind rebasing? Sorry and thanks <3

@jcollie jcollie force-pushed the parse-kitty-desktop-notification branch from 89c53e9 to f242ec2 Compare August 25, 2024 03:41
@jcollie
Copy link
Member Author

jcollie commented Aug 25, 2024

This has some conflicts with main do you mind rebasing? Sorry and thanks <3

Done.

Copy link
Contributor

@mitchellh mitchellh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bunch more relatively easy comments. I still haven't deeply studied the format of the protocol to understand some of the decisions here bigger picture.

@jcollie jcollie force-pushed the parse-kitty-desktop-notification branch from 2048f46 to 8505b78 Compare September 12, 2024 21:10
@jcollie
Copy link
Member Author

jcollie commented Sep 12, 2024

Ugh. I realized that I had read the spec wrongly, so I've redone the patch.

@jcollie jcollie force-pushed the parse-kitty-desktop-notification branch from 8505b78 to 37f06ca Compare September 26, 2024 22:37
@jcollie
Copy link
Member Author

jcollie commented Sep 26, 2024

rebased onto current main

@mitchellh
Copy link
Contributor

My main blocker on merging this at the moment is that I'm still chasing down a LOT of crash reports since merging the Kitty Color Protocol PR. I received 5 yesterday (and average about 2 or 3 per day). All in the same place, all deinit of Kitty color protocol. I haven't been able to find the path that leads to it yet, but here's the stack trace:

CleanShot 2024-09-28 at 21 34 25@2x

I want to chase this down first so I can understand what's going on to see if this PR is also susceptible.

@jcollie
Copy link
Member Author

jcollie commented Sep 29, 2024

I added a little bit of debugging to the OSC reset function and created a quick fuzzer for the Kitty color protocol and am unable to reproduce so far.

I am wondering about the command in the OSC parser being initialized as undefined and if there is a situation where that ends up being mistakenly interpreted as a kitty_color_protocol command except that the ArrayList was never properly initialized? I've not been able to detect that actually happening so perhaps that's not it.

@jcollie
Copy link
Member Author

jcollie commented Sep 29, 2024

One other thought, do any of the users that send in reports of these crashes report using TUIs that make use of the Kitty color protocol? The protocol was only released in Kitty 0.36.0 (released Aug 17th) so there can't be that many TUIs that actually use it (outside of Kitty's internal apps).

@mitchellh
Copy link
Contributor

I am wondering about the command in the OSC parser being initialized as undefined and if there is a situation where that ends up being mistakenly interpreted as a kitty_color_protocol command except that the ArrayList was never properly initialized? I've not been able to detect that actually happening so perhaps that's not it.

That's surely the case, but I don't see how that's possible in the current codepaths. It clearly is, so its something I want to figure out.

@jcollie
Copy link
Member Author

jcollie commented Sep 29, 2024

I'm still unable to duplicate this, even using ReleaseFast. Are all the crashes macOS or are some Linux/GTK? Is there something different about the allocator on macOS or linux distros other than NixOS that causes that memory to be initialized/uninitialized in a weird way?

In any case, I cleaned up some of the debugging changes I was making and put them here:

https://github.com/jcollie/ghostty/tree/kcp-defensive-programming

I'm not going to PR it at this point because I know that this just papers over a possibly deeper problem...

@jcollie jcollie closed this by deleting the head repository Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants