skip to Main Content

I’ve been using HeadlessChromium in my PHP project on Ubuntu Server 23.10. Until recently, this worked to set up a new browser:

$browserFactory = new HeadlessChromiumBrowserFactory();
$browser = $browserFactory->createBrowser
(
    [
        'windowSize' => [1024, 768],
        'debugLogger' => 'php://stderr',
    ]
);

Today I upgraded Chrome to version 128.0.6613.84

The above code started giving this error:

PHP message: RuntimeException: Chrome process stopped before startup completed. Additional info: mkdir: cannot create directory ‘/var/www/.local’: Permission denied

So I created /var/www/.local and set its owner to www-data. Now I get this error:

PHP message: RuntimeException: Chrome process stopped before startup completed. Additional info: chrome_crashpad_handler: –database is required

I’ve tried adding a few more options to no avail:

$browser = $browserFactory->createBrowser
(
    [
        'windowSize' => [1024, 768],
        'debugLogger' => 'php://stderr',
        'args' =>
        [
            '--no-crashpad',
            '--disable-dev-shm-usage',
            '--disable-gpu',
            '--headless',
            '--disable-software-rasterizer',
            '--no-sandbox',
        ],
    ]
);

As far a I can tell the ‘args’ array has no effect.

2

Answers


  1. Chosen as BEST ANSWER

    The problem, as identified by @MartinZeitler is that there are directories missing from the www-data home directory. This solved the problem on my server (Ubuntu 23.10):

    sudo mkdir ~www-data/.local ~www-data/.config ~www-data/.cache ~www-data/.pki && sudo chown www-data:www-data ~www-data/.local ~www-data/.config ~www-data/.cache ~www-data/.pki
    

    In my case, the www-data home directory is /var/www


  2. Mine issue was fixed by adding environment variables XDG_CONFIG_HOME and XDG_CACHE_HOME:

    $browser = $browserFactory->createBrowser
    (
        [
            'envVariables' => [
                'XDG_CONFIG_HOME'=>'/tmp/.chromium',
                'XDG_CACHE_HOME'=>'/tmp/.chromium',
            ]
        ]
    );
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search