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

[Bug]: The global content client will init twice on the startup #35916

Closed
3 tasks done
netflt opened this issue Oct 5, 2022 · 0 comments · Fixed by #35932
Closed
3 tasks done

[Bug]: The global content client will init twice on the startup #35916

netflt opened this issue Oct 5, 2022 · 0 comments · Fixed by #35932

Comments

@netflt
Copy link

netflt commented Oct 5, 2022

Preflight Checklist

Electron Version

19

What operating system are you using?

Other (specify below)

Operating System Version

macOS

What arch are you using?

Other (specify below)

Last Known Working Electron version

No response

Expected Behavior

The global content client should init once on startup.

Actual Behavior

The global content client will init twice on the startup and it cause a memory leak.causes.

Testcase Gist URL

No response

Additional Information

These days I try to debug the electron source and found that the global content client will init twice on startup because the ElectronMainDelegate didn't override the CreateContentClient.

The first time, it call the ContentMainDelegate::CreateContentClient to create an ContentClient instance.

void SetContentClient(ContentClient* client) {
  /*
  if(g_client != nullptr)
  {
      DCHECK(false);
  }
  */
  g_client = client;
}

//ContentClientCreator::Create
static void Create(ContentMainDelegate* delegate) {
    ContentClient* client = delegate->CreateContentClient();
    DCHECK(client);
    SetContentClient(client);
  }

image

Then the global ContentClient will be set as an ElectronContentClient instance in ElectronMainDelegate::BasicStartupComplete

image

So the first one is never to be used and never to be free until the process exit.

@netflt netflt added the bug 🪲 label Oct 5, 2022
@netflt netflt changed the title [Bug]: The global content client will inite twice on the startup [Bug]: The global content client will init twice on the startup Oct 6, 2022
@codebytere codebytere added blocked/need-info ❌ Cannot proceed without more information platform/all 19-x-y and removed blocked/need-info ❌ Cannot proceed without more information labels Oct 6, 2022
@codebytere codebytere self-assigned this Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants