p-e-w / argos

Create GNOME Shell extensions in seconds
https://extensions.gnome.org/extension/1176/argos/
1.66k stars 112 forks source link

Javascript Fixes for GNOME shell 42 #134

Closed mwilck closed 1 year ago

mwilck commented 2 years ago

Convert ArgosButton and ArgosLineView to GObject.registerClass().

Unfortunately, this time it seems that we can't maintain backward compatibility. For reasons I can't explain, until GNOME 41 the "complex" classes ArgosButton and ArgosLineView could still be defined using Lang.Class(), therefore we could get away with the simplistic makeSimpleClass() trick to define classes differently for different GNOME shell versions. Now this doesn't work any more, classes with multiple methods can't be converted between Lang.Class() and GObject.registerClass() syntax without complex text procesing.

This fixes errors like this:

Mar 25 18:11:49 apollon.suse.de gnome-shell[15049]: JS ERROR: Extension argos@pew.worldwidemann.com: TypeError: Object 0x284558126958 is not a subclass of GObject_Objec>
                                                    _construct@resource:///org/gnome/gjs/modules/script/_legacy.js:536:31
                                                    wrapper@resource:///org/gnome/gjs/modules/script/_legacy.js:83:27
                                                    newClass@resource:///org/gnome/gjs/modules/script/_legacy.js:115:21
                                                    Class@resource:///org/gnome/gjs/modules/script/_legacy.js:66:16
                                                    @/home/mwilck/.local/share/gnome-shell/extensions/argos@pew.worldwidemann.com/button.js:24:19
                                                    @/home/mwilck/.local/share/gnome-shell/extensions/argos@pew.worldwidemann.com/extension.js:18:21

I've removed GNOME shell < 3.34 from the compatibility list. GObject.registerClass() should be available in 3.34. So far I have only tested this with GNOME shell 42.

Testing with other GNOME shell versions (34 - 41) would be appreciated.

mwilck commented 2 years ago

Just tested with GNOME 34, seems to work.

sthesing commented 2 years ago

I tested #134 on the following systems and gnome-shell versions:

gnome-shell --version OS Status
3.36.9 Ubuntu 20.04 LTS works
40.5 Ubuntu 21.10 works
41.5 Arch works
42 Arch works
42 Debian Testing works

Thanks, @mwilck!

JordanViknar commented 2 years ago

Just tested it on my Arch Linux system : it works perfectly ! Thank you for this amazing work, I can now use once again the extension I had made for my headphones.

puyoxyz commented 2 years ago

Before this, my Argos script used to be to the left of the clock, but now it's to the right of the clock image

Otherwise, works great!

edit: and now it's back on the left of the clock again?

Coda-Coda commented 2 years ago

Hi @mwilck, apparently, as mentioned here https://github.com/p-e-w/argos/issues/135#issuecomment-1096101625 this pull request does not populate dropdown menus. Before I became aware of this pull request I made my own branch to support GNOME 42 (which does populate dropdown menus). I don't intend to create a competing pull request, but feel free to figure out what changes need to be made to this pull request to fix dropdowns based on my changes here: https://github.com/Coda-Coda/argos/commit/ab53846fc92639b826da3e36818e5525701dcc9c if you feel like it. :slightly_smiling_face:

mwilck commented 2 years ago

@Coda-Coda, thanks for the note. I had a look at your branch but the differences are too big for a detailed assessment about the drop-down menu issue. Your branch is not based on current master. You need to rebase before we can go into further detail. In addition, please consider to rebase to my code base here and create a PR against my branch. That might clarify what the cause of @prurigo's issue was.

I'm not concerned about authorship at all, so if your code (on top of current master) works better than mine, I'll just close this PR and let you create one instead.

@prurigro, if you had problems with the version in this PR I'd appreciate if you could describe them here rather than in #135. drop-down menus do work for me with my version, so I'd be grateful for a more detailed description of your issue, possibly with screenshots, and ideally with a small sample program to demonstrate the effect and for me to try. Also, please report whether your program works with current master under GNOME <42.

Coda-Coda commented 2 years ago

I have just tried this pull request and the drop-down menu appears to work fine for me as well - thanks for your efforts @mwilck :slightly_smiling_face:.

The reason my branch diverges from master is that it's based on https://github.com/rammie/argos/tree/gnome-3.36. But just in case it is useful, here is a pull request against your branch with the relevant changes: https://github.com/mwilck/argos/pull/7.

@prurIgro if you have the time, please do describe any issues you had with dropdowns here - I was not able to reproduce your issue.

vijay-prema commented 2 years ago

Thanks working well in Gnome 42 in Ubuntu 22.04

joaociocca commented 2 years ago

any idea if/when this is getting merged?

orangethunder commented 2 years ago

