neffo / bing-wallpaper-gnome-extension

GNOME shell extension that syncs your desktop & lock screen wallpaper to Microsoft Bing's Image of the Day.
https://extensions.gnome.org/extension/1262/bing-wallpaper-changer/
GNU General Public License v3.0
299 stars 56 forks source link

[BUG] TypeError: image is null error on newly created user accounts #246

Open pacho2 opened 1 month ago

pacho2 commented 1 month ago

Hello,

I am not sure why extension runs fine on my user account but it doesn't on newly created ones. Maybe some folder (or subfolder) is missing on the newly one, but I am unsure about which one :(

Desktop (please complete the following information):

The following errors are logged:

gnome-shell[1695]: Extension BingWallpaper@ineffable-gmail.com: TypeError: image is null

                                             Stack trace:
                                               _selectImage@file:///usr/share/gnome-shell/extensions/BingWallpaper@ineffable-gmail.com/extension.js:870:17
                                               _setImage@file:///usr/share/gnome-shell/extensions/BingWallpaper@ineffable-gmail.com/extension.js:343:14
                                               _setConnections@file:///usr/share/gnome-shell/extensions/BingWallpaper@ineffable-gmail.com/extension.js:256:14
                                               _init@file:///usr/share/gnome-shell/extensions/BingWallpaper@ineffable-gmail.com/extension.js:205:14
                                               ButtonBox@resource:///org/gnome/shell/ui/panelMenu.js:13:1
                                               PanelMenuButton@resource:///org/gnome/shell/ui/panelMenu.js:99:4
                                               BingWallpaperIndicator@file:///usr/share/gnome-shell/extensions/BingWallpaper@ineffable-gmail.com/extension.js:83:1
                                               enable@file:///usr/share/gnome-shell/extensions/BingWallpaper@ineffable-gmail.com/extension.js:1099:34
                                               _callExtensionEnable@resource:///org/gnome/shell/ui/extensionSystem.js:253:38
                                               loadExtension@resource:///org/gnome/shell/ui/extensionSystem.js:461:32
                                               async*_loadExtensions@resource:///org/gnome/shell/ui/extensionSystem.js:759:24
                                               async*_enableAllExtensions@resource:///org/gnome/shell/ui/extensionSystem.js:765:48
                                               _sessionUpdated@resource:///org/gnome/shell/ui/extensionSystem.js:800:20
                                               async*init@resource:///org/gnome/shell/ui/extensionSystem.js:72:14
                                               _initializeUI@resource:///org/gnome/shell/ui/main.js:303:22
                                               start@resource:///org/gnome/shell/ui/main.js:176:11
                                               @resource:///org/gnome/shell/ui/init.js:12:47
                                               @resource:///org/gnome/shell/ui/init.js:21:20

Thanks for your help

neffo commented 1 month ago

This is the default, can you if your Pictures or Desktop folders are writable?

let userPicturesDir = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_PICTURES);
let userDesktopDir = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DESKTOP);
BingWallpaperDir = (userPicturesDir?userPicturesDir:userDesktopDir) + '/BingWallpaper/';

It's possible your Distro has read-only for one of those?

neffo commented 1 month ago

Are you able to test the version 50 branch?

I've added error notifications: image

pacho2 commented 1 month ago

Sadly the notification is not shown because extension fails to start at login with:

Extension BingWallpaper@ineffable-gmail.com: TypeError: image is null

                                              Stack trace:
                                                _selectImage@file:///usr/share/gnome-shell/extensions/BingWallpaper@ineffable-gmail.com/extension.js:930:17
                                                _setImage@file:///usr/share/gnome-shell/extensions/BingWallpaper@ineffable-gmail.com/extension.js:382:14
                                                _setConnections@file:///usr/share/gnome-shell/extensions/BingWallpaper@ineffable-gmail.com/extension.js:267:14
                                                _init@file:///usr/share/gnome-shell/extensions/BingWallpaper@ineffable-gmail.com/extension.js:211:14
                                                ButtonBox@resource:///org/gnome/shell/ui/panelMenu.js:13:1
                                                PanelMenuButton@resource:///org/gnome/shell/ui/panelMenu.js:99:4
                                                BingWallpaperIndicator@file:///usr/share/gnome-shell/extensions/BingWallpaper@ineffable-gmail.com/extension.js:89:1
                                                enable@file:///usr/share/gnome-shell/extensions/BingWallpaper@ineffable-gmail.com/extension.js:1164:34
                                                _callExtensionEnable@resource:///org/gnome/shell/ui/extensionSystem.js:253:38
                                                loadExtension@resource:///org/gnome/shell/ui/extensionSystem.js:461:32
                                                async*_loadExtensions@resource:///org/gnome/shell/ui/extensionSystem.js:759:24
                                                async*_enableAllExtensions@resource:///org/gnome/shell/ui/extensionSystem.js:765:48
                                                _sessionUpdated@resource:///org/gnome/shell/ui/extensionSystem.js:800:20
                                                async*init@resource:///org/gnome/shell/ui/extensionSystem.js:72:14
                                                _initializeUI@resource:///org/gnome/shell/ui/main.js:303:22
                                                start@resource:///org/gnome/shell/ui/main.js:176:11
                                                @resource:///org/gnome/shell/ui/init.js:12:47
                                                @resource:///org/gnome/shell/ui/init.js:21:20

