New frame control functionality examples

454 views
Skip to first unread message

p...@ciklum.com

unread,
Jul 4, 2018, 5:12:51 AM7/4/18
to headless-dev
Hi!

I am wondering whether there are some examples or use cases (on NodeJS) on how to use HeadlessExperimental.beginFrame and Target in order to control screenshots rate? Because from the documentation it is not really clear how to use them. 

p...@ciklum.com

unread,
Jul 4, 2018, 8:55:50 AM7/4/18
to headless-dev, p...@ciklum.com
If to be concrete currently we initialize Target:
 
 let logLine = '[NodeJS: Connecting to chrome...]';
        request
.post('http://127.0.0.1:40000/videoCapture/log/'+ jobId, {json: logLine});
        client
= await CDP('ws://localhost:9222/devtools/browser');

       
const {Target} = client;
       
const {browserContextId} = await Target.createBrowserContext();

       
const {targetId} = await Target.createTarget({
            url
: url,
            width
: viewportWidth,
            height
: viewportHeight,
            enableBeginFrameControl
: true
       
});

        client
= await CDP({target: targetId});
/* ... */
 await
Emulation.setDeviceMetricsOverride(deviceMetrics);
        await
Emulation.setVisibleSize({
            width
: viewportWidth,
            height
: viewportHeight
       
});

await
Page.navigate({url});
await
Page.loadEventFired();

  await
HeadlessExperimental.enable();
        await
HeadlessExperimental.needsBeginFramesChanged();

and the script halts on needsBeginFramesChanged event.

Eric Seckler

unread,
Jul 10, 2018, 2:50:46 AM7/10/18
to p...@ciklum.com, headless-dev
There's a doc about the concepts behind it on https://bit.ly/headless-rendering. Apart from that, I'd recommend looking at the test cases here: 


Ciklum refers to one or more of Ciklum Group Holdings LTD. and its subsidiaries and affiliates each of which is a legally separate entity. Ciklum LLC is a limited liability company registered in Ukraine under EDRPOU code 31902643, with its registered address at 12 Amosova St., 03680, Kyiv, Ukraine.

The contents of this e-mail (including any attachments) are confidential and may be legally privileged. If you are not the intended recipient of this e-mail, please notify the sender immediately and then delete it (including any attachments) from all your systems. Any unauthorised use, reproduction, distribution, disclosure and/or modification of this message and/or its contents are strictly prohibited. We cannot guarantee that this e-mail is secure or error-free. Ciklum cannot be held liable for any loss or damage caused by software viruses or resulting from any use of or reliance on this email by anyone, other than the intended addressee to the extent agreed in a contract for the matter to which this email relates (if any). Messages sent to and from Ciklum may be monitored; by replying to this e-mail you give your consent to such monitoring. Notice: we do not accept service by e-mail of court proceedings, other processes or formal notices of any kind without specific prior written agreement. This email does not constitute a binding offer or acceptance for Ciklum unless so set forth in a separate document.

--
You received this message because you are subscribed to the Google Groups "headless-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to headless-dev...@chromium.org.
To post to this group, send email to headle...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/headless-dev/2b7084b1-62ba-4064-96f5-6b8e321571ed%40chromium.org.

Eric Seckler

unread,
Jul 10, 2018, 2:54:29 AM7/10/18
to p...@ciklum.com, headless-dev
In particular, the beginFrame command requires a few additional command line flags (see the doc / tests) and only works in --headless mode.

p...@ciklum.com

unread,
Jul 12, 2018, 4:51:44 AM7/12/18
to headless-dev, p...@ciklum.com
Yes, we have also used all additional recommended flags for starting chrome from the "Rendering in Headless Chrome" doc:

--enable-surface-synchronization

   --run-all-compositor-stages-before-draw

   --disable-threaded-animation

   --disable-threaded-scrolling

   --disable-checker-imaging


When we are not setting enableBeginFrameControl: true page is loaded and we can see it rendered in debug, but if the flag is set then page doesn't load, maybe we are not firing some event?

Eric Seckler

unread,
Jul 16, 2018, 2:30:51 AM7/16/18
to p...@ciklum.com, headless-dev
Only thing I can think of is that you're somehow missing the initial HeadlessExperimental.needsBeginFramesChanged event. It may be sent before the Headless.enable command completes. Try setting an async event handler for it before sending Headless.enable?

Reply all
Reply to author
Forward
0 new messages