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

Tests are slow when browser is minized #228

Open
rklec opened this issue May 30, 2022 · 8 comments
Open

Tests are slow when browser is minized #228

rklec opened this issue May 30, 2022 · 8 comments

Comments

@rklec
Copy link

rklec commented May 30, 2022

When you use Firefox and the window is minimized or not active which is running the tests, they run very slow.

Question

How can I prevent this, as obviously I want to run my tests, even if they run in the background. So I guess there is no reason in our use case here for such a behavior.

So how can I disable that?
Or can you generally disable it by default?

Reason

As far as I know the cause may be the "new" Process Priority Manager on Windows' Firefox versions that prioritized tasks the user works on. So minimized windows of course are not considered a priority.

I am not sure whether this also applies to FirefoxHeadless.

@birtles
Copy link
Collaborator

birtles commented May 31, 2022

That's a really good question. I'm not sure what the answer would be. Out of curiosity, is there a reason you can't use FirefoxHeadless?

Alternatively, if it is the process priority manager, perhaps you could turn it off via prefs?

browsers: ['FirefoxNoProcessPriorityManager'],

customLaunchers: {
    FirefoxNoProcessPriorityMangaer: {
        base: 'Firefox',
        prefs: {
            'dom.ipc.processPriorityManager.enabled': false
        }
    }
}

?

It looks like Firefox does that for xpcshell tests:

https://searchfox.org/mozilla-central/rev/32ca4fc265150e7d3d7aa6c6abea088768cf024b/testing/profiles/xpcshell/user.js#26-30

// The process priority manager only shifts priorities when it has at least
// one active tab. xpcshell tabs don't have any active tabs, which would mean
// all processes would run at low priority, which is not desirable, so we
// disable the process priority manager entirely here.
user_pref("dom.ipc.processPriorityManager.enabled", false);

@rklec
Copy link
Author

rklec commented May 31, 2022

Well maybe I wanna see my tests and so I explicitly don''t want to use FirefoxHeadless or have another reason for doing so.
Your solution sounds good though, why not integrate that by default?

@birtles
Copy link
Collaborator

birtles commented May 31, 2022

Your solution sounds good though, why not integrate that by default?

That sounds reasonable. If it works for you, could you let me know? Thanks!

@rklec
Copy link
Author

rklec commented May 31, 2022

Well, I tried and it does not solve the issue.
I mean it's not bad, it can certainly be included, however the original issue remains.

  • Also I found out that this setting dom.min_background_timeout_value is bad. When it is set to 10 (ms) it really throttles timeouts a lot/fast. The default 1000ms (tested here and describe din the docs) seems way more reasonable.
  • I can confirm, however, that FirefoxDeveloperHeadless runs fast, i.e. no problems here. Is there any way to find out what specs this uses?
  • dom.suspend_inactive.enabled also sounds like a thing we don't want, though AFAIK it suspends entire tabs and they are not loaded/shwon then.

Firefox Developer 101.0b9
Windows 10

As or Chrome I found settings around that.

Testing with currently:

customLaunchers: {
  FirefoxDeveloperNoProcessPriorityMangaer: {
    base: 'FirefoxDeveloper',
    prefs: {
      'dom.ipc.processPriorityManager.enabled': false,
      'dom.suspend_inactive.enabled': false,
      'gfx.webrender.enable-low-priority-pool': false,
      'dom.min_background_timeout_value': 10000
    }
  }
},

@birtles
Copy link
Collaborator

birtles commented May 31, 2022

How about setting widget.windows.window_occlusion_tracking.enabled to false?

@rklec
Copy link
Author

rklec commented May 31, 2022

network.http.throttle.enabled is also already false. widget.windows.window_occlusion_tracking.enabled does not help either, still slow. (also tried this extension, which essentially does the same AFAIK, does not work)

Ah no widget.windows.window_occlusion_tracking.enabled works, but only when the window is open (and the correct tab is choosen!), but the window itself not focused. If the window is correctly minimized it is still slow!

Note the performance drain is immense: It's 1 test/s when minimized and when focused it is like 200 tests/s (calculated based on the run time it takes).

customLaunchers: {
  FirefoxDeveloperNoProcessPriorityMangaer: {
    base: 'FirefoxDeveloper',
    prefs: {
      'dom.ipc.processPriorityManager.enabled': false,
      'dom.suspend_inactive.enabled': false,
      'gfx.webrender.enable-low-priority-pool': false,
      'dom.min_background_timeout_value': 10000,
      'widget.windows.window_occlusion_tracking.enabled': false,
      'widget.pause-compositor-when-minimized': false
    }
  }
},

@birtles
Copy link
Collaborator

birtles commented May 31, 2022

How about widget.pause-compositor-when-minimized ?

@rklec
Copy link
Author

rklec commented May 31, 2022

Already tried 🙂

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

No branches or pull requests

2 participants