Running this on Gnome 42 with Ubuntu 22.04. It seems to make my UI laggy, with random pauses when doing things like clicking, scrolling with the mouse wheel and even typing. Is anyone else having that issue? I didn't have any issues on Ubuntu 20.04 and 21.10 with a different fork of argos.

Coda-Coda commented 2 years ago

@orangethunder, I've also encountered that freezing issue but have not managed to resolve it yet, turning off extensions completely does seem to stop it. If you figure out how to fix it, please let me know, thanks 🙂

mwilck commented 2 years ago

@Coda-Coda, @orangethunder: is argos the only extension you use? How many argos scripts do you have, how quickly/often do they refresh? Unless this if this happens if and only if argos but no other extension is enabled (iow, doesn't happens with other extensions) I'm sceptical that argos alone would drag down the overall performance of the shell.

I'm trying not to be defensive, but some additional evidence is needed.

Coda-Coda commented 2 years ago

@mwilck I totally agree we need more data to resolve this. My setup right now has argos as the only extension, with one script, being refreshed every 1s. I'm currently trying out running this version of argos (that doesn't fit well with master) but as it is an intermittent issue I'm not sure if that makes a difference or not. As I was typing this message (with argos enabled) there didn't seem to be any freezing issues). Who knows 🤷‍♂️

I'll try report back here in the future if I have the time.

vijay-prema commented 2 years ago

I was experiencing instability, hangs and lag in the UI. Like the activity overview animation and even just dragging windows around was suddenly so jerky, and sometimes the activity overview would not show any windows suddenly. It turned out to be another extension, not Argos, I think either Unite or "Gnome 4x UI improvements" or something. It was hard to pinpoint exactly which. But it seems to be working perfectly now. It could also be a conflict between extensions maybe, so disabling either extension will fix it who knows. I thought argos is a relatively simple extension that does not modify the Gnome system much.

orangethunder commented 2 years ago

