-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Nightmare freezes on either evaluate() or screenshot() #736
Comments
Silly question: have you tried running with |
(Also: Possibly related to #405.) |
Yeah, I run it with DEBUG=*, it outputs 2 lines indicating the initialization of Nightmare, but then I stop getting output from that debug path for the remainder of the program. |
Since the initial implementation of `FrameManager`, Electron added an API for Chromium's remote debugging protocol. One of the debugger's capabilities is to visually highlight a portion of the page. This change uses that functionality to force a new frame to be rendered. This is much more reliable than the way Nightmare currently tries to force new frames to render by fiddling around with the DOM (see issues segment-boneyard#555, segment-boneyard#736, segment-boneyard#809). It also has the benefit of not doing anything page content can observe, ensuring that any JS or CSS won't modify the page in response to Nightmare's attempt to take a screenshot. In future versions of the protocol, it will be possible to directly capture an image of the page, but that feature is still experimental (so it could be removed) and Electron does not yet support it anyhow. Something to keep in mind for future changes, though. This is an alternative solution to the one in 53dee8a (currently on the `screenshot-with-offscreen-rendering` branch). That method (using Electron's new "offscreen" rendering mode) is *much* faster than this and vastly simplifies the code, but has more ways it can fail.
Sometime mid-year, Electron added support for "offscreen" rendering (it still shows a window, but the whole rendering pipeline is a bit different). When this mode is enabled, the rendered view can be explicitly invalidated, which is *much* better and more reliable than the way Nightmare currently tries to force new frames to render by fiddling around with the DOM (see issues segment-boneyard#555, segment-boneyard#736, segment-boneyard#809). This isn't without its downsides; it doesn't work with forced device scale factors and it renders differently than with native system rendering (e.g. text rendering will be slightly different).
Considering this fixed with #927. If you're still having this problem with that change, feel free to reopen. |
I am working on moving from Phantom JS to Nightmare in an effort to get more CSS compatibility on my pages.
As a high-level view, my Nightmare instance lives inside a Docker container and listens for data to be pushed onto a queue. Once that data is pushed, I pull some data (including a string of HTML) out of the queue, alter the page a bit using Cheerio, and then turn the data into a HTML Data URL.
Then, I goto the data url, use a couple of evaluate functions, scroll the page, and take a screenshot.
Here is a condensed version of my code:
However, my script will occasionally lock up during various evaluate functions, or during the screenshot function. Other times, the script runs successfully. I have tried this on various websites with the same results.
I can't pinpoint anything in the script that is causing this issue, and I didn't know if any of you had any thoughts on the problem?
The text was updated successfully, but these errors were encountered: