RangeError: too many function arguments, getFileContents@handlers.js:54:19
Closed this issue · 4 comments
I'm not sure which version of Unite I previously had, it was several versions behind but it worked great until recently when Gnome upgrades were applied and Unite v80 was installed/upgraded. This was shown in the Extensions list:
and this was in the system log:
gnome-shell[2585]:
Extension unite@hardpixel.eu:
RangeError: too many function arguments
Stack trace:
getFileContents@file:///home/scar/.local/share/gnome-shell/extensions/unite@hardpixel.eu/handlers.js:54:19
resetGtkStyles/<@file:///home/scar/.local/share/gnome-shell/extensions/unite@hardpixel.eu/handlers.js:72:32
resetGtkStyles@file:///home/scar/.local/share/gnome-shell/extensions/unite@hardpixel.eu/handlers.js:70:16
enable@file:///home/scar/.local/share/gnome-shell/extensions/unite@hardpixel.eu/extension.js:16:14
_callExtensionEnable@resource:///org/gnome/shell/ui/extensionSystem.js:266:38
loadExtension@resource:///org/gnome/shell/ui/extensionSystem.js:478:32
async*_loadExtensions@resource:///org/gnome/shell/ui/extensionSystem.js:786:24
async*_enableAllExtensions@resource:///org/gnome/shell/ui/extensionSystem.js:792:48
_sessionUpdated@resource:///org/gnome/shell/ui/extensionSystem.js:827:20
async*init@resource:///org/gnome/shell/ui/extensionSystem.js:76:14
_initializeUI@resource:///org/gnome/shell/ui/main.js:303:22
start@resource:///org/gnome/shell/ui/main.js:175:11
@resource:///org/gnome/shell/ui/init.js:12:47
@resource:///org/gnome/shell/ui/init.js:21:20
To Reproduce
Steps to reproduce the behavior:
- wget https://github.com/hardpixel/unite-shell/releases/download/v80/unite-v80.zip
- gnome-extensions install unite-v80.zip
Environment:
- OS: Debian 12
- GNOME Shell version 46.4
- Unite version 80
I checked getFileContents@handlers.js:54:19 and rewrote that to:
51 │ function getFileContents(path) {
52 │ if (fileExists(path)) {
53 │ const contents = GLib.file_get_contents(path);
**54 │ const decoder = new TextDecoder('utf-8');
++55 │ return decoder.decode(contents[1]);
56 │ } else {
57 │ return '';
58 │ }
59 │ }
Now extension works again for me 🎉
According to experts, TextDecoder
is more robust and offers a better approach for converting large buffers or arrays to strings, and is a more memory-efficient way to handle large data. 🤷💫
Thanks for the detailed report @scarlion1! Would you like to make a PR for this?
Yeah, sir! I could. I've only done that once before tho 😅 So it will take a bit longer to remember the process and setup my access keys, etc. again. I'm also pretty busy lately with several deadlines for various things looming, so might not get it done immediately. Hopefully this weekend could find time or next weekend at the latest. Do you know why the RangeError happens? what's getFileContents() used for? er, I mean i guess it gets the contents of a file 🙄 but what's Unite looking at? I guess mine is too big? 😛
No worries for the PR, I can make the required changes.
The RangeError is because your file is, as you correctly guessed, too big. To remove decorations from CSD applications the extension uses CSS styles. These styles should be included in:
~/.config/gtk-3.0/gtk.css
for GTK3 apps
~/.config/gtk-4.0/gtk.css
for GTK4 apps
When enabled, the extension gets the contents of those files, prepends the extension code and re-writes the file.
/* UNITE windowDecorations */
@import url('/usr/share/gnome-shell/extensions/unite@hardpixel.eu/styles/gtk3/buttons-left/maximized.css');
/* windowDecorations UNITE */
/* This is the existing file content */
header {
color: red;
}
When disabled, it gets the contents again, removes the extension code and re-writes the file.
/* This is the existing file content */
header {
color: red;
}
This is done so the extension does not delete your GTK theme customization. You can review the code here. Also you can check the gtk.css
files and enable/disable the extension to observe the changes it makes.
Cool thanks for the pointers! Yeah i did some modifications a while ago to both 3 and 4's gtk.css... with Unite enabled, my gtk-30.css is 526,074 bytes! A huge portion has been converted to unicode showing up in vim like <U+0083>Ã<U+0083>Â<U+0082>Ã<U+0082>Â<U+0082>Ã<U+0083>Â<U+0083>Ã<U+0082>Â<U+0082>Ã<U+0083>Â<U+0082>Ã<U+0082>Â<U+0083>
break, no break, break, no break over and over wtf... let me turn Unite off n see... uhhh now it's 525,895 bytes still let me look at this in Geany.... huh it's all within a comment, let me just delete all this garbage... and there we go back to 1,609 bytes much better idk wtf happened there.
Some other quick questions I got lmk you'd rather me put them in separate issues, but is there a way to change the size of the min,max,close buttons? They do not match the size of the indicator icons and it's driving me nuts!
er, well, I would like to size them up until the close button matches the indicators, which are currently set to 25px thru Just Perfection add-on...
and also this seems to cause a sh*t ton of warnings from mutter-x11-frames
, such as:
GtkHeaderBar 0x55e1c326d690 (headerbar) reported min height -172, but sizes must be >= 0�
MetaFrameHeader 0x55e1c328f570 (widget) reported min height -172, but sizes must be >= 0�
MetaFrameHeader 0x55e1c328f570 reported baselines of minimum -180 and natural -180, but sizes of minimum 0 and natural 0. Baselines must be inside the widget size.
[...]<these 3 lines repeat over and over, then end for a few moments with:>
GtkWindowControls 0x55e1c3b7dca0 (windowcontrols) reported min width -110, but sizes must be >= 0
Is that maybe from my gtk.css customizations or what?
Thanks