@mwilck, argos was the only user-installed extension I had active at the time. I have 3 tasks running every 5 seconds. Since this is so hard to troubleshoot (and it's working for other users) I decided to code up a simple alternative for my needs instead.

mwilck commented 2 years ago

@orangethunder: thanks for the update. If anyone has ideas how this could be debugged, please speak up.

DmitryBurstein commented 2 years ago

I've just tried it on Fedora 36 with Gnome 42, and got the following error: "Utilities.getActor is not a function"

mwilck commented 2 years ago

@DmitryBurstein, can you paste an entire log? What exactly is the GNOME shell version iin F36? Can you confirm that you actually used the code from this PR?

DmitryBurstein commented 2 years ago

Gnome shell version is 42.0. Yes, I have manually updated all 3 files from this PR in the .local subtree. The appropriate log lines are: gnome-shell[11882]: Some code accessed the property 'ArgosMenuItem' on the module 'menuitem'. That property was defined with 'let' or 'const' inside the module. This was previously supported, but is not correct according to the ES6 standard. Any symbols to be exported from a module must be defined with 'var'. The property access will work as previously for the time being, but please fix your code anyway. gnome-shell[11882]: JS ERROR: Extension argos@pew.worldwidemann.com: TypeError: Utilities.getActor is not a function _init@/home/dima/.local/share/gnome-shell/extensions/argos@pew.worldwidemann.com/button.js:39:15 ArgosButton@/home/dima/.local/share/gnome-shell/extensions/argos@pew.worldwidemann.com/button.js:29:1 addButtons@/home/dima/.local/share/gnome-shell/extensions/argos@pew.worldwidemann.com/extension.js:111:18 enable@/home/dima/.local/share/gnome-shell/extensions/argos@pew.worldwidemann.com/extension.js:62:3

orangethunder commented 2 years ago

@mwilck, FWIW, I switched back to Xorg from Wayland, and now have no performance issues with this PR. I also noticed that Wayland had some stutters even without the extensions, but it was definitely worse when the extension was enabled. I don't really know what it means, but it could be taken as evidence that the issue is not with the PR itself.

marianrh commented 2 years ago

@mwilck To add a few data points: I've been using this branch on Ubuntu 22.04 on about 10 desktops and laptops since 22.04's release. I haven't encountered any problems on any of those machines, and other users haven't complained either. We're using both Wayland and Xorg. So to me this looks good to be merged.

Coda-Coda commented 2 years ago

To add to my earlier comment, I've been using the code of my fork for the last while and since switching to it have not had the issue with the lagging. However, I am not fully convinced this correlation is necessarily a causal link. What I'll do next is try the code of this pull request again to see if the issue re-emerges. I am using Wayland.

DmitryBurstein commented 2 years ago

Gnome version on F36 got bumped to 42.2, but the error message remains the same: "Utilities.getActor is not a function"

mwilck commented 2 years ago

I don't see this message here.

real-or-random commented 2 years ago

Since this seems to be working properly for everyone except @DmitryBurstein , I suggest to merge it, and then care about the getActor thing separately.

p-e-w commented 2 years ago

Should this be merged into a separate gnome-42 branch maybe? Since EGO has rejected the most recent Argos update, currently the only way to install is by cloning this repository, and many users aren't on GNOME 42 yet. Therefore, it might make sense to have separate branches so people can easily install the version that's appropriate for them. I always wanted to avoid that but with the problems we are facing (no backward compatibility + no EGO) it looks like the only reasonable option.

real-or-random commented 2 years ago

Makes sense but then maybe better create a separate gnome-41 branch and merge this to master. Otherwise some kind of rule is needed to define what master should reflect.

DmitryBurstein commented 2 years ago

I installed the fork @Coda-Coda mentioned and it's working perfectly for me.

mwilck commented 2 years ago

I agree with @real-or-random that the master branch should support the latest stable GNOME version. This is what users would expect, IMO.

p-e-w commented 1 year ago

Yes, that sounds reasonable. @mwilck, feel free to merge this whenever you think it's ready, and arrange the branches however you think is best.

andersk commented 1 year ago

This was working for me in GNOME Shell 42.0 through 42.3, but with GNOME Shell 42.3.1, I’m now getting

Unsupported GNOME Shell version '42.3.1'
JS ERROR: Extension argos@pew.worldwidemann.com: TypeError: Object 0x27e71fb77820 is not a subclass of GObject_Object, it's a Object

because getShellVersion incorrectly expects versionParts.length === 2 for GNOME 40 and newer.

https://github.com/p-e-w/argos/blob/691cdcf271097200ed354676f49e64ba407045e8/argos%40pew.worldwidemann.com/utilities.js#L281-L316

mwilck commented 1 year ago

Hm, did they change their versioning scheme again?

mwilck commented 1 year ago

because getShellVersion incorrectly expects versionParts.length === 2 for GNOME 40 and newer.

That expectation was based on the discourse post. Apparently they recently started to add another digit to their versions.

Never trust anything the GNOME devs publish... well this worked for almost 2 years, which can be considered a success, I suppose.

mwilck commented 1 year ago

I've pushed a tentative fix. @andersk, please check it out.

markonius commented 1 year ago

I can confirm it works. Thank you!

real-or-random commented 1 year ago

I can also confirm that it the new commit works on 42.3.1.

joaociocca commented 1 year ago

just wondering if I need to do something else... my previous script still won't show there, and the top example from README.md only shows the "top" text on the bar, but nothing happens on hover and/or clicking it... image

mwilck commented 1 year ago

The "top" script works for me. Could you share your logs? You might also want to put some add some messages in the extension to try isolating the problem.

joaociocca commented 1 year ago

huh...

jul 13 20:52:54 jciocca-crtirt gnome-shell[203277]: JS ERROR: Error: Tried to construct an object without a GType; are you using GObject.registerClass() when inheriting from a GObject type?
                                                    ArgosMenuItem@/home/jciocca/.local/share/gnome-shell/extensions/argos@pew.worldwidemann.com/menuitem.js:25:5
                                                    _processOutput@/home/jciocca/.local/share/gnome-shell/extensions/argos@pew.worldwidemann.com/button.js:200:20
                                                    wrapper@resource:///org/gnome/gjs/modules/script/_legacy.js:82:27
                                                    _update/<@/home/jciocca/.local/share/gnome-shell/extensions/argos@pew.worldwidemann.com/button.js:95:16
                                                    spawnWithCallback/<@/home/jciocca/.local/share/gnome-shell/extensions/argos@pew.worldwidemann.com/utilities.js:268:7
                                                    readStream/<@/home/jciocca/.local/share/gnome-shell/extensions/argos@pew.worldwidemann.com/utilities.js:280:7
mwilck commented 1 year ago

Is it really the code from this PR you're running?

joaociocca commented 1 year ago

I'm beginning to wonder the same thing.

joaociocca commented 1 year ago

I must be doing something horrifically wrong. I tried using the install from GNOME shell ext website, I tried cloning the repo and symlink the folder... ok, copying the folder worked, top is showing nicely when I click it, but my timezones script... still nothing.

If I edit it, change something and save, I see the message of reload on Argos' area. But that's it, and it just blinks ultra fast out of view.

image

mwilck commented 1 year ago

copying the folder worked, top is showing nicely when I click it

good. Could you perhaps just attach or paste your script, so that I don't have to type it from your screenshot?

real-or-random commented 1 year ago

@joaociocca Argos tries to parse the trailing < as pango markup. Try < | useMarkup=false as the last output, see the README.

joaociocca commented 1 year ago

@mwilck sorry about that! @real-or-random that worked! thank you very much <3 image (I changed UTC for BR heh)