Bug 40985 - Firefox hangs when clicking on "finish" at the end of the setup wizard
Firefox hangs when clicking on "finish" at the end of the setup wizard
Product: UCS
Classification: Unclassified
Component: UMC - Setup wizard
UCS 4.1
Other Linux
: P5 normal (vote)
: UCS 4.1-2-errata
Assigned To: Eduard Mai
Alexander Kläser
Depends on:
Blocks: 40006
  Show dependency treegraph
Reported: 2016-04-04 13:29 CEST by Alexander Kläser
Modified: 2017-01-20 16:47 CET (History)
2 users (show)

See Also:
What kind of report is it?: ---
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Kläser univentionstaff 2016-04-04 13:29:24 CEST
With the changes of Bug 40046, Firefox is hanging when clicking on "finish" on the last page of the setup wizard. "finish" will trigger a JS function which calls window.close(). This problems only seems to be reproducible in a setup with DHCP, static IP addresses seem to work fine.
Comment 1 Alexander Kläser univentionstaff 2016-04-04 13:33:53 CEST
→ Maybe this problem is related to some problem with the profile?

→ The shutdown process will trigger some shutdown operations which might end up in a deadlock. Not sure, but I had the impression that Bug 38866 might be related to this problem as well. I observed FF with a normal load and it did not hang with DHCP.

Firefox also reports errors due to dbus missing (→ Bug 36168), not sure whether this could be related.
Comment 2 Alexander Kläser univentionstaff 2016-04-04 13:36:29 CEST
In about:config → toolkit.asyncshutdown.timeout.crash could be set to 1 (ms) (default value is 60000ms). This could be worth a try. Otherwise, I could not detect any other config parameters that might be of interest.

Another workaround would be to install a temporary web service which allows to kill the Firefox session.
Comment 3 Alexander Kläser univentionstaff 2016-04-04 13:48:19 CEST
Problem has been reproduced in "demo mode" and when joining the system as UCS master.
Comment 4 Eduard Mai univentionstaff 2016-04-06 14:38:03 CEST
Revision 68429: Closing Firefox by umcp command instead of window.close
Successful build
Package: univention-system-setup
Version: 9.1.4-5.954.201604061432
Branch: ucs_4.1-0
Scope: appliance
Comment 5 Alexander Kläser univentionstaff 2016-04-06 15:04:55 CEST
Really nice fix :) ! Just some minor issues...

(a) this.umcpCommand('setup/closefirefox', {keep_alive: true}, false);
→ As no data is transferred, this could be rather:
this.umcpCommand('setup/closefirefox', {}, false);

(b) def close_firefox(self, request): ...
→ Could have a simple_response decorator, then without the "request" parameter.
Comment 6 Florian Best univentionstaff 2016-04-06 15:20:57 CEST
+	def close_firefox(self, request):
+		PATH_BROWSER_PID = '/var/cache/univention-system-setup/browser.pid'
+		try:
+			fpid = open(PATH_BROWSER_PID)
+			strpid = fpid.readline().strip()
+			pid = int(strpid)
+			p = psutil.Process(pid)
+			p.kill()
+		except IOError:
+			print 'WARN: cannot open browser PID file: %s' % PATH_BROWSER_PID
+		except ValueError:
+			print 'ERROR: browser PID is not a number: "%s"' % strpid
+		except psutil.NoSuchProcess:
+			print 'ERROR: cannot kill process with PID: %s' % pid

1. you don't need to define a constant for a variable which is only used once
2. use "with open(filename) as fd:" when opening files (to automatically close them)
3. don't use print, use MODULE.error()

    with open('/var/cache/univention-system-setup/browser.pid', 'rb') as fd:
       pid = int(fd.readline().strip())
       process = psutil.Process(pid)
except IOError as exc:
   MODULE.error('cannot open PID file: %s' % (exc,))
Comment 7 Eduard Mai univentionstaff 2016-04-06 18:44:18 CEST
Added suggestions from Comment 5 and 6.

Rev. 68438: Code cleanup
Rev. 68439: Corrected typo
Successful build
Package: univention-system-setup
Version: 9.1.4-7.956.201604061840
User: emai
Branch: ucs_4.1-0
Comment 8 Florian Best univentionstaff 2016-04-07 06:21:38 CEST
What in case of an error? Maybe the window.close() should be readded to the error handler of the umcpCommand deferred - even if it takes 5 minutes then it's better than closing it never.
Comment 9 Eduard Mai univentionstaff 2016-04-08 14:04:24 CEST
Rev. 68509: Added error handling.
Package: univention-system-setup
Version: 9.1.4-8.957.201604081401
Branch: ucs_4.1-0
Scope: appliance
Comment 10 Florian Best univentionstaff 2016-04-12 14:45:44 CEST
Just a small hint:
You don't have to use psutil to kill a process. You can simply use os.kill(pid).
Comment 11 Florian Best univentionstaff 2016-04-12 14:50:17 CEST
os.kill(pid, 9)

9 is signal.SIGKILL.
15 is signal.SIGTERM.
Maybe SIGTERM is better?
Comment 12 Alexander Kläser univentionstaff 2016-04-14 16:58:57 CEST
(In reply to Florian Best from comment #11)
> os.kill(pid, 9)
> 9 is signal.SIGKILL.
> 15 is signal.SIGTERM.
> Maybe SIGTERM is better?

Not sure, looking at the FF bug when the process is hanging.
Comment 13 Eduard Mai univentionstaff 2016-04-18 14:00:46 CEST
Firefox does exit for me on SIGTERM in this particular case. However SIGKILL seems fine to me, as system-setup does not rely on Firefox exiting gracefully.
Comment 14 Alexander Kläser univentionstaff 2016-07-08 17:36:06 CEST
Changes: OK, works like a charm.

Comment 15 Janek Walkenhorst univentionstaff 2016-08-03 15:56:46 CEST