Solving The ERROR:gpu_process_transport_factory.cc(1007)-Lost UI shared context : with Chrome browser and ChromeDriver in Headless mode

ERROR:gpu_process_transport_factory.cc(1007)-Lost UI shared context : with Chrome browser and ChromeDriver in Headless mode is an error which occurs because of a chromium bug.

This post is my attempt to explain to you why this error occurs and how you can solve it, I will also include multiple solutions that could be considered as alternative fixes to the error.

Exploring the Error : ERROR:gpu_process_transport_factory.cc(1007)-Lost UI shared context : with Chrome browser and ChromeDriver in Headless mode

First of all, this error could happen to anyone running headless chrome.

The error message bellow should be very close to the error message you get.

                                                                       #
ERROR:gpu_process_transport_factory.cc(1007)] Lost UI shared context.
                                                                       #

To solve the problem above, I have a couple of solutions which have worked for me, bellow is a detailed explanation of the solutions.

Solution 1 : ignore the error

The first solution is the simplest, since this error doesn’t impact your ability to run your code, you can just ignore the error.

The error gpu_process_transport_factory.cc(1007)-Lost UI shared context happens because chromium skips GPU data collection in Headless Mode.

Previously, running the line of code bellow was enough but now that solution does not work.

                                                                       #
--disable-gpu \                # on Windows.
                                                                       #

So, the solution of ignoring the erro is not bad at all. If you do not like this suggestion try the fix bellow.

Solution 2 : Add Chrome driver options

The second solution is to use Chrome driver options.

You can add the flags bellow and that should be enough.

                                                                       #
options.add_arguments("--proxy-server='direct://'");
options.add_arguments("--proxy-bypass-list=*");
                                                                       #

I hope the commands above fixed your problem, good luck with the scripts to come.

Summing-up

Friends, I hope this article was helpful and help you in any way, shape or form, the first solution worked for me and also the third, depending on your case the solution could be different, just keep trying and do not give up, keep coding, cheers.

If you want to learn more about Python, please check out the Python Documentation : https://docs.python.org/3/