org.eclipse.rap
org.eclipse.rap copied to clipboard
Weakness in `FileDialog` may cause `Widget disposed` error
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.
Can you provide a PR with a fix suggestion?
... also a stack trace with "Widget disposed" error will help to understand better the problem and find the proper fix.
I've got a stack trace, unfortunately only as screenshot. I'll attach it anyway.
I'll try to provide a PR, but this might take a few days...