MrOtherGuy / fx-autoconfig

Load custom javascript in browser context
Mozilla Public License 2.0
171 stars 10 forks source link

about:home showing "Please reload the page and try again" #54

Closed olivertzeng closed 2 months ago

olivertzeng commented 2 months ago

LibreWolf Firefox 127.0.2-2 Arch Linux AUR librewolf-bin have tried nuking the whole chrome except stuff in /profile and still doesn't work

olivertzeng commented 2 months ago

new page with other extensions work though

MrOtherGuy commented 2 months ago

I'd suggest that you first clear startup cache and then restart Firefox. You can do that from about:support or from the menu items added to menubar > help by fx-autoconfig.

If that doesn't work, then you should probably rename the whole chrome folder and see how that works.

For what it's worth, loading about:home works fine on my system with Firefox 128 and Nightly 130. I have not tested LibreWolf though so it might be an issue on their end.

MrOtherGuy commented 2 months ago

Additionally, chances are that some error is reported to browser console so you should check that as well.

olivertzeng commented 2 months ago

Additionally, chances are that some error is reported to browser console so you should check that as well.

how do i retrieve them?

olivertzeng commented 2 months ago

clearing restart cache didn't work

MrOtherGuy commented 2 months ago

You can open browser console from main menu -> more tools or via Ctrl+Shift+J although I'm not sure if this is OS dependent.

olivertzeng commented 2 months ago

Browser is executing custom scripts via autoconfig boot.sys.mjs:5:9 Could not load userChrome.ag.css: NS_ERROR_FILE_NOT_FOUND userChrome_ag_css.sys.mjs:17:13 Hi mom, I'm loaded! test.uc.js:1:9 Error: @ userChrome_au_css.uc.js:13 tryLoadScriptIntoWindow chrome://userchromejs/content/boot.sys.mjs:192 Caused by: ReferenceError: _ucUtils is not defined

chrome://userscripts/content/userChrome_au_css.uc.js:13 chrome://userscripts/content/userChrome_au_css.uc.js:30 injectClassicScriptIntoGlobal chrome://userchromejs/content/boot.sys.mjs:216 tryLoadScriptIntoWindow chrome://userchromejs/content/boot.sys.mjs:189 onDOMContent chrome://userchromejs/content/boot.sys.mjs:477 handleEvent chrome://userchromejs/content/boot.sys.mjs:567 [boot.sys.mjs:192:15](chrome://userchromejs/content/boot.sys.mjs) Error: @ copyCurrentUrlHotkey.uc.js:50 tryLoadScriptIntoWindow chrome://userchromejs/content/boot.sys.mjs:192 Caused by: ReferenceError: _ucUtils is not defined CopyCurrentURL chrome://userscripts/content/copyCurrentUrlHotkey.uc.js:50 chrome://userscripts/content/copyCurrentUrlHotkey.uc.js:94 injectClassicScriptIntoGlobal chrome://userchromejs/content/boot.sys.mjs:216 tryLoadScriptIntoWindow chrome://userchromejs/content/boot.sys.mjs:189 onDOMContent chrome://userchromejs/content/boot.sys.mjs:477 handleEvent chrome://userchromejs/content/boot.sys.mjs:567 [boot.sys.mjs:192:15](chrome://userchromejs/content/boot.sys.mjs) NS_ERROR_NOT_IMPLEMENTED: Component returned failure code: 0x80004001 (NS_ERROR_NOT_IMPLEMENTED) [nsIAppStartup.secondsSinceLastOSRestart] _collectStartupConditionsTelemetry resource:///modules/BrowserGlue.sys.mjs:1806 BG__onFirstWindowLoaded resource:///modules/BrowserGlue.sys.mjs:1914 BG_observe resource:///modules/BrowserGlue.sys.mjs:1116 _delayedStartup chrome://browser/content/browser-init.js:623 [BrowserGlue.sys.mjs:1815:15](resource:///modules/BrowserGlue.sys.mjs) _collectStartupConditionsTelemetry resource:///modules/BrowserGlue.sys.mjs:1815 BG__onFirstWindowLoaded resource:///modules/BrowserGlue.sys.mjs:1914 BG_observe resource:///modules/BrowserGlue.sys.mjs:1116 _delayedStartup chrome://browser/content/browser-init.js:623 TypeError: linkMap is undefined Links_onLinkChanged resource://gre/modules/NewTabUtils.sys.mjs:2003 PlacesProvider__callObservers resource://gre/modules/NewTabUtils.sys.mjs:697 handlePlacesEvents resource://gre/modules/NewTabUtils.sys.mjs:679 [NewTabUtils.sys.mjs:699:19](resource://gre/modules/NewTabUtils.sys.mjs) ​
olivertzeng commented 2 months ago

userChrome.ag.css: NS_ERROR_FILE_NOT_FOUND oh i see

olivertzeng commented 2 months ago
❯ fd userChrome.ag.css
JS/userChrome_ag_css.sys.mjs
olivertzeng commented 2 months ago

@MrOtherGuy after a bit of research i do miss both userChrome.ag.css and userChrome.au.css but adding them doesn't fix the problem

MrOtherGuy commented 2 months ago

Right. That's a bunch of errors. Some of the reference errors I can fix. They are caused by one of the example scripts using old api calls.

But the you have for example ReferenceError: _ucUtils is not defined - this suggests (but doesn't necessarily confirm) that you have an up-to-date version of fx-autoconfig loader (ie. files in /chrome/utils/) but that you also have other custom scripts that depend on old version of the loader. Current version does not define _ucUtils anymore - you can read more about these changes at issue #50

It's somewhat possible that having loads of errors happening on startup could lead to some script that about:home depends on to not execute properly.

olivertzeng commented 2 months ago

Right. That's a bunch of errors. Some of the reference errors I can fix. They are caused by one of the example scripts using old api calls.

But the you have for example ReferenceError: _ucUtils is not defined - this suggests (but doesn't necessarily confirm) that you have an up-to-date version of fx-autoconfig loader (ie. files in /chrome/utils/) but that you also have other custom scripts that depend on old version of the loader. Current version does not define _ucUtils anymore - you can read more about these changes at issue #50

It's somewhat possible that having loads of errors happening on startup could lead to some script that about:home depends on to not execute properly.

Thanks! will keep an eye on them

olivertzeng commented 2 months ago

@MrOtherGuy https://asciinema.org/a/668006 shows where they are used. p.s. most of my chrome is either copied or produced by ai. most of them is from https://github.com/black7375/Firefox-UI-Fix you can see my whole chrome directory online https://github.com/olivertzeng/chrome

MrOtherGuy commented 2 months ago

Sorry but I don't think I can help you much here other than that you probably want to update all your scripts to use methods provided by UC_API instead of old _ucUtils. Alternatively, you could downgrade your fx-autoconfig loader to version 0.9.0 or earlier - which could possibly work.

But it is entirely possible that you are not having some one singular problem but multiple different ones, and so it's is quite impossible for me to debug this for you. But I suggest that you try what happens if you no scripts are being loaded. Either by setting pref userChromeJS.enabled to false - which should only initialize the loader module but not load any additional files - or simply removing boot.sys.mjs file - that would at least narrow things down. If the former works then your issue is highly likely to be in one or more of your custom scripts which I can't help you too much with. If the issue persist even after removing boot.sys.mjs then you have some real problems, and I can't understand what that could be about, but probably not anything to do with fx-autoconfig.

olivertzeng commented 2 months ago

@MrOtherGuy 圖片 this is a brand new profile ive just created and has this error the log says

1721006429760   addons.xpi  WARN    Checking /usr/lib/librewolf/distribution/extensions for addons
NS_ERROR_NOT_IMPLEMENTED: Component returned failure code: 0x80004001 (NS_ERROR_NOT_IMPLEMENTED) [nsIAppStartup.secondsSinceLastOSRestart]
    _collectStartupConditionsTelemetry resource:///modules/BrowserGlue.sys.mjs:1806
    BG__onFirstWindowLoaded resource:///modules/BrowserGlue.sys.mjs:1914
    BG_observe resource:///modules/BrowserGlue.sys.mjs:1116
    _delayedStartup chrome://browser/content/browser-init.js:623
BrowserGlue.sys.mjs:1815:15
No chrome package registered for chrome://pocket/content/pktApi.sys.mjs
Error: Failed to load chrome://pocket/content/pktApi.sys.mjs TelemetryFeed.sys.mjs:1161:33
Key event not available on some keyboard layouts: key=“r” modifiers=“accel,alt” id=“key_toggleReaderMode” browser.xhtml
Key event not available on some keyboard layouts: key=“r” modifiers=“accel,alt” id=“key_quickRestart” browser.xhtml
Key event not available on some keyboard layouts: key=“i” modifiers=“accel,alt,shift” id=“key_browserToolbox” browser.xhtml

that is much less errors though

olivertzeng commented 2 months ago

userChromeJS.enabled to false didn't work as well

圖片 p.s. the new config doesn't have the chrome folder 圖片 removing programs work

MrOtherGuy commented 2 months ago

Wow, thanks to you I noticed that the "global toggle" pref userChromeJS.enabled is largely ignored - it only prevented window scoped scripts from running but system module scripts (.sys.mjs) files were still being executed. I have fixed that in version 0.10.1.

So, in the event that one of your .sys.mjs scripts is causing the issue, your previous test (setting that pref to false) did nothing useful. You should check the same with version 0.10.1 - preferably after removing startup-cache again.

olivertzeng commented 2 months ago

圖片 @MrOtherGuy I've updated to 0.10.1 and here is what it shows got even more errors in the test profile unreachable code after return statement Utils.sys.mjs:57:3 1721053908400 addons.xpi WARN Checking /usr/lib/librewolf/distribution/extensions for addons 1721053908480 addons.webextension.plasma-browser-integration@kde.org WARN Loading extension 'plasma-browser-integration@kde.org': Reading manifest: Warning processing key: An unexpected property was found in the WebExtension manifest. 1721053908775 addons.xpi-utils WARN Disabling foreign installed add-on plasma-browser-integration@kde.org in app-global formatURLPref: Couldn't get pref: startup.homepage_welcome_url.additional URLFormatter.sys.mjs:157:15 Ignoring protocol handler for mailto without a uriTemplate! ExtHandlerService.sys.mjs:162:19 NS_ERROR_NOT_IMPLEMENTED: Component returned failure code: 0x80004001 (NS_ERROR_NOT_IMPLEMENTED) [nsIAppStartup.secondsSinceLastOSRestart] _collectStartupConditionsTelemetry resource:///modules/BrowserGlue.sys.mjs:1806 BG__onFirstWindowLoaded resource:///modules/BrowserGlue.sys.mjs:1914 BG_observe resource:///modules/BrowserGlue.sys.mjs:1116 _delayedStartup chrome://browser/content/browser-init.js:623 BrowserGlue.sys.mjs:1815:15 No chrome package registered for chrome://pocket/content/pktApi.sys.mjs Error: Failed to load chrome://pocket/content/pktApi.sys.mjs TelemetryFeed.sys.mjs:1161:33 Error: Could not get children of `/home/olivertzeng/.librewolf/94hbkqsi.Test/thumbnails': directory does not exist (NS_ERROR_FILE_NOT_FOUND) PromiseWorker.sys.mjs:75 Key event not available on some keyboard layouts: key=“r” modifiers=“accel,alt” id=“key_toggleReaderMode” browser.xhtml Key event not available on some keyboard layouts: key=“r” modifiers=“accel,alt” id=“key_quickRestart” browser.xhtml Key event not available on some keyboard layouts: key=“i” modifiers=“accel,alt,shift” id=“key_browserToolbox” browser.xhtml update.locale file doesn't exist in either the application or GRE directories UpdateUtils.sys.mjs:143:13 services.settings: main/anti-tracking-url-decoration sync already running RemoteSettingsClient.sys.mjs:653 services.settings: main/public-suffix-list sync already running RemoteSettingsClient.sys.mjs:653 services.settings: main/hijack-blocklists sync already running RemoteSettingsClient.sys.mjs:653 services.settings: main/pioneer-study-addons-v1 sync already running RemoteSettingsClient.sys.mjs:653 services.settings: main/doh-providers sync already running RemoteSettingsClient.sys.mjs:653 XML Parsing Error: syntax error Location: https://aus5.mozilla.org/update/3/GMP/127.0.2-2/20240626231124/Linux_x86_64-gcc3/null/default-cck-librewolf/Linux%25206.9.9-arch1-1%2520(GTK%25203.24.43%252Clibpulse%252017.0.0)/io.gitlab.librewolf-community/1.0/update.xml Line Number 1, Column 1: update.xml:1:1 1721053940119 addons.productaddons WARN Unexpected missing content signature header during content signature validation services.settings: main/fxmonitor-breaches sync already running RemoteSettingsClient.sys.mjs:653 services.settings: main/search-config sync already running RemoteSettingsClient.sys.mjs:653 services.settings: main/search-config Signature failed InvalidSignatureError: Invalid content signature (main/search-config) using 'remote-settings.content-signature.mozilla.org-2024-08-29-13-50-59.chain' RemoteSettingsClient.sys.mjs:1095 services.settings: main/search-config local data was corrupted RemoteSettingsClient.sys.mjs:1130 services.settings: main/search-config Signature verified failed. Retry from scratch RemoteSettingsClient.sys.mjs:803 services.settings: security-state/cert-revocations sync already running RemoteSettingsClient.sys.mjs:653 services.settings: security-state/onecrl sync already running RemoteSettingsClient.sys.mjs:653 services.settings: security-state/intermediates sync already running

olivertzeng commented 2 months ago

but sorry if i didn't tell you but in order to fit with firefox ui fix i've renamed CSS into css and changed utils/chrome.manifest from CSS to css does that matter as well

MrOtherGuy commented 2 months ago

I don't know if that error makes less or more sense than before. Your utils.sys.mjs doesn't have a return on line 57 for example - although it is capitalized so maybe it means some other Utils.sys.mjs which is not part of my project? Anyway, I assume you tested with that pref userChromeJS.enabled set to false?

Nonetheless, the fact that it complains about formatURLPref sort of suggests that something is breaking in things that affect urlbar. I know that some things that touch urlbar can break startup in rather magnificent ways which would then result in bunch of errors. So maybe try removing scripts that deal with urlbar somehow?

olivertzeng commented 2 months ago

Utils.sys.mjs

This file doesn't exist though and yes userChromeJS.enabled is false

olivertzeng commented 2 months ago

Nonetheless, the fact that it complains about formatURLPref sort of suggests that something is breaking in things that affect urlbar. I know that some things that touch urlbar can break startup in rather magnificent ways which would then result in bunch of errors. So maybe try removing scripts that deal with urlbar somehow?

test profiles doesn't even have a chrome folder

olivertzeng commented 2 months ago

oh right now i see the problem ill have to test with clean profile with chrome/profile

olivertzeng commented 2 months ago

圖片 now this is how the test profile looks like @MrOtherGuy

MrOtherGuy commented 2 months ago

That is quite interesting... Startup has to be quite successful for that notification bar to show up. The only remaining source of clues would be to check what that content page would show up in its console. Right click the page and select Inspect, then see what the console says.

olivertzeng commented 2 months ago

actually it showed up for every profile

olivertzeng commented 2 months ago

That is quite interesting... Startup has to be quite successful for that notification bar to show up. The only remaining source of clues would be to check what that content page would show up in its console. Right click the page and select Inspect, then see what the console says.

all js are actually working it's just about:home not working for me

TypeError: sectionOrder is undefined
    renderSections resource://activity-stream/data/content/activity-stream.bundle.js:8231
    render resource://activity-stream/data/content/activity-stream.bundle.js:8251
    React 12
    Redux 4
    messageMiddleware resource://activity-stream/data/content/activity-stream.bundle.js:10935
    rehydrationMiddleware resource://activity-stream/data/content/activity-stream.bundle.js:10968
    initStore resource://activity-stream/data/content/activity-stream.bundle.js:11009
[react-dom.js:125:24](resource://activity-stream/vendor/react-dom.js)

with the default stuff in profile/chrome/* into profile-name/chrome

MrOtherGuy commented 2 months ago

Dang, that's much less helpful than I had hoped.

The only other thing I can think of you could test is to see if things work in normal Firefox.

Forks are pretty much second-class citizens as far as I'm concerned and if a fork is breaking some compatibility then I don't really try too hard to provide a fix for that fork specifically. That isn't to say that the issue is definitely about the fork, just to say that I certainly don't test any forks.

olivertzeng commented 2 months ago

Dang, that's much less helpful than I had hoped.

sorry for that if i couldn't help.

The only other thing I can think of you could test is to see if things work in normal Firefox. will do

圖片 it works @MrOtherGuy

olivertzeng commented 2 months ago
Browser is executing custom scripts via autoconfig [boot.sys.mjs:5:9](chrome://userchromejs/content/boot.sys.mjs)
1721136689349   addons.xpi  WARN    Checking /usr/lib/firefox/distribution/extensions for addons
Hi mom, I'm loaded! [test.uc.js:1:9](chrome://userscripts/content/test.uc.js)
NS_ERROR_NOT_IMPLEMENTED: Component returned failure code: 0x80004001 (NS_ERROR_NOT_IMPLEMENTED) [nsIAppStartup.secondsSinceLastOSRestart]
    _collectStartupConditionsTelemetry resource:///modules/BrowserGlue.sys.mjs:1819
    BG__onFirstWindowLoaded resource:///modules/BrowserGlue.sys.mjs:1890
    BG_observe resource:///modules/BrowserGlue.sys.mjs:1125
    _delayedStartup chrome://browser/content/browser-init.js:616
[BrowserGlue.sys.mjs:1828:15](resource:///modules/BrowserGlue.sys.mjs)
Region.sys.mjs: Error fetching region SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data [Region.sys.mjs:409:11](resource://gre/modules/Region.sys.mjs)
Region.sys.mjs: Failed to fetch region Error: NO_RESULT
    _getRegion resource://gre/modules/Region.sys.mjs:411
[Region.sys.mjs:208:11](resource://gre/modules/Region.sys.mjs)
WebGL context was lost. 2 [Troubleshoot.sys.mjs:766:17](resource://gre/modules/Troubleshoot.sys.mjs)
stack of snapshot error for about:support:  TypeError: titleL10nObjects[i] is null
    experimentalFeatures chrome://global/content/aboutSupport.js:409
 :  experimentalFeatures@chrome://global/content/aboutSupport.js:409:28
[aboutSupport.js:31:19](chrome://global/content/aboutSupport.js)
NotFoundError: No such JSProcessActor 'BrowserToolboxDevToolsProcess'
Key event not available on some keyboard layouts: key=“r” modifiers=“accel,alt” id=“key_toggleReaderMode” [browser.xhtml](chrome://browser/content/browser.xhtml)
Key event not available on some keyboard layouts: key=“i” modifiers=“accel,alt,shift” id=“key_browserToolbox”

this is the console errors of firefox with homepage workingwith the default fx-config profile

MrOtherGuy commented 2 months ago

Great! Thanks a lot, no we at least know that it is only limited to Librewolf (maybe other forks as well?) and whatever it is doing.

With this I can perhaps try to find time and install Librewolf and see if I can figure out something, no promises though. I am kinda interested about what on earth they might be doing that breaks in this way.

olivertzeng commented 2 months ago

Great! Thanks a lot, no we at least know that it is only limited to Librewolf (maybe other forks as well?) and whatever it is doing.

With this I can perhaps try to find time and install Librewolf and see if I can figure out something, no promises though. I am kinda interested about what on earth they might be doing that breaks in this way.

i can help you test some of the forks if you would like to and also the logs as well and maybe chromium browsers as well

MrOtherGuy commented 2 months ago

Okay, so I downloaded Librewolf for Windows (portable version) and started it once. It seemed okay.

Then I added just the files to program folder as well as files in chrome/ - and indeed I saw this error - error messages in console looked quite similar to what you have shown.

But both browser console and browser toolbox seemed to be totally broken in fantastic ways, so no real help from those sadly.

After this and couple of other attempts I decided to remove the profile folder completely - to start completely fresh. To my surprise the errors still happen but fx-autoconfig files nor chrome/ folder don't even exist anymore.

Some more digging happened because the above would suggest that Librewolf is just utterly broken. Well, eventually I found what is going on...

Drumroll

Well, Librewolf has its own configuration file called librewolf.cfg in its program folder. This is controlled by pref general.config.filename - on normal Firefox this pref doesn't exist and thus Firefox doesn't load any autoconfig files. But Librewolf apparently has it's own autoconfiguration file and our file conflicts with theirs.

Soooo, what you need to do is to:

  1. remove <program dir>/defaults/pref/config-prefs.js
  2. Put contents of <program-dir>/config.js at the end of <program-dir/librewolf.cfg

That should make things work. However, doing this will not fix errors in you scripts that use APIs from old fx-autoconfig versions - those you need to fix yourself.

In addition, because this requires writing stuff to librewolf.cfg, these changes are likely to be undone when Librefox is updated, but I don't really see any way around that.

Anyway, mystery solved so that's nice.

olivertzeng commented 2 months ago

Okay, so I downloaded Librewolf for Windows (portable version) and started it once. It seemed okay.

Then I added just the files to program folder as well as files in chrome/ - and indeed I saw this error - error messages in console looked quite similar to what you have shown.

But both browser console and browser toolbox seemed to be totally broken in fantastic ways, so no real help from those sadly.

After this and couple of other attempts I decided to remove the profile folder completely - to start completely fresh. To my surprise the errors still happen but fx-autoconfig files nor chrome/ folder don't even exist anymore.

Some more digging happened because the above would suggest that Librewolf is just utterly broken. Well, eventually I found what is going on...

Drumroll

Well, Librewolf has its own configuration file called librewolf.cfg in its program folder. This is controlled by pref general.config.filename - on normal Firefox this pref doesn't exist and thus Firefox doesn't load any autoconfig files. But Librewolf apparently has it's own autoconfiguration file and our file conflicts with theirs.

Soooo, what you need to do is to:

1. remove `<program dir>/defaults/pref/config-prefs.js`

2. Put **contents** of `<program-dir>/config.js` at the end of `<program-dir/librewolf.cfg`

That should make things work. However, doing this will not fix errors in you scripts that use APIs from old fx-autoconfig versions - those you need to fix yourself.

In addition, because this requires writing stuff to librewolf.cfg, these changes are likely to be undone when Librefox is updated, but I don't really see any way around that.

Anyway, mystery solved so that's nice.

damn its fixed! thanks!