eclipse-rap / org.eclipse.rap

Eclipse RAP Runtime (Remote Application Platform)
https://www.eclipse.org/rap/
Eclipse Public License 1.0
17 stars 19 forks source link

Weakness in `FileDialog` may cause `Widget disposed` error #174

Closed hendeltom closed 4 weeks ago

hendeltom commented 6 months ago

In a production environment with average to high load we encountered several "Widget disposed" errors thrown by org.eclipse.rap.rwt.widgets.FileUpload.submit(String). Users see the following effect: They select a file using the file picker dialog. Then, for a while nothing happens, i.e. the progress bar does not change. But since the "Ok" button is active, they click on "Ok". And then the error is thrown. After digging into the code I found the asynchronous file upload triggered by org.eclipse.swt.widgets.FileDialog.handleFileUploadSelection(FileUpload). Apparently, in our environment the background thread does not start for several seconds. But since the "Ok" button is disabled from the background thread (org.eclipse.swt.widgets.FileDialog.SingleThreadExecutor.beforeExecute(Thread, Runnable)), the button stays active and clickable until the thread is finally started. If the user clicks on it, then the whole dialog is disposed. If then the background thread starts, it will cause the "Widget disposed" error. My suggestion is to set org.eclipse.swt.widgets.FileDialog.okButton to disabled immediately after creation. BUT: In order to avoid any "Widget disposed" error in this context, the class org.eclipse.swt.internal.widgets.FileUploadRunnable must get some information about the disposal of the dialog and then just do nothing.

ifurnadjiev commented 6 months ago

Can you provide a PR with a fix suggestion?

ifurnadjiev commented 6 months ago

... also a stack trace with "Widget disposed" error will help to understand better the problem and find the proper fix.

hendeltom commented 6 months ago

I've got a stack trace, unfortunately only as screenshot. I'll attach it anyway.

2024-02-27-stacktrace-fileupload

hendeltom commented 6 months ago

I'll try to provide a PR, but this might take a few days...