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

PageNavigation constructor: 2 seconds delay BEFORE sending the Page.navigate message to the browser #646

Open
nevez opened this issue Aug 9, 2024 · 1 comment

Comments

@nevez
Copy link

nevez commented Aug 9, 2024

Hello,

I'm using chrome-php 1.11.0 with "keepAlive" to generate quite a lot of PDFs, the performance I get is a bit on the slow side (2 seconds to navigate to the page, while if I open the page on the browser directly it gets loaded in .2 secs).

So I investigated a bit and found that 99% of the navigation time is spent before even sending the "Page.navigate" message to the browser, it is spent on this line of PageNavigation.php, inside its __construct() method:

        // make sure latest loaderId was pulled
        $page->getSession()->getConnection()->readData();

That readData() triggers an fread() on the socket that lasts almost 1.9 seconds, and returns these bytes (this is only the first part):

......{"method":"Page.lifecycleEvent","params":{"frameId":"4D165D5C6D26BE5D7D19194C6AD3BC43","loaderId":"D14903F279C2FA2B3C7B35E5687F62A1","name":"networkAlm

hexdump of the received buffer: 817e00e97b226d6574686f64223a22506167652e6c6966656379636c654576656e74222c22706172616d73223a7b226672616d654964223a223444313635443543364432364245354437443139313934

Is this kind of delay normal? Is it a problem of chrome responding slowly or the way Wrench handles sockets? Is there anything I can do in terms of chrome command line options or in the way I use chrome-php to reduce this fixed ~2 sec pre-delay?

Thank you

@nevez
Copy link
Author

nevez commented Aug 23, 2024

Has anybody else measured with microtime() the execution time of that line of PageNavigation.php? Do you see the same ~2 seconds delay I see?

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

No branches or pull requests

1 participant