简体   繁体   中英

Asynchronous extension breaks GNOME Shell

I made a simple async Extension which periodically count Arch Linux's updates and shows them on the panel.

The extension works fine IF it's enabled with Gnome Shell already running . In any other case (starting Gnome Shell with the extension pre-enabled), it breaks the desktop and goes back to GDM.

My code can be found at: https://github.com/speltriao/Pacman-Update-for-GNOME-Shell/blob/main/pacmancounter@example.com/extension.js

Maybe there is something wrong with the async function? Got the idea from https://www.andyholmes.ca/articles/asynchronous-programming-in-gjs.html

Thanks.

I'd recommend reading through the review guidelines as a start, as well as the extension guides .

In the function countUpdates() you are creating a nested GLib.MainLoop , which when run will block the existing main loop that GNOME Shell is already running (sort of defeats the purpose of asynchronous operations). It's not clear to me how nested main loops work in GJS at all, and I would generally not do that unless it is clear to you.

Additionally, if the asynchronous function fails, the nested main loop is never quit, which will hang GNOME Shell indefinitely. There's a good chance that could cause GNOME Shell to crash during start up.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM