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

fix(webdriver): configure Firefox to start with the default user context only #12309

Closed
wants to merge 7 commits into from

Conversation

Lightning00Blade
Copy link
Collaborator

By default Firefox start with multiple UserContexts (containers). We need to disable this by only providing single Container to the containers.json file and pointing to it from lastUserContextId.

if (options.disableExtraUserContexts) {
const containersPath = path.join(options.path, 'containers.json');

const singleContainer = JSON.stringify({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@whimboo we want to disable extra user contexts for Firefox in Puppeteer (for profiles created by Puppeteer). This works but I wonder if this solution is something we can rely on?

P.S. @Lightning00Blade did you notice any speed up in launching Firefox?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running page.spec.ts with hook, shows diff in the margin of error (under 1%)

  after(() => {
    console.log('End', performance.now());
  });

But I think there is slight overhead for writing the file if I isolate a test is around 100ms, I think I can optimize it by paralleling the writing of the file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With parallelization it seems the overhead of writing a file to be around 30-50ms and that varies from run to run a lot have seen the old one be slower and the new one be faster.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(whimboo is off this week)

There are two internal containers that should be preserved:
https://searchfox.org/mozilla-central/rev/6121b33709dd80979a6806ff59096a561e348ae8/toolkit/components/contextualidentity/ContextualIdentityService.sys.mjs#85-105

userContextIdInternal.thumbnail and userContextIdInternal.webextStorageLocal
I am not sure what are the side effects of removing the second one, but I think it's better to keep it.

Note that the current version was recently bumped to 5 (https://bugzilla.mozilla.org/show_bug.cgi?id=1814969), but it's fine to keep 4 for now, and anyway the contextualidentityservice has migration logic based on the version.

Overall I would say this is fine as a temporary solution but we should try to introduce a preference in Firefox in order to skip the default user profiles.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Lightning00Blade let's probably rewrite the tests to expect any number of non-default contexts.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah sound good, I think I would extract some of the changes from this PR as well, I think we can make FF launch just a little bit faster.

@OrKoN OrKoN added the full-ci label Apr 23, 2024
Copy link
Collaborator

@OrKoN OrKoN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's wait for feedback from Henrik

@OrKoN OrKoN changed the title fix(webdriver): Firefox starting with multiple UserContexts fix(webdriver): configure Firefox to start with the default user context only Apr 23, 2024
@Lightning00Blade Lightning00Blade deleted the fix-firefox-bidi-user-context-issue branch June 11, 2024 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants