Open vkatsikaros opened 8 years ago
Sending a term signal to geckodriver does not terminate the spawned firefox instance, if Delete Session has not been issued before:
I use the script (1)
Launch geckodriver, and send no delete session command. The firefox process is leftover in the end:
% perl firefox_launch_manually.pl 0
1477560454560 geckodriver INFO Listening on 127.0.0.1:25000
POST /session
1477560456569 mozprofile::profile INFO Using profile path /tmp/rust_mozprofile.5OKfT7FqPRdG
1477560456570 geckodriver::marionette INFO Starting browser /usr/bin/firefox
1477560456572 geckodriver::marionette INFO Connecting to Marionette on localhost:33258
(firefox:26547): GLib-GObject-CRITICAL **: g_object_ref: assertion 'object->ref_count > 0' failed
(firefox:26547): GLib-GObject-CRITICAL **: g_object_unref: assertion 'object->ref_count > 0' failed
(firefox:26547): GLib-GObject-CRITICAL **: g_object_ref: assertion 'object->ref_count > 0' failed
(firefox:26547): GLib-GObject-CRITICAL **: g_object_unref: assertion 'object->ref_count > 0' failed
1477560457832 Marionette INFO Listening on port 33258
1477560460135 Marionette INFO startBrowser 8c41f3c2-c636-422c-bb8c-2073c05ea0da
POST /session/8c41f3c2-c636-422c-bb8c-2073c05ea0da/url
(/usr/lib/firefox/plugin-container:26632): GLib-GObject-CRITICAL **: g_object_ref: assertion 'object->ref_count > 0' failed
(/usr/lib/firefox/plugin-container:26632): GLib-GObject-CRITICAL **: g_object_unref: assertion 'object->ref_count > 0' failed
(/usr/lib/firefox/plugin-container:26632): GLib-GObject-CRITICAL **: g_object_ref: assertion 'object->ref_count > 0' failed
(/usr/lib/firefox/plugin-container:26632): GLib-GObject-CRITICAL **: g_object_unref: assertion 'object->ref_count > 0' failed
POST /session/8c41f3c2-c636-422c-bb8c-2073c05ea0da/element
% pgrep -fla firefox; pgrep -fla geckodriver;
26547 /usr/lib/firefox/firefox --marionette --profile /tmp/rust_mozprofile.5OKfT7FqPRdG
26632 /usr/lib/firefox/plugin-container -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 26547 true tab
Launch geckodriver, and send one delete session command. The firefox process is cleared in the end:
% perl firefox_launch_manually.pl 1
1477560425814 geckodriver INFO Listening on 127.0.0.1:25000
POST /session
1477560427826 mozprofile::profile INFO Using profile path /tmp/rust_mozprofile.SKpVRbQG6QBJ
1477560427826 geckodriver::marionette INFO Starting browser /usr/bin/firefox
1477560427828 geckodriver::marionette INFO Connecting to Marionette on localhost:49944
(firefox:26390): GLib-GObject-CRITICAL **: g_object_ref: assertion 'object->ref_count > 0' failed
(firefox:26390): GLib-GObject-CRITICAL **: g_object_unref: assertion 'object->ref_count > 0' failed
(firefox:26390): GLib-GObject-CRITICAL **: g_object_ref: assertion 'object->ref_count > 0' failed
(firefox:26390): GLib-GObject-CRITICAL **: g_object_unref: assertion 'object->ref_count > 0' failed
1477560429174 Marionette INFO Listening on port 49944
1477560431391 Marionette INFO startBrowser eca6bd3b-3f05-47fa-ace6-1a09b7b30289
POST /session/eca6bd3b-3f05-47fa-ace6-1a09b7b30289/url
(/usr/lib/firefox/plugin-container:26465): GLib-GObject-CRITICAL **: g_object_ref: assertion 'object->ref_count > 0' failed
(/usr/lib/firefox/plugin-container:26465): GLib-GObject-CRITICAL **: g_object_unref: assertion 'object->ref_count > 0' failed
(/usr/lib/firefox/plugin-container:26465): GLib-GObject-CRITICAL **: g_object_ref: assertion 'object->ref_count > 0' failed
(/usr/lib/firefox/plugin-container:26465): GLib-GObject-CRITICAL **: g_object_unref: assertion 'object->ref_count > 0' failed
POST /session/eca6bd3b-3f05-47fa-ace6-1a09b7b30289/element
DELETE /session/eca6bd3b-3f05-47fa-ace6-1a09b7b30289
[Child 26465] WARNING: pipe error (3): Connection reset by peer: file /build/firefox-XpkqMU/firefox-49.0+build4/ipc/chromium/src/chrome/common/ipc_channel_posix.cc, line 316
[Child 26465] ###!!! ABORT: Aborting on channel error.: file /build/firefox-XpkqMU/firefox-49.0+build4/ipc/glue/MessageChannel.cpp, line 2052
[Child 26465] ###!!! ABORT: Aborting on channel error.: file /build/firefox-XpkqMU/firefox-49.0+build4/ipc/glue/MessageChannel.cpp, line 2052
% pgrep -fla firefox; pgrep -fla geckodriver;
# nothing shows up
Sorry for not doing this in rust (don't know yet enough rust to do this)
#!/usr/bin/perl
use strict;
use warnings;
use feature qw(say);
use Data::Dumper;
use JSON::XS;
my $must_delete = $ARGV[0]; # accept 0 or 1 as argument
my @command = qw{ /usr/local/bin/geckodriver --port 25000 };
my $pid = fork();
die 'Fork failed' if not defined $pid;
if (not $pid) {
exec(@command) or die $!;
}
sleep(2); # wait for geckodriver to launch
my $host = 'localhost:25000';
my $url = '/session';
say "POST $url";
my $res;
$res = decode_json( `curl --silent -X POST ${host}$url --data '{}'` );
my $sessionId = $res->{sessionId};
$url = "/session/$sessionId/url";
say "POST $url";
$res = decode_json( `curl --silent -X POST ${host}$url --data '{"url":"https://www.adzuna.co.uk"}'` );
$url = "/session/$sessionId/element";
say "POST $url";
$res = decode_json( `curl --silent -X POST ${host}$url --data '{"using":"css selector","value":"h1"}'` );
if($must_delete) {
$url = "/session/$sessionId";
say "DELETE $url";
$res = decode_json( `curl --silent -X DELETE ${host}$url --data '{}'` );
}
kill(15, $pid);
perl firefox_launch_manually.pl 0 perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = (unset), LC_ALL = (unset), LC_PAPER = "bn_BD", LC_ADDRESS = "bn_BD", LC_MONETARY = "bn_BD", LC_NUMERIC = "bn_BD", LC_TELEPHONE = "bn_BD", LC_IDENTIFICATION = "bn_BD", LC_MEASUREMENT = "bn_BD", LC_TIME = "bn_BD", LC_NAME = "bn_BD", LANG = "en_US.UTF-8" are supported and installed on your system. perl: warning: Falling back to the standard locale ("C"). Can't open perl script "firefox_launch_manually.pl": No such file or directory root@ip-10-0-1-140:~# env | grep DISP DISPLAY=vkcloud2:1 root@ip-10-0-1-140:~#
There is basically https://bugzilla.mozilla.org/show_bug.cgi?id=1430064, which handles this particular issue.
(EDIT): you can skip this comment and go to https://github.com/mozilla/geckodriver/issues/291#issuecomment-256596003 that has a more accurate and compact way of reproducing the problem.
Summary
When I kill -15 a geckodriver launched in the shell, there is a firefox process left in the end. I am not sure if this expected or if I am doing something wrong :/
Details
I use 3 terminals.
A$
,B$
,C$
Initially no firefox or geckodriver runningStart geckodriver
Create a new session (and as a consequence a firefox will be created)
Firefox and geckodriver are up and running
Let's gracefully kill geckodriver.
In the end I still see a firefox running
My env
I tried the above with geckodriver 0.10.0 and 0.11.1. The difference was in the output of geckodriver (0.11.1 was more verbose, maybe different log level?) and in the final firefox command:
0.10:
0.11.1: