Bug 422889 - Unhandled event loop exception while MessageBox is open hangs UI
Summary: Unhandled event loop exception while MessageBox is open hangs UI
Status: REOPENED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.16   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2013-11-30 06:54 EST by Richard Fearn CLA
Modified: 2020-08-02 12:41 EDT (History)
1 user (show)

See Also:


Attachments
Test program that demonstrates UI freeze (2.12 KB, text/x-java)
2013-11-30 07:08 EST, Richard Fearn CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Fearn CLA 2013-11-30 06:54:34 EST
If a task executed with Display.asyncExec throws an unchecked exception, normally that exception propagates up to the code running the event loop.

In an RCP application (using Eclipse 3.x), the exception is caught in Workbench.runEventLoop, and eventually gets logged (by WorkbenchAdvisor.eventLoopException) as an "Unhandled event loop exception".

However if a task that throws an exception is executed while a MessageBox is open, the exception causes the UI to freeze.

When a MessageBox is opened, SWT calls gtk_dialog_run, which "blocks in a recursive main loop" (according to the GTK manual). This main loop, when idle, invokes an SWT callback - Display.idleProc - that allows SWT to execute other pending tasks, even though the (modal) dialog is open.

An uncaught exception while a task is being invoked *by the callback* hangs the UI.

The workaround is to avoid throwing an unchecked exception from a task, even though most of the time it will just get logged as an "Unhandled event loop exception" and the application will continue running normally.
Comment 1 Richard Fearn CLA 2013-11-30 07:08:37 EST
Created attachment 237882 [details]
Test program that demonstrates UI freeze

Test program to demonstrate UI freeze.

* UI initially works fine (e.g. button can be pressed)
* 1st task throws NPE; UI continues to work
* 2nd task opens a MessageBox; UI continues to work
* 3rd task throws NPE; UI freezes

This reproduces the freeze on a variety of systems:

Red Hat Enterprise Linux 6
GTK 2.18.9
SWT 3.8.1 (version 3836)

Ubuntu 13.10
GTK 2.24.20
Eclipse 4.3 SR1
SWT version 4333

Fedora 19
GTK 2.24.22
Eclipse 3.7 SR2
SWT 3.7.2 (version 3740)
Comment 2 Eric Williams CLA 2018-07-06 14:10:08 EDT
This is still reproducible on SWT from master as of today, GTK3.22, and Fedora 28.
Comment 3 Eclipse Genie CLA 2020-07-20 19:59:34 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 4 Richard Fearn CLA 2020-08-02 12:41:49 EDT
Still reproducible on Fedora 32, using SWT/JFace from Eclipse 2020-06:

 * org.eclipse.swt.gtk.linux.x86_64_3.114.100.v20200604-0951.jar
 * org.eclipse.jface_3.20.0.v20200505-1952.jar

version.txt in the SWT JAR says "version 4.934"

Test program outputs "SWT version: 4934"

GTK 3.24.20