Skip to content

WebView frequently fails to load the node-related globals when there are multiple instance in a browser window  #1038

Description

@christoth

I have created webview "load test" use case[https://gist.github.com/christoth/d11e03c70a144ba02caa], creating and deleting multiple webviews at a time.

Please click the "Start Test" button, which will created 5 "tabs"/webviews at a time and then it will start deleting them 5 at a time (always keeping at least 5 tabs open at all times - delayed close timer)

Frequently, but not all the time, the webview fails to load the node-related globals (e.g. require()) which causes a ReferenceError in content.html. This happens both with a preload defined and without.

I have tested this on Win7 x64, with atom-shell versions 20.6 & 20.7 (and it has occurred with my larger application with prior versions as well.

Thanks

Activity

  1. CharlieHess commented on Jan 21, 2015

    @CharlieHess
    Contributor

    This sounds similar to the issues @paulcbetts and I are seeing with both process and require.
    /cc #1039, #1028

  2. zcbenz commented on Jan 26, 2015

    @zcbenz
    Contributor

    Fixed by #1044.

  3. christoth commented on Jan 27, 2015

    @christoth
    ContributorAuthor

    @zcbenz I still get the intermittent issue of require, process & module not being defined in the webview javascript env when then nodeintegration is defined using 0.20.8

    Can you re-open this issue? The gist I created should reproduce this issue.

    Thanks

  4. reopened this on Jan 27, 2015
  5. christoth commented on Jan 29, 2015

    @christoth
    ContributorAuthor

    I updated my gist [https://gist.github.com/christoth/d11e03c70a144ba02caa] to log to the console when it starts the preload.js and when the webview content.html JavaScript starts.

    I discovered that with Atom-Shell v0.21 (Win7 x64) the preload.js does not execute when the node-related globals (e.g. require, remote, process, etc...) are not defined in content.html that is loaded in the webview.

  6. christoth commented on Jan 31, 2015

    @christoth
    ContributorAuthor

    @zcbenz After some further investigation it looks like the command line arguments are not being appended in AtomBrowserClient::AppendExtraCommandLineSwitches() when atom-shell spawns a new child process. Specifically, WebViewRendererState::GetInstance()->GetInfo(child_process_id, &info) is not being evaluated to true when the error occurs (webview does not load the preload JS and add the nodeintegration objects to global).

    I will try to investigate further...

  7. anaisbetts commented on Feb 4, 2015

    @anaisbetts
    Contributor

    We hit this pretty frequently, it appears that the preload script doesn't run at all sometimes. Anything we can capture to help debug this?

  8. zcbenz commented on Feb 4, 2015

    @zcbenz
    Contributor

    I just looked into this and as @christoth said it should be caused by the race condition when updating/reading WebViewRendererState.

  9. christoth commented on Feb 5, 2015

    @christoth
    ContributorAuthor

    @zcbenz This fixed it, thanks!

  10. yjfdl123 commented on Feb 24, 2016

    @yjfdl123

    i have the same question,that require and process and global can't be used in webview tag.
    I'm wait'ing the question to be resolved

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions