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

PWAs sometimes crash immediately on first opening, and then work normally after re-opening. #488

Closed
awdwyn opened this issue Apr 21, 2024 · 19 comments
Labels
bug Something isn't working help wanted Extra attention is needed
Milestone

Comments

@awdwyn
Copy link

awdwyn commented Apr 21, 2024

Description

On a fresh boot, or sometimes after the PC has been idle for a while, opening a PWA (any of them) will show the window briefly and then immediately close. Re-opening the app (almost always, but not guaranteed) will work normally.

Steps to Reproduce

  1. Open PWA from launcher or console
  2. See error

Additional Information

This is from journalctl showing the result of the failure while opening my bitwarden webUI PWA. No other logs show anything.

20:51:27.070 UTC [email protected] app-FFPWA\x2d01HVY51HGCWXJCCYJ8AZ6533P4-1274414f271e4424a5dbff7594ede7bc.scope: Consumed 1.263s CPU time.
20:51:29.104 UTC [email protected] 20:51:29 [INFO] Patching the runtime
20:51:29.104 UTC [email protected] 20:51:29 [INFO] Runtime patched!
20:51:29.104 UTC [email protected] 20:51:29 [INFO] Patching the profile
20:51:29.106 UTC [email protected] 20:51:29 [INFO] Profile patched!
20:51:29.106 UTC [email protected] 20:51:29 [INFO] Launching the web app
20:51:29.120 UTC [email protected] app-FFPWA\x2d01HVY51HGCWXJCCYJ8AZ6533P4-c070ff37ae0748aa812f5e7c3bd65276.scope: Couldn't move process 7862 to requested cgroup '/user.slice/user-1000.slice/[email protected]/app.slice/app-FFPWA\x2d01HVY51HGCWXJCCYJ8AZ6533P4-c070ff37ae0748aa812f5e7c3bd65276.scope': No such process
20:51:29.120 UTC [email protected] app-FFPWA\x2d01HVY51HGCWXJCCYJ8AZ6533P4-c070ff37ae0748aa812f5e7c3bd65276.scope: Failed to add PIDs to scope's control group: No such process
20:51:29.120 UTC [email protected] app-FFPWA\x2d01HVY51HGCWXJCCYJ8AZ6533P4-c070ff37ae0748aa812f5e7c3bd65276.scope: Failed with result 'resources'.
20:51:29.120 UTC [email protected] Failed to start Bitwarden Web App.

Next I opened a terminal and used firefoxpwa site launch 01HVTD62EA2KY9QPTGS64EBKS1 -- --jsconsole to load my unRAID webUI. The error occured again, displaying the following in the browser console:

1713733303001	addons.xpi	WARN	Checking /home/[REDACTED]/.local/share/firefoxpwa/runtime/distribution/extensions for addons
TypeError: currentPlacements is undefined CustomizableUI.sys.mjs:3632:11
    get inDefaultState resource:///modules/CustomizableUI.sys.mjs:3632
    get inDefaultState resource:///modules/CustomizableUI.sys.mjs:4539
    _updateResetButton resource:///modules/CustomizeMode.sys.mjs:1535
    observe resource:///modules/CustomizeMode.sys.mjs:1655
    set resource://pwa/utils/xPref.jsm:37
    configureSettings file:///home/[REDACTED]/.local/share/firefoxpwa/profiles/01HVTD62D9XQDRJ333N8ZCXP0P/chrome/pwa/content/browser.jsm:1866
    configureAll file:///home/[REDACTED]/.local/share/firefoxpwa/profiles/01HVTD62D9XQDRJ333N8ZCXP0P/chrome/pwa/content/browser.jsm:1779
    PwaBrowser file:///home/[REDACTED]/.local/share/firefoxpwa/profiles/01HVTD62D9XQDRJ333N8ZCXP0P/chrome/pwa/content/browser.jsm:17
    <anonymous> file:///home/[REDACTED]/.local/share/firefoxpwa/profiles/01HVTD62D9XQDRJ333N8ZCXP0P/chrome/pwa/content/browser.jsm:2099
    loadUserScript resource://pwa/chrome.jsm:118
    handleEvent resource://pwa/chrome.jsm:97
Uncaught TypeError: this._button is null
    init chrome://browser/content/browser-addons.js:1171
    onDOMContentLoaded chrome://browser/content/browser.js:1670
browser-addons.js:1171:5
    init chrome://browser/content/browser-addons.js:1171
    onDOMContentLoaded chrome://browser/content/browser.js:1670
NS_ERROR_NOT_IMPLEMENTED: Component returned failure code: 0x80004001 (NS_ERROR_NOT_IMPLEMENTED) [nsIAppStartup.secondsSinceLastOSRestart]
    _collectStartupConditionsTelemetry resource:///modules/BrowserGlue.sys.mjs:1756
    BG__onFirstWindowLoaded resource:///modules/BrowserGlue.sys.mjs:1864
    BG_observe resource:///modules/BrowserGlue.sys.mjs:1086
    _delayedStartup chrome://browser/content/browser.js:2112
BrowserGlue.sys.mjs:1765:15
    _collectStartupConditionsTelemetry resource:///modules/BrowserGlue.sys.mjs:1765
    BG__onFirstWindowLoaded resource:///modules/BrowserGlue.sys.mjs:1864
    BG_observe resource:///modules/BrowserGlue.sys.mjs:1086
    _delayedStartup chrome://browser/content/browser.js:2112
TypeError: error loading dynamically imported module: chrome://global/content/elements/moz-button-group.mjs
Loading failed for the module with source “chrome://global/content/elements/moz-button-group.mjs”. browser.xhtml
Loading failed for the module with source “chrome://global/content/elements/moz-toggle.mjs”. browser.xhtml
AboutHomeStartupCache: requestCache called with no _procManager! BrowserGlue.sys.mjs:5958:16
    requestCache resource:///modules/BrowserGlue.sys.mjs:5958
    cacheNow resource:///modules/BrowserGlue.sys.mjs:5913
    _cacheTask resource:///modules/BrowserGlue.sys.mjs:5757
    _runTask resource://gre/modules/DeferredTask.sys.mjs:341
    _timerCallback resource://gre/modules/DeferredTask.sys.mjs:312
    _timerCallback resource://gre/modules/DeferredTask.sys.mjs:331
    callback resource://gre/modules/DeferredTask.sys.mjs:179

Environment

[REDACTEDs]-pc:/home/[REDACTED]
15:10 [REDACTED]: neofetch
                   -`                     
                  .o+`                   OS: Arch Linux x86_64 
                 `ooo/                   Host: Z790 AORUS ELITE AX 
                `+oooo:                  Kernel: 6.8.7-arch1-1 
               `+oooooo:                 Uptime: 1 hour, 2 mins 
               -+oooooo+:                Packages: 1394 (pacman), 8 (flatpak) 
             `/:-:++oooo+:               Shell: bash 5.2.26 
            `/++++/+++++++:              Resolution: 3440x1440 
           `/++++++++++++++:             DE: Plasma 6.0.4 
          `/+++ooooooooooooo/`           WM: kwin 
         ./ooosssso++osssssso+`          Theme: Breeze-Dark [GTK2], Breeze [GTK3] 
        .oossssso-````/ossssss+`         Icons: breeze-dark [GTK2/3] 
       -osssssso.      :ssssssso.        Terminal: BlackBox 
      :osssssss/        osssso+++.       CPU: 13th Gen Intel i7-13700K (24) @ 5.300GHz 
     /ossssssss/        +ssssooo/-       GPU: NVIDIA GeForce RTX 4070 Ti 
   `/ossssso+/:-        -:/+osssso+-     Memory: 6422MiB / 31924MiB 
  `+sso+:-`                 `.-/+oso:    GPU Driver: NVIDIA 550.76 
 `++:.                           `-/+/
 .`                                 `/                           
                                                                 

Project versions:

  • Extension version: 2.11.1
  • Native version: 2.11.1
  • Runtime version: 125.0.1
  • Firefox version: 125.0.1
REDACTED]s-pc:/home/[REDACTED]
15:08 [REDACTED]: sudo pacman -Qs firefox
[sudo] password for [REDACTED]: 
local/firefox 125.0.1-1
    Standalone web browser from mozilla.org
local/firefox-pwa 2.11.1-1
    A tool to install, manage and use Progressive Web Apps (PWAs) in Mozilla Firefox (native component)

Other

My user.js automatically enables css styling within firefox, and turns off the tabs:

user_pref("toolkit.legacyUserProfileCustomizations.stylesheets", true);
user_pref("browser.tabs.inTitlebar", 0);

and userChrome.css centers the title and turns off the hamburger menu button:

@-moz-document url('chrome://browser/content/browser.xhtml') {
    /* Horizontally center the title element */
    .site-info > .tab-label-container {
        position: relative;
        margin-left: auto;
        margin-right: auto;
        left: 9rem;
    }
}
#navigator-toolbox {
    visibility: collapse;
}
@awdwyn awdwyn added the bug Something isn't working label Apr 21, 2024
@hofleverancier
Copy link

I have also experienced this, in my case though I'm convinced it only occurs when I do a reboot without closing the PWA manually, in other words, when it is killed.

@filips123
Copy link
Owner

filips123 commented Apr 30, 2024

@awdwyn Does it happen on every fresh boot or only sometimes? I think I experienced this in the past, but not frequently, which makes it harder to fix.

There are some problems with session restore (so, maybe it's really because of killing PWAs before), so this issue might be related, but I don't know why it happens. The error in CustomizableUI seems to be caused because PWAsForFirefox sets some preferences during startup, but I don't know why the error then occurs. (Edit: This error sometimes also happens normally, so I think it's not the issue here.) I'm also not sure why the other errors happen.

I will try to fix this in the future when I rewrite the UserChrome part, but it will probably take a while.

@filips123 filips123 moved this to To Do in PWAsForFirefox Apr 30, 2024
@filips123 filips123 added the help wanted Extra attention is needed label Apr 30, 2024
@awdwyn
Copy link
Author

awdwyn commented May 1, 2024

@filips123 It's almost a guaranteed thing on a fresh reboot. I just rebooted this machine and the first two PWAs I opened both did the open->crash->reopen->ok loop, but after that the other PWAs I opened were fine. I don't expect to see the bug again until either another reboot or extended suspend.

@FranBar1966
Copy link

FranBar1966 commented Jun 2, 2024

I have a suspicion that the error occurs when trying to restore a previous session.

In a profile where I have browser.sessionstore.max_resumed_crashes set to 0 this error does not occur.

Maybe someone else can try to reproduce the error.

Edit (workaround):

Add to prefs.js
user_pref("browser.sessionstore.max_resumed_crashes", 0);

@awdwyn
Copy link
Author

awdwyn commented Jun 2, 2024

I will test this on my system

@awdwyn
Copy link
Author

awdwyn commented Jun 3, 2024

Initial test looks really good. Rebooted, loaded 10 PWAs; none had this issue. Rebooted again and tested again, same results. I think you're on to something as I absolutely would have run into this in those tests previously.

I've updated user.js in all of my profiles folders in (/home/beaker/.local/share/firefoxpwa/profiles/) and also the default profile template. Thanks for sharing you're suspicions.

@FranBar1966
Copy link

Whoever implements this workaround must take into account that the session will not be restored in case of a crash.

On the other hand, the origin of the error seems to be precisely in the restoration of the session, so the session will not be restored in any case.

@filips123
Copy link
Owner

filips123 commented Jun 3, 2024

I've already tried to disable restoring session a few times with another pref (browser.sessionstore.resume_from_crash) that I thought disables session, but appearently it didn't. So, I'll probably also set browser.sessionstore.max_resumed_crashes to 0 by default.

But I'm still not sure why all those session issues/crashes even happened in the first place...

@superboo07
Copy link

superboo07 commented Jun 11, 2024

I have a suspicion that the error occurs when trying to restore a previous session.

In a profile where I have browser.sessionstore.max_resumed_crashes set to 0 this error does not occur.

Maybe someone else can try to reproduce the error.

Edit (workaround):

Add to prefs.js user_pref("browser.sessionstore.max_resumed_crashes", 0);

when attempting this the PWA still faced the same issues unfortunately, and I noticed that the prefs.js was immeditely modified apon reopening to remove the line I had added.

@superboo07
Copy link

Whoever implements this workaround must take into account that the session will not be restored in case of a crash.

On the other hand, the origin of the error seems to be precisely in the restoration of the session, so the session will not be restored in any case.

personally I don't see this as of great loss when the alternative is the app annoyingly closing itself when trying to launch

@FranBar1966
Copy link

when attempting this the PWA still faced the same issues unfortunately, and I noticed that the prefs.js was immeditely modified apon reopening to remove the line I had added.

If you modify prefs.js while the browser is open, it will overwrite it when you close the browser.

You can also try with: user_pref("browser.sessionstore.resume_session_once", true);

@superboo07
Copy link

when attempting this the PWA still faced the same issues unfortunately, and I noticed that the prefs.js was immeditely modified apon reopening to remove the line I had added.

If you modify prefs.js while the browser is open, it will overwrite it when you close the browser.

You can also try with: user_pref("browser.sessionstore.resume_session_once", true);

Yes I noticed this, the issue still occured even when editing while the browser is closed.

@ccoager
Copy link

ccoager commented Aug 14, 2024

This fixed it for me:
browser.sessionstore.idleDelay: -1

@filips123
Copy link
Owner

@ccoager Did you also set the other preferences or just this one?

There are many different preferences that control the session, but I don't know what each one does, which are really needed to fix this and why it even happens.

@ccoager
Copy link

ccoager commented Aug 14, 2024

@filips123 I did try the other preferences mentioned in this issue but none of them helped.

@github-project-automation github-project-automation bot moved this from To Do to Done in PWAsForFirefox Sep 7, 2024
@filips123
Copy link
Owner

I've set browser.sessionstore.max_resumed_crashes=0 and browser.sessionstore.idleDelay=-1. I hope this will fix the issue. It will be available in the next version.

@ccoager
Copy link

ccoager commented Sep 22, 2024

@filips123 You have a conflict between this ticket and #559 as they set the same variable, browser.sessionstore.idleDelay, to different values. Since release 2.12.4 and the changing of browser.sessionstore.idleDelay, this is now crashing again for me.

@filips123
Copy link
Owner

Well, setting browser.sessionstore.idleDelay to -1 broke extensions (#557), swipe gestures (#558) and closing (#559), so I reverted it. I'm not sure why it's crashing for you if browser.sessionstore.idleDelay is not set to -1. Please check if it also crashes in a fresh web app profile.

@ccoager
Copy link

ccoager commented Sep 25, 2024

@filips123 I did some more digging and I think I found the root cause. I have browser.startup.page configured in user.js which you said causes problems mentioned here, #384. I removed my configuration for browser.sessionstore.idleDelay and browser.startup.page and the crashes have stopped. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
Status: Done
Development

No branches or pull requests

6 participants