Lighthouse: Crashes on Docker with emulated-form-factor=desktop

Created on 16 Jun 2019  ·  13Comments  ·  Source: GoogleChrome/lighthouse

Provide the steps to reproduce

  1. Use this Dockerfile
  2. Run LH with --emulated-form-factor=desktop and "heavy js page" like amazon.fr

Dockerfile:

FROM node:12.4-alpine

RUN apk add --update --no-cache chromium && rm -rf /var/cache/apk/*

docker-compose.yml

version: '3.5'

services:

  lh:
    build:
      context: ./docker/nodejs
    tty: true
    working_dir: /app
    volumes:
      - ./:/app

Note:

  • Same issue on many Dockerfiles (node:10*-alpine, node:10-slim, node:12-slim), using chromium or chrome...
  • No crash on my computer: Node 12 on Debien Stretch

What is the current behavior?

Inside docker shell:

./node_modules/.bin/lighthouse --emulated-form-factor=desktop --chrome-flags="--no-sandbox --headless --disable-gpu" https://www.amazon.fr/
  ChromeLauncher Waiting for browser. +0ms
  ChromeLauncher Waiting for browser... +0ms
  ChromeLauncher Waiting for browser..... +506ms
  ChromeLauncher Waiting for browser.....✓ +4ms
  status Connecting to browser +88ms
  status Resetting state with about:blank +11ms
  status Benchmarking machine +36ms
  status Initializing… +506ms
  status Resetting state with about:blank +32ms
  status Setting up network for the pass trace +35ms
  status Cleaning browser cache +2ms
  status Beginning devtoolsLog and trace +12ms
  status Loading page & waiting for onload CSSUsage, ViewportDimensions, RuntimeExceptions, ConsoleMessages, AnchorElements, ImageElements, LinkElements, MetaElements, ScriptElements, AppCacheManifest, Doctype, DOMStats, OptimizedImages, PasswordInputsWithPreventedPaste, ResponseCompression, TagsBlockingFirstPaint, FontSize, EmbeddedContent, RobotsTxt, TapTargets, Accessibility +3ms
  Driver:warn Timed out waiting for page load. Checking if page is hung... +45s
  Driver:warn Page appears to be hung, killing JavaScript... +1s
  status Disconnecting from browser... +30s
  ChromeLauncher Killing Chrome instance 416 +8ms
Runtime error encountered: Waiting for DevTools protocol response has exceeded the allotted time. (Method: Emulation.setScriptExecutionDisabled)
LHError: PROTOCOL_TIMEOUT
    at Timeout._onTimeout (/usr/local/lib/node_modules/lighthouse/lighthouse-core/gather/driver.js:399:21)
    at listOnTimeout (internal/timers.js:531:17)
    at processTimers (internal/timers.js:475:7)

What is the expected behavior?

No crashes with --emulated-form-factor=mobile

Environment Information

  • Lighthouse version: 4.0/4.1
  • Node.js version: 10/12.1/12.4
  • Operating System: Debian Stretch with Docker 18.09.1
P3 needs-investigation

Most helpful comment

I was unable to reproduce this issue with https://github.com/GoogleChrome/lighthouse/issues/9212#issuecomment-607276050 or --disable-dev-shm-usage so we'll consider that the solution here 👍

All 13 comments

Howdy chief! Appreciate you filing this bug. :clap:

We think this is the same root issue as #6512. So, we'll automatically mark this as a duplicate. Thanks!
:robot: Beep beep boop.

Howdy chief! Appreciate you filing this bug. :clap:

We think this is the same root issue as #6512. So, we'll automatically mark this as a duplicate. Thanks!
:robot: Beep beep boop.

bot, i outrank you

TY @connorjclark :+1:

Thanks for filing @HanXHX! That error indicates that Chrome is hanging while loading the desktop version of https://www.amazon.fr/ when the following Chrome flags are used --no-sandbox --headless --disable-gpu. There's not really a workaround on our side that could be done.

Are you able to verify that loading that page with those flags works when Lighthouse is not involved?

@patrickhulce

/app # chromium-browser --no-sandbox --headless --disable-gpu --dump-dom https://www.amazon.fr | head
[0618/043258.807827:WARNING:dns_config_service_posix.cc(334)] Failed to read DnsConfig.
[0618/043258.855746:ERROR:gl_implementation.cc(281)] Failed to load /usr/lib/chromium/swiftshader/libGLESv2.so: Error loading shared library /usr/lib/chromium/swiftshader/libGLESv2.so: No such file or directory
[0618/043258.856754:ERROR:viz_main_impl.cc(184)] Exiting GPU process due to errors during initialization
libpng warning: iCCP: extra compressed data
libpng warning: iCCP: extra compressed data
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
<!DOCTYPE html>
<html lang="fr-fr" class=" a-js a-audio a-video a-canvas a-svg a-drag-drop a-geolocation a-history a-webworker a-autofocus a-input-placeholder a-textarea-placeholder a-local-storage a-gradients a-transform3d a-touch-scrolling a-text-shadow a-text-stroke a-box-shadow a-border-radius a-border-image a-opacity a-transform a-transition a-ember" data-19ax5a9jf="dingo" data-aui-build-date="3.19.3-2019-06-04" data-useragent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/72.0.3626.121 Safari/537.36" data-platform="Linux x86_64"><!-- sp:feature:head-start --><head><script async="" src="https://m.media-amazon.com/images/G/01/csm/showads.v2.js" crossorigin="anonymous"></script><script async="" src="https://images-eu.ssl-images-amazon.com/images/G/01/AUIClients/ClientSideMetricsAUIJavascript@jserrorsForester.10f2559e93ec589d92509318a7e2acbac74c343a._V2_.js" crossorigin="anonymous"></script><script>var aPageStart = (new Date()).getTime();</script><meta charset="utf-8">
<script type="text/javascript">var ue_t0=ue_t0||+new Date();</script><!-- sp:feature:cs-optimization -->
<meta http-equiv="x-dns-prefetch-control" content="on"><link rel="dns-prefetch" href="//images-eu.ssl-images-amazon.com"><link rel="dns-prefetch" href="//m.media-amazon.com"><link rel="dns-prefetch" href="//completion.amazon.com"><script type="text/javascript">
window.ue_ihb = (window.ue_ihb || window.ueinit || 0) + 1;
if (window.ue_ihb === 1) {

var ue_csm = window,
    ue_hob = +new Date();
(function(d){var e=d.ue=d.ue||{},f=Date.now||function(){return+new Date};e.d=function(b){return f()-(b?0:d.ue_t0)};e.stub=function(b,a){if(!b[a]){var c=[];b[a]=function(){c.push([c.slice.call(arguments),e.d(),d.ue_id])};b[a].replay=function(b){for(var a;a=c.shift();)b(a[0],a[1],a[2])};b[a].isStub=1}};e.exec=function(b,a){return function(){if(1==window.ueinit)try{return b.apply(this,arguments)}catch(c){ueLogError(c,{attribution:a||"undefined",logLevel:"WARN"})}}}})(ue_csm);
[0618/043300.454985:WARNING:spdy_session.cc(3178)] Received HEADERS for invalid stream 15
.........

Thanks @HanXHX! Unfortunately, that doesn't validate that Chrome isn't hanging here. In the Lighthouse case it's getting that same initial DOM payload as well it's just that Chrome gets stuck in some CPU loop that prevents Lighthouse from continuing and even the recovery commands aren't getting a response.

Does the output of top seem to indicate something similar to this happening without Lighthouse involved?

@patrickhulce I can't see any problem without LH. The command chromium-browser --no-sandbox --headless --disable-gpu --dump-dom https://www.amazon.fr passes on ~ 1.5 sec

Any updates on this?

I've had the same issue and found a workaround.
Apparently, chrome relies on shared memory which is mounted on /dev/shm, my alpine image default partition has only 64mb, so I had to mount it to a host volume: added the following to my docker-compose file:

services:
  lighthouse:
    volumes:
      - lighthouse-shm:/dev/shm
...
volumes:
  siteanalysis-dashboard-data:

After the volume is mounted, lighthouse completes normally.

I've had the same issue and found a workaround.
Apparently, chrome relies on shared memory which is mounted on /dev/shm, my alpine image default partition has only 64mb, so I had to mount it to a host volume: added the following to my docker-compose file:

services:
  lighthouse:
    volumes:
      - lighthouse-shm:/dev/shm
...
volumes:
  siteanalysis-dashboard-data:

After the volume is mounted, lighthouse completes normally.

It works perfect. Thanks !!

Chrome has a --disable-dev-shm-usage option. lighthouse --chrome-flags="--disable-dev-shm-usage" xxx

See https://developers.google.com/web/tools/puppeteer/troubleshooting#tips

I was unable to reproduce this issue with https://github.com/GoogleChrome/lighthouse/issues/9212#issuecomment-607276050 or --disable-dev-shm-usage so we'll consider that the solution here 👍

Was this page helpful?
0 / 5 - 0 ratings