AccessKit / accesskit

Accessibility infrastructure for UI toolkits
https://accesskit.dev
BSD 3-Clause "New" or "Revised" License
1.04k stars 51 forks source link

AT-SPI2: Activate tree updates only if org.a11y.Status's IsEnabled is true #314

Closed tronical closed 8 months ago

tronical commented 10 months ago

In Slint we've had the situation that on Linux machines where there's no screen reader running, access kit would still send tree updates on the a11y bus. We've seen this in https://github.com/slint-ui/slint/issues/3867 as well as in https://github.com/slint-ui/slint/pull/3046#issuecomment-1623831111 .

Based on my reading of https://www.freedesktop.org/wiki/Accessibility/AT-SPI2/ as well as peeking at the Qt Sources as well as Orca it seems like to me that AccessKit's AT-SPI2 adapter should consider itself active only if org.a11y.Status.IsEnabled in the path /org/a11y/bus on org.a11y.Bus on the session(!) bus is true, and of course watch the property for any changes.

Would this behaviour make sense to implement?

mwcampbell commented 10 months ago

Do GTK and Qt check this status just once on startup, or can they connect to the bus, watch for the status to change, and initialize accessibility if, say, Orca is started after the application? The latter would be ideal, but we should at least aim for parity with existing toolkits.

tronical commented 10 months ago

Qt checks this once on startup and then is supposed to watch for changes, but that isn't implemented. I can't find out where Gtk would check for this property, but the spec suggests that this is what toolkits should do.

Okay, but your response sounds like you agree that access kit should implement the spec'ed behaviour. That would solve the issue one of our users reported (paying a price for tree updates despite no a11y tech being in use), while still providing full accessibility support when needed.

I might give it a try when I'm back - I'll be offline for a few weeks. But anyone please feel free to beat me to it ;-)

DataTriny commented 10 months ago

Hello, GTK3 may have used this property in the past, but GTK4 surely doesn't care.

By the way I have a VM running Ubuntu 23.10 on which the AT-SPI daemon is started and IsEnabled always return true even when no AT appear to be currently running. I think the bus launcher accepts an argument to force this property to true, and I wouldn't be surprised if some distributions use it if accessibility is configured to start with the system.

With that being said, this is on my TODO list. I didn't implement it initially because I wasn't sure where we would monitor for the property change signal, it's still a bit blur currently to be honest.

If we want to do it right, we should also monitor the session bus for name owner changed events for org.a11y.Bus, otherwise we risk crashing the application if the accessibility bus goes down. We also want this process to be centralized, keeping track of all the adapters so that we can activate/deactivate them from a single place.

I don't think it's going to be so easy, I can't really spend time on this before mid next week anyway.

DataTriny commented 10 months ago

Woah, I overthought this one!

I think I can handle this in a reasonably short time.

DataTriny commented 9 months ago

Status update

Tackling this issue is taking me way longer than I anticipated... I wasted time trying multiple approaches and I am not really used to writing async Rust, but I think I finally just solved the last major blocker. I still have a couple of tasks to finish, but the PR might be ready before this weekend.

tronical commented 8 months ago

Thank you for implementing this!