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

Race condition for shown state in TouchBar #1

Closed
Dunedan opened this issue May 29, 2017 · 8 comments
Closed

Race condition for shown state in TouchBar #1

Dunedan opened this issue May 29, 2017 · 8 comments

Comments

@Dunedan
Copy link

Dunedan commented May 29, 2017

As already mentioned in Dunedan/mbp-2016-linux#5 (comment) I noticed a race condition in appletb, causing it to show the wrong keys in the TouchBar. I just want to ensure this issue is still on the radar.

As it happens during regular use it's quite enjoying, because the TouchBar suddenly shows the wrong state. E.g. with fnmode = 2 pressing fn should get me from function keys displayed to special keys displayed. Once that bug occurs the special keys stay displayed on the TouchBar even if no key is pressed anymore. Only pressing fn a few times brings it back in such a case. That correlates with the TouchBar sometimes being unresponsive in such cases.

Aside from happening during regular usage it's also possible to force this issue by frequent key presses (e.g. fn and left ctrl together). Forcing the issue can be a bit tricky, but I'm able to reliably reproduce it.

My best guess is that it's somehow a race condition between the state the TouchBar currently is in and the state it should be in causing one command to change the state not being submitted to the TouchBar.

@roadrunner2
Copy link
Owner

Thanks for opening this here. I had tested frequent fn-key-presses (as fast as I could) originally, and I tried to reproduce this recently, even playing with adding extra delays, but could not. However, a couple days ago I started noticing that every now and then there is an error trying to send the usb control command - can you check your kernel logs (dmesg)? In my case I get an EPIPE (the mode varies between 1 and 2):

appletb: Failed to set touchbar mode to 1 (-32)

Can you see if you are getting similar (or other) errors when things get stuck?

@Dunedan
Copy link
Author

Dunedan commented May 30, 2017

Yes, as it turns out I actually have dozens of these messages.

@roadrunner2
Copy link
Owner

Investigating some more, the EPIPE's are coming from the iBridge device itself (urb status). Furthermore they appear to be related to "switching" between the interfaces: they most consistently show up when sending a control message to interface 2 (used for mode switching) after having sent one to interface 3 (used for dimming and display off).

I'll push some mitigations shortly.

@roadrunner2
Copy link
Owner

I've pushed some updates that reduce the chance of this happening, as well as retry when it does, but it's far from perfect - I still don't have a reliable way handle the EPIPE's. But hopefully this make most of your errors go away.

@Dunedan
Copy link
Author

Dunedan commented May 30, 2017

Still getting the EPIPE's, but haven't being able to get the TouchBar in such an odd state again after your changes. 👍

@roadrunner2
Copy link
Owner

Good to hear it hear it mostly resolves the issues you've been seeing. I'm going to leave this open, however, since the underlying issue (-EPIPE) is not fixed.

@Dunedan
Copy link
Author

Dunedan commented Nov 30, 2018

I haven't seen such -EPIPE errors for a long time. Is that perhaps solved and we can close this issue?

@roadrunner2
Copy link
Owner

Yeah, this appears to be fixed. Thanks for verifying and following up. Closing.

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

No branches or pull requests

2 participants