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

Javascript Fixes for GNOME shell 42 #134

Merged
merged 2 commits into from
Jul 12, 2022
Merged

Javascript Fixes for GNOME shell 42 #134

merged 2 commits into from
Jul 12, 2022

Conversation

mwilck
Copy link
Collaborator

@mwilck mwilck commented Mar 25, 2022

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.

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.
@mwilck
Copy link
Collaborator Author

mwilck commented Mar 25, 2022

Just tested with GNOME 34, seems to work.

@sthesing
Copy link

sthesing commented Apr 7, 2022

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
Copy link

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
Copy link

puyoxyz commented Apr 8, 2022

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
Copy link

Coda-Coda commented Apr 12, 2022

Hi @mwilck, apparently, as mentioned here #135 (comment) 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: Coda-Coda@ab53846 if you feel like it. 🙂

@mwilck
Copy link
Collaborator Author

mwilck commented Apr 12, 2022

@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
Copy link

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 🙂.

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: mwilck#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
Copy link

Thanks working well in Gnome 42 in Ubuntu 22.04

@joaociocca
Copy link

any idea if/when this is getting merged?

@orangethunder
Copy link

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
Copy link

Coda-Coda commented May 9, 2022

@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
Copy link
Collaborator Author

mwilck commented May 10, 2022

@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
Copy link

@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
Copy link

vijay-prema commented May 11, 2022

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
Copy link

@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
Copy link
Collaborator Author

mwilck commented May 12, 2022

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

@DmitryBurstein
Copy link

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

@mwilck
Copy link
Collaborator Author

mwilck commented May 13, 2022

@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
Copy link

DmitryBurstein commented May 13, 2022

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
Copy link

@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
Copy link

@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
Copy link

Coda-Coda commented May 22, 2022

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
Copy link

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

@mwilck
Copy link
Collaborator Author

mwilck commented Jun 10, 2022

I don't see this message here.

@real-or-random
Copy link

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
Copy link
Owner

p-e-w commented Jun 25, 2022

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
Copy link

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
Copy link

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

@mwilck
Copy link
Collaborator Author

mwilck commented Jun 27, 2022

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
Copy link
Owner

p-e-w commented Jul 9, 2022

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
Copy link

andersk commented Jul 9, 2022

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.

function getShellVersion(str) {
let versionParts = str.split(".");
let versionNumber = 0;
if (versionParts.length === 2) {
// GNOME 40 and newer versioning scheme
// https://discourse.gnome.org/t/new-gnome-versioning-scheme/4235
// must be > 3.x.y with x <= 38
// 40.alpha -> 33997
// 41.beta -> 34098
// 41.rc -> 34099
// 41.0 -> 34100
// 40.1 -> 34001
let testReleases = new Map([["alpha", -3], ["beta", -2], ["rc", -1]]);
let minor = testReleases.get(versionParts[1]);
let major = Number(versionParts[0]);
if (typeof minor === "undefined")
minor = Number(versionParts[1]);
if (major >= 40)
versionNumber = 30000 + major * 100 + minor;
} else if (versionParts.length === 3 && versionParts[0] === "3") {
versionNumber = versionParts.map(Number).reduce(function(previousValue, currentValue) {
return 100 * previousValue + currentValue;
});
};
if (versionNumber === 0) {
log("Unsupported GNOME Shell version '" + str + "'");
return 0;
}
return versionNumber;
}

@mwilck
Copy link
Collaborator Author

mwilck commented Jul 11, 2022

Hm, did they change their versioning scheme again?

@mwilck
Copy link
Collaborator Author

mwilck commented Jul 11, 2022

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.

Recently GNOME shell has started releasing 3-digit versions again,
like 42.3.1. Let's assume for now that these are bug fix versions
which don't affect the extension API, and simply ignore the last
digit.
@mwilck
Copy link
Collaborator Author

mwilck commented Jul 11, 2022

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

@markonius
Copy link

markonius commented Jul 11, 2022

I can confirm it works. Thank you!

@real-or-random
Copy link

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

@mwilck mwilck merged commit 1180568 into p-e-w:master Jul 12, 2022
@joaociocca
Copy link

joaociocca commented Jul 12, 2022

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
Copy link
Collaborator Author

mwilck commented Jul 13, 2022

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
Copy link

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
Copy link
Collaborator Author

mwilck commented Jul 13, 2022

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

@joaociocca
Copy link

I'm beginning to wonder the same thing.

@joaociocca
Copy link

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
Copy link
Collaborator Author

mwilck commented Jul 14, 2022

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
Copy link

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

@joaociocca
Copy link

joaociocca commented Jul 14, 2022

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

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.