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

Uncaught RuntimeException: Chrome process stopped before startup completed. #261

Closed
proconsult-ti opened this issue Sep 27, 2021 · 6 comments

Comments

@proconsult-ti
Copy link

I tried to solve this problem but I can't find a solution. I'm getting this issue but without any further information. I activated the suggested debug options but it doesn't make any difference since the error happens in the first line of code.

Error:
Fatal error: Uncaught RuntimeException: Chrome process stopped before startup completed. in D:\manual1_dev\Assistec\vendor\chrome-php\chrome\src\Browser\BrowserProcess.php:400 Stack trace: #0 D:\manual1_dev\Assistec\vendor\chrome-php\chrome\src\Utils.php(57): HeadlessChromium\Browser\BrowserProcess->HeadlessChromium\Browser{closure}(Object(Symfony\Component\Process\Process)) #1 D:\manual1_dev\Assistec\vendor\chrome-php\chrome\src\Browser\BrowserProcess.php(437): HeadlessChromium\Utils::tryWithTimeout(30000000, Object(Generator)) #2 D:\manual1_dev\Assistec\vendor\chrome-php\chrome\src\Browser\BrowserProcess.php(139): HeadlessChromium\Browser\BrowserProcess->waitForStartup(Object(Symfony\Component\Process\Process), 30000000) #3 D:\manual1_dev\Assistec\vendor\chrome-php\chrome\src\BrowserFactory.php(67): HeadlessChromium\Browser\BrowserProcess->start('C:\Program File...', Array) #4 D:\manual1_dev\Assistec\services\TicketDownloadService.php(278): HeadlessChromium\BrowserFactory->createBrowser(Array) #5 D:\manual1_dev in D:\manual1_dev\Assistec\vendor\chrome-php\chrome\src\Browser\BrowserProcess.php on line 400

@enricodias
Copy link
Member

If you remove the headless option in the options, can you see the chrome window appear during the execution? And can you paste the debug output here?

The debug info isn't displayed in a page, it's sent to the terminal.

@proconsult-ti
Copy link
Author

About the debug information it is simply not being generated. I'm using Monolog and in the version of my local machine, the logs are generated normally, but in this version that is giving an error, nothing is generated... apparently it doesn't even reach the "browserFactory->createBrowser(['debugLogger' => monologInstance] )".

About the headless option I'll check it tomorrow as it's a machine that I don't have direct access to, but I'm afraid it will fall into the same problem as the debug.

My code:

$log = new Logger("chrome_php");
$logPath = __DIR__ . "/../logs/chrome_php.log";
$log->pushHandler(new StreamHandler($logPath));

$browserFactory = new BrowserFactory(); // seems to stop here
$browser = $browserFactory->createBrowser([
    'headless' => false,
    'debugLogger' => $log
]);
try {
    $page = $browser->createPage();
    $pdfOptions = [ 'printBackground' => true ];
    // stuff
    $page->navigate($url)->waitForNavigation(Page::DOM_CONTENT_LOADED);
    $page->pdf($pdfOptions)->saveToFile($output);
} catch (Exception $e) {
    $response['error'] = "Exception on Chrome-php: " . $e->getMessage();
} finally {
    $browser->close();
}

@proconsult-ti
Copy link
Author

Here is the generated log:
[2021-09-28T08:12:10.717276-03:00] chrome_php.DEBUG: process: initializing [] []
[2021-09-28T08:12:10.730863-03:00] chrome_php.DEBUG: process: using directory: C:\Windows\Temp\chr5A3C.tmp [] []
[2021-09-28T08:12:10.738759-03:00] chrome_php.DEBUG: process: starting process: "C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=0 --disable-background-networking --disable-background-timer-throttling --disable-client-side-phishing-detection --disable-default-apps --disable-extensions --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --disable-translate --metrics-recording-only --no-first-run --safebrowsing-disable-auto-update --enable-automation --password-store=basic --use-mock-keychain --headless --disable-gpu --font-render-hinting=none --hide-scrollbars --mute-audio --user-data-dir=C:\Windows\Temp\chr5A3C.tmp [] []
[2021-09-28T08:12:10.755276-03:00] chrome_php.DEBUG: process: waiting for 30 seconds for startup [] []
[2021-09-28T08:12:10.776049-03:00] chrome_php.DEBUG: process: ✗ chrome process stopped [] []
[2021-09-28T08:12:10.785035-03:00] chrome_php.DEBUG: process: killing chrome [] []
[2021-09-28T08:12:10.785091-03:00] chrome_php.DEBUG: process: cleaning temporary resources:C:\Windows\Temp\chr5A3C.tmp [] []

I tried using the connectionDelay and noSandbox options, but they did the same thing. The browser also doesn't seem to be opening with headless as false.
I think I will have to switch to MPDF.

@enricodias
Copy link
Member

Your chrome is just stopping shortly after starting.

What happens if you try to execute C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=0 --disable-background-networking --disable-background-timer-throttling --disable-client-side-phishing-detection --disable-default-apps --disable-extensions --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --disable-translate --metrics-recording-only --no-first-run --safebrowsing-disable-auto-update --enable-automation --password-store=basic --use-mock-keychain --disable-gpu --font-render-hinting=none --hide-scrollbars --mute-audio --user-data-dir=C:\Windows\Temp\chr5A3C.tmp manually? (I removed the --headless option.

@proconsult-ti
Copy link
Author

Running your command opens chrome normally.
At this point I don't know if this has something with the PHP script running on a Windows server with IIS and for some reason it's being blocked

@proconsult-ti
Copy link
Author

Unfortunately I couldn't make it work through chrome-php and decided to make a separate script via command line with chrome. Thanks for trying to help

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

2 participants