rubycdp / ferrum

Headless Chrome Ruby API
https://ferrum.rubycdp.com
MIT License
1.71k stars 123 forks source link

Ferrum::DeadBrowserError in Docker container #270

Closed d1rewolf closed 2 years ago

d1rewolf commented 2 years ago

Hello,

I'm using Ferrum to download public data from a particular site. When run via my Macbook, things work perfectly. However, if I run it within a docker container, I get Ferrum::DeadBrowserError.

I don't believe it's a RAM issue, as the container has access to 8GB.

Stacktrace below, and log file attached. I appreciate any guidance you can offer, as this is a blocker for my project but I'm already heavily invested in Ferrum.

Thanks in advance!

Ferrum::DeadBrowserError: Browser is dead or given window is closed /usr/local/bundle/gems/ferrum-0.11/lib/ferrum/browser/client.rb:45:incommand' /usr/local/bundle/gems/ferrum-0.11/lib/ferrum/browser.rb:90:in command' /usr/local/bundle/gems/ferrum-0.11/lib/ferrum/contexts.rb:80:indiscover' /usr/local/bundle/gems/ferrum-0.11/lib/ferrum/contexts.rb:13:in initialize' /usr/local/bundle/gems/ferrum-0.11/lib/ferrum/browser.rb:127:innew' /usr/local/bundle/gems/ferrum-0.11/lib/ferrum/browser.rb:127:in start' /usr/local/bundle/gems/ferrum-0.11/lib/ferrum/browser.rb:63:ininitialize'`

ferrum.log

route commented 2 years ago

https://github.com/rubycdp/ferrum#docker

d1rewolf commented 2 years ago

Yes, I reviewed that and tried before raising the issue here. I apologize...I should have included more information.

The params I'm using:

@browser = Ferrum::Browser.new(logger: File.open("/tmp/ferrum.log", "w+"), save_path: @download_directory, headless: true, timeout: 100, browser_options: { 'no-sandbox': nil })

I am beginning to think this is related to running on an M1 macbook. Even though I've built the docker image for amd64, I'm not certain it's still not related based on Google searches. For example, when I launch Chrome directly, I get:

`# google-chrome --headless --no-sandbox --disable-gpu --remote-debugging-port=9222 --disable-software-rasterizer https://www.chromestatus.com

qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped [0527/180248.534031:ERROR:bus.cc(398)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory [0527/180248.540168:ERROR:bus.cc(398)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory [0527/180248.548037:ERROR:file_path_watcher_inotify.cc(329)] inotify_init() failed: Function not implemented (38)

DevTools listening on ws://127.0.0.1:9222/devtools/browser/8be632b4-a4f7-4d83-a87f-d274a456d01f qemu: unknown option 'type=utility' [0527/180248.695541:WARNING:bluez_dbus_manager.cc(248)] Floss manager not present, cannot set Floss enable/disable. [0527/180248.701542:ERROR:gpu_process_host.cc(967)] GPU process launch failed: error_code=1002 [0527/180248.701663:WARNING:gpu_process_host.cc(1273)] The GPU process has crashed 1 time(s) [0527/180248.751667:ERROR:network_service_instance_impl.cc(470)] Network service crashed, restarting service. qemu: unknown option 'type=utility' [0527/180248.901845:ERROR:gpu_process_host.cc(967)] GPU process launch failed: error_code=1002 [0527/180248.901931:WARNING:gpu_process_host.cc(1273)] The GPU process has crashed 2 time(s) [0527/180248.910490:ERROR:network_service_instance_impl.cc(470)] Network service crashed, restarting service. qemu: unknown option 'type=utility' [0527/180248.951908:ERROR:gpu_process_host.cc(967)] GPU process launch failed: error_code=1002 [0527/180248.952035:WARNING:gpu_process_host.cc(1273)] The GPU process has crashed 3 time(s) [0527/180248.952132:FATAL:gpu_data_manager_impl_private.cc(450)] GPU process isn't usable. Goodbye. [0527/180248.954588:ERROR:scoped_ptrace_attach.cc(27)] ptrace: Function not implemented (38) qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped Trace/breakpoint trap`

route commented 2 years ago

Try to build a container and run Chrome inside manually, this will help to triage the issue. For Ferrum the only thing needed is the link I provided.