I have full permissions on my ~/Pictures/ directory, but I don't know why it fails to create the subdir :/

pacho2 commented 1 month ago

But even creating manually the dir, it keeps failing in the same way. I have tried to enable debug from the extension settings, but it is the same error:

Extension BingWallpaper@ineffable-gmail.com: TypeError: image is null

                                              Stack trace:
                                                _selectImage@file:///usr/share/gnome-shell/extensions/BingWallpaper@ineffable-gmail.com/extension.js:930:17
                                                _setImage@file:///usr/share/gnome-shell/extensions/BingWallpaper@ineffable-gmail.com/extension.js:382:14
                                                _setConnections@file:///usr/share/gnome-shell/extensions/BingWallpaper@ineffable-gmail.com/extension.js:267:14
                                                _init@file:///usr/share/gnome-shell/extensions/BingWallpaper@ineffable-gmail.com/extension.js:211:14
                                                ButtonBox@resource:///org/gnome/shell/ui/panelMenu.js:13:1
                                                PanelMenuButton@resource:///org/gnome/shell/ui/panelMenu.js:99:4
                                                BingWallpaperIndicator@file:///usr/share/gnome-shell/extensions/BingWallpaper@ineffable-gmail.com/extension.js:89:1
                                                enable@file:///usr/share/gnome-shell/extensions/BingWallpaper@ineffable-gmail.com/extension.js:1164:34
                                                _callExtensionEnable@resource:///org/gnome/shell/ui/extensionSystem.js:253:38
                                                loadExtension@resource:///org/gnome/shell/ui/extensionSystem.js:461:32
                                                async*_loadExtensions@resource:///org/gnome/shell/ui/extensionSystem.js:759:24
                                                async*_enableAllExtensions@resource:///org/gnome/shell/ui/extensionSystem.js:765:48
                                                _sessionUpdated@resource:///org/gnome/shell/ui/extensionSystem.js:800:20
                                                async*init@resource:///org/gnome/shell/ui/extensionSystem.js:72:14
                                                _initializeUI@resource:///org/gnome/shell/ui/main.js:303:22
                                                start@resource:///org/gnome/shell/ui/main.js:176:11
                                                @resource:///org/gnome/shell/ui/init.js:12:47
                                                @resource:///org/gnome/shell/ui/init.js:21:20
pacho2 commented 1 month ago

Maybe it is failing to download the image? But I cannot see anywhere in the logs where it is trying to fetch it from, and nothing is downloaded to the BingWallpaper folder

neffo commented 1 month ago

This triggering an error in startup possibly. I don't understand how it's triggering an error there but can you comment out the log function call on row 930 in extension.js?

log('_selectImage: ' + this.selected_image + ' = ' + (image && image.urlbase) ? image.urlbase : 'not found');
pacho2 commented 1 month ago

Nice, now it can start and the failure is:

 JS ERROR: TypeError: time.to_unix is not a function
                                              friendly_time_diff@file:///usr/share/gnome-shell/extensions/BingWallpaper@ineffable-gmail.com/utils.js:396:24
                                              _openMenu@file:///usr/share/gnome-shell/extensions/BingWallpaper@ineffable-gmail.com/extension.js:367:30
                                              @resource:///org/gnome/shell/ui/init.js:21:20
Oct 01 09:34:07 gec-pacho gjs[91944]: g_task_return_error: assertion '!task->ever_returned' failed
martywesley commented 1 month ago

I was getting the same "TypeError: image is null" error on my account. I commented out the log call on line 930 as you suggested and it started working for me. So not entirely the same problem as OP reported, but there's clearly a problem with that log line.

JordanViknar commented 3 weeks ago

I can also confirm I've encountered the same error, and the same fix has worked successfully. However, my user account isn't new, so I'm not convinced this is related to that.