Skip to content

Page.frameAttached Chrome Devtools Protocol events are not being dispatched #46048

Closed as not planned

Description

@brianlyn

Preflight Checklist

Electron Version

35.0.1 (also tested in the latest nightly and 33.0.0)

What operating system(s) are you using?

macOS

Operating System Version

MacOS Sequoia 15.1.1

What arch are you using?

arm64 (including Apple Silicon)

Last Known Working Electron version

No response

Expected Behavior

The Page.frameAttached CDP event should be dispatched when a frame has been attached to its parent.

This event should be fired after rendering an iframe in a given webContents while:

  • attached to the webContents debugger AND
  • the Page domain is enabled via debugger.sendCommand('Page.enabled')

Actual Behavior

The event is not fired, despite the above conditions being met. Testing in Chrome itself via the DevTools protocol monitor shows that the event is fired when rendering a similar iframe on a page.

Testcase Gist URL

https://gist.github.com/323207d04289df0dda5267b2d2cdfc1d

Additional Information

The gist simply logs CDP events after enabling the page domain to create a simple test case.

I've also unsuccessfully tested this with:

  • cross-origin and same-origin iframes
  • iframes that are rendered mounted/unmounted dynamically via js

For additional context, I'm investigating this because I'm attempting to integrate playwright with electron for automation use-cases, and playwright listens for the Page.frameAttached CDP event to track frames.

Activity

  1. added theissue type on Mar 14, 2025
  2. added
    has-repro-gist
    on Mar 14, 2025
  3. moved this to 👀 Unsorted Items in 35-x-yon Mar 14, 2025
  4. brianlyn commented on Mar 14, 2025

    @brianlyn
    Author

    I took a stab at investigating why this might be happening by creating a custom electron build and adding some logs. I don't have a fix but I've been able to outline the basic flow of what is happening:

    1. Page.frameAttached events are initially dispatched from blink here

    2. The event is enqueued/processed/dispatched via mojo IPC from blink -> the browser process here

    3. The IPC event is received in the browser DevToolsSession class here

    4. The browser DevToolsSession class passes the event to the attached electron debugger client here

    5. The electron debugger client emits the event to javascript here

    I was able to observe that Page.frameAttached events made it to (2) but no further (it gets enqueued/processed/dispatched but then its gone). Other CDP events in the same domain that are also initially dispatched from blink (e.g. Page.frameDetached) go through this entire flow and are emitted in javascript.

  5. brianlyn commented on Mar 16, 2025

    @brianlyn
    Author

    I've narrowed down the problem to this logic

    void Debugger::RenderFrameHostChanged(content::RenderFrameHost* old_rfh,

    We detach/reattach the session in Debugger::RenderFrameHostChanged. When I remove that logic the Page.frameAttached event makes it all the way though the flow I outlined above and is emitted in js.

    I'm going to investigate possible fixes this week. Would love input from folks if anyone has ideas as to how to fix this.

    Relevant PR: #14475

  6. brianlyn commented on Mar 17, 2025

    @brianlyn
    Author

    Quick follow up - The reason the Page.frameAttached event is being swallowed is that the page agent / session reconnect asynchronously (see implementation here). The frame gets attached while the reconnection task is ongoing so we lose the event.

    I wonder if there is a way to pause messages while we're reconnecting, or if there is a way to resolve the issue fixed by #14475 without disconnecting/reconnecting.

    I also wonder if this is causing other subtle bugs in addition to what i've observed.

  7. moved this from 👀 Unsorted Items to 👍 Does Not Block Stable in 35-x-yon Mar 19, 2025
  8. electron-issue-triage commented on Jun 16, 2025

    @electron-issue-triage

    This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

  9. brianlyn commented on Jun 29, 2025

    @brianlyn
    Author

    bump

  10. huaxinjiayou commented on Aug 8, 2025

    @huaxinjiayou

    I've narrowed down the problem to this logic

    electron/shell/browser/api/electron_api_debugger.cc

    Line 82 in 4ad20cc

    void Debugger::RenderFrameHostChanged(content::RenderFrameHost* old_rfh,
    We detach/reattach the session in Debugger::RenderFrameHostChanged. When I remove that logic the Page.frameAttached event makes it all the way though the flow I outlined above and is emitted in js.

    I'm going to investigate possible fixes this week. Would love input from folks if anyone has ideas as to how to fix this.

    Relevant PR: #14475

    @brianlyn

    I encountered the same issue when using puppeteer-core in electron.After commenting out these three lines of code, it can be used normally.Is there any other negative impact if we remove these three lines of code?

  11. brianlyn commented on Aug 10, 2025

    @brianlyn
    Author

    I had to deprioritize this issue and am not sure when i'll be able to continue investigating. The original PR that added the code can be found here: #14475. A good next step would be to investigate if the issue it was fixing is still a problem without the change. Do you have capacity to do that?

  12. electron-issue-triage commented on Nov 9, 2025

    @electron-issue-triage

    This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

  13. electron-issue-triage commented on Dec 9, 2025

    @electron-issue-triage

    This issue has been closed due to inactivity, and will not be monitored. If this is a bug and you can reproduce this issue on a supported version of Electron please open a new issue and include instructions for reproducing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    35-x-ybug 🪲component/devtoolshas-repro-gistplatform/macOSstale

    Type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions