Skip to content
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

Hangs with Jest run #7

Open
dennismphil opened this issue Sep 14, 2019 · 12 comments
Open

Hangs with Jest run #7

dennismphil opened this issue Sep 14, 2019 · 12 comments

Comments

@dennismphil
Copy link

dennismphil commented Sep 14, 2019

When I attempted to integrate this with Jest using TAIKO_PLUGIN=screencast jest it seemed to hang.

This is a very useful and powerful feature, especially during test runs headlessly.

Thank you for the hard work and the beautiful API ❤️

@shubhamsc
Copy link
Contributor

shubhamsc commented Sep 16, 2019

@dennismphil Thanks for reporting,
I can replicate this issue with this example while running with jest.

const { openBrowser, closeBrowser, goto, click, screencast, text } = require('taiko');

describe('taiko screencast', () => {
    beforeAll(async () => {
        await openBrowser();
        await screencast.startScreencast('output.gif');
    })

    afterAll(async () => {
        await screencast.stopScreencast();
        await closeBrowser();
    })

    test('test for screencast', async () => {
        await goto('gauge.org');
        await click('Plugins');
        expect(await text('Language Runners').exists()).toBeTruthy();
    });
});

Tests are hanged on stopScreencast. we will look on it soon.

@dennismphil dennismphil changed the title Jest integration and example Hangs with Jest run Sep 16, 2019
@negiDharmendra negiDharmendra self-assigned this Sep 17, 2019
@negiDharmendra negiDharmendra removed their assignment Sep 25, 2019
@negiDharmendra
Copy link
Contributor

I have tried debugging this issue and found out that it takes a lot of time to generate gif file with jest where as works fine with mocha and plain Taiko script.
For the given sample script in the previous comment it takes around 3 minutes.

Could not find any reason why it takes more time with jest.

@dennismphil
Copy link
Author

Instrumented some of the taiko code with console logs while running.

Screen Shot 2019-09-25 at 4 19 07 PM

This is where it seems like stalling for me. Gave it 15 mins it still remains there.

@BugDiver
Copy link
Member

BugDiver commented Oct 1, 2019

Did some more debugging and found out that, The . GifEncoder packages tries to learn the color palate for every frame and alter them accordingly. Which is taking a lot of time with jest.
Could not figure out why it take more time only with jest, work fine with mocha.
Maybe we can look for alternative GifEncoders.

@librehat
Copy link

Any updates on this one please?

@sriv
Copy link
Contributor

sriv commented Feb 19, 2020

Not yet, we have been busy with other things. It might be some time till we get to this, since we have our hands full at the moment.

That said, we would appreciate any help, and would gladly accept Pull Requests!

@dennismphil
Copy link
Author

dennismphil commented Mar 10, 2020

Got a chance to debug this more. Yes, this completed after a really really really long time.

Eg: 47 frames; device height=1250; device width: 1200; => takes a long time and finally completes.

The encoder addFrame is where it takes most time. ~30s per frame.

Suggestion

Short term fix

skip few frames (eg use a logarithmic scale for i in the loop of adding frame) or limit the device width and height could be easy fixes.

Long term fix:

Consider switching to a more efficient encoder.

@sriv
Copy link
Contributor

sriv commented Mar 11, 2020

The thing with skipping frames is that the plugin has no way of telling if it's skipping an important frame.

gif-encoder-2 claims some improvements, and at first glance it looks like a drop-in replacement.

That being said, I wonder why would this bother only jest, and not other runners.

@spinningarrow
Copy link

Any reason why it emits a gif and not an m4v or something like that? My understanding is those are more compact and efficient (could be wrong though!)

@sriv
Copy link
Contributor

sriv commented Mar 11, 2020

Any reason why it emits a gif and not an m4v

gif, primarily because it is html/browser friendly. but one could argue that modern browsers allow videos to be embedded too. Perhaps we can have it configurable.

Really depends on what works best for users. We do not use this much :P

@librehat
Copy link

Any modern browsers should be able to handle video files just fine, adding the good things that you can control the progress bar and play/pause

@sriv
Copy link
Contributor

sriv commented Mar 12, 2020

Any modern browsers should be able to handle video files just fine

That is true. Anybody interested in taking a stab at this? I believe it shouldn't be too hard to wire up something like ffmpeg and dump the output as a movie?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants