ERROR:gpu_process_transport_factory.cc(1007)-Lost UI shared context : while initializing Chrome browser through ChromeDriver in Headless mode

19,820

When Headless Chrome was first released as GA (General Availability) by Google Team the article Getting Started with Headless Chrome mentioned that :

--disable-gpu \                # Temporarily needed if running on Windows.

A note was added as :

Right now, you'll also want to include the --disable-gpu flag if you're running on Windows.

As per the discussion Headless: make --disable-gpu flag unnecessary it was clear that :

The --disable-gpu flag is no longer necessary on Linux or Mac OSX. It will also become unnecessary on Windows as soon as the bug SwiftShader fails an assert on Windows in headless mode is fixed.

What happened under the hood?

As per the discussion headless: Switch from osmesa to SwiftShader as Google/Chromium team decided to ship SwiftShader with Chrome the team thought to start using it to render GL content in Headless Mode. This required a couple of changes as follows :

  • Skip GPU data collection in Headless Mode since SwiftShader isn't considered a software implementation by that code which lead to a failure when we tried to retrieve information from the Window System.
  • Only skip GL initialization in InitializeStaticEGLInternal if we intend to use osmesa. SwiftShader requires initialization like the other non-software implementations.
  • SwiftShader is currently not supported on Mac OSX, so the team decided to continue to use the physical GPU in Headless Mode on that platform (unlike on other platforms where everything is software rendered).
  • So, to disable WebGL support in Headless Mode they decided to use --disable-gpu and --disable-software-rasterizer

The idea to Support WebGL in headless is still under discussion but SwiftShader fails an assert on Windows in headless mode with an error as :

[0117/125830.649194:ERROR:gpu_process_transport_factory.cc(1043)] Lost UI shared context.
DevTools listening on ws://127.0.0.1:37429/devtools/browser/1f0b2bf7-dfdd-44ac-9da7-f2659d352f0d

Conclusion

This error doesn't impact your @Test and you can ignore the error for the time being.

Share:
19,820
Admin
Author by

Admin

Updated on July 01, 2022

Comments

  • Admin
    Admin almost 2 years

    I am getting this error when I attempt to run code on 2 of 3 computers:

    [0502/155335.565:ERROR:gpu_process_transport_factory.cc(1007)] Lost UI shared context.
    

    Here is the code:

    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    import os
    
    chrome_options = Options()
    chrome_options.add_argument("--headless")
    chrome_options.add_argument("--disable-gpu")
    chrome_options.add_argument("--window-size=1920x1080")
    
    chrome_driver = os.getcwd() + "\\chromedriver.exe"
    print "chrome driver:" + chrome_driver
    
    driver = webdriver.Chrome(chrome_options=chrome_options, 
    executable_path=chrome_driver)
    
    driver.get("http://www.google.com")
    
    luck_button = driver.find_element_by_css_selector("[name=btnI")
    luck_button.click()
    
    driver.get_screenshot_as_file("capture.png")
    

    Now I have checked all of the systems, they are running windows 10 64-bit, google chrome 64 bit Version: 66.0.3359.139, python 2.7 32-bit, chromedriver.exe 32-bit, pycharm 2018.1.1

    funny thing is if I run this without the headless options then everything works. The browser pops up, the I'm feeling lucky button is pressed, and a screen shot is taken. Only if I add in the headless bit does this error occur.

    I am not sure what could be different on 1 system that would allow this to work when the other systems are running the same software.

  • xbmono
    xbmono over 5 years
    We are using ember exam to run our tests and it stops completely because of this error. Is there any workaround to fix this
  • undetected Selenium
    undetected Selenium over 5 years
    @xbmono Won't be able to comment on ember exam without the relevant html, code trials and error stack trace. However as per the documentation from Chromium Team the error Lost UI shared context looks harmless and is quite easily reproducible on Windows10 OS which is not a blocker issue.
  • xbmono
    xbmono over 5 years
    It may not be blocker in Win but we are using Debian and Jenkins Pipeline. All of our tests fail and stops because of this issue. We now have decided to temporarily disable tests which is not good
  • xbmono
    xbmono over 5 years
    I have these settings: module.exports = { "test_page": "tests/index.html?hidepassed", "disable_watching": true, "parallel": 6, "launch_in_ci": [ "Chrome" ], "launch_in_dev": [ "Chrome" ], "browser_start_timeout": 80, "browser_args": { "Chrome": [ '--no-sandbox', '--disable-gpu', '--headless', '--window-size=1440,900' ] } };
  • undetected Selenium
    undetected Selenium over 5 years
    @xbmono As you are using Debian, --disable-gpu is not a desired parameter. See the discussion Lost UI Shared Context Error - Running protractor tests in headless chrome
  • nights
    nights about 5 years
    I'm getting this without the --disable-gpu flag