org.eclipse.rap icon indicating copy to clipboard operation
org.eclipse.rap copied to clipboard

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

Open hendeltom opened this issue 1 year ago • 4 comments

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.

hendeltom avatar Feb 27 '24 16:02 hendeltom

Can you provide a PR with a fix suggestion?

ifurnadjiev avatar Feb 28 '24 08:02 ifurnadjiev

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

ifurnadjiev avatar Feb 28 '24 09:02 ifurnadjiev

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

2024-02-27-stacktrace-fileupload

hendeltom avatar Feb 28 '24 10:02 hendeltom

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

hendeltom avatar Feb 28 '24 10:02 hendeltom