0

I render the javascript behaviour of a page by phantomJS with a code like

var page = require('webpage').create();
page.viewportSize = { width: 1920, height: 1080 };
page.open('index.html', function(){
    (function snap(i){
        if(i < 5000){
            window.setTimeout(function(){
                page.render('i+'.png');
                snap(++i);
            }, 20);
        }
        else{
            phantom.exit();
        }
    })(0);
});

The problem is when rendering at high resolution, the CPU is heavily used and thus the javascript performance becomes slower. For example, if a javascript action takes 100s, it will take 500s under a heavy load. Thus, the captured images are only for 1/5 of the javascript scenario.

Is it possible to guarantee that the javascript events is finished in the original timeframe? Or render the javascript according to the original timeframe rather than the occuring timeframe?

1 Answer 1

1

Is it possible to guarantee that the javascript events is finished in the original timeframe?

No, that's not possible because there is no concept of "original timeframe".

All you need to do instead is speed up your capability for capturing. You'll have to abandon PhantomJS for this. Fortunately, Chromium itself has a very nice tab capture API which can capture video in realtime.

Sign up to request clarification or add additional context in comments.

1 Comment

Chromium itself has tab capture API which can capture video in realtime citation needed :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.