Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 370139 - [Dialog] Modal dialog blocks application upon close
Summary: [Dialog] Modal dialog blocks application upon close
Status: RESOLVED FIXED
Alias: None
Product: RAP
Classification: RT
Component: RWT (show other bugs)
Version: 1.5   Edit
Hardware: PC Windows 7
: P1 normal (vote)
Target Milestone: 1.5 M6   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 373884 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-01-30 11:07 EST by Austin Riddle CLA
Modified: 2012-03-12 15:48 EDT (History)
5 users (show)

See Also:


Attachments
simple project with RAP mail demo (31.10 KB, application/zip)
2012-02-16 08:11 EST, Sudesh Bulathsinhala CLA
no flags Details
Proposed patch (13.59 KB, patch)
2012-02-17 09:12 EST, Ivan Furnadjiev CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Austin Riddle CLA 2012-01-30 11:07:42 EST
Version: CVS HEAD

In some situations, modal dialogs (including progress dialogs) will leave the application in a _hung_ state upon close.  The result is that after the dialog disappears, the div that shows the lightbox effect remains on top, effectively blocking any interaction with the application.  

I have experienced this in two different applications, and am trying to produce a sample project.
Comment 1 Ivan Furnadjiev CLA 2012-02-09 03:07:20 EST
Austin, any progress on a snippet to reproduce it?
Comment 2 Austin Riddle CLA 2012-02-09 23:01:27 EST
(In reply to comment #1)
> Austin, any progress on a snippet to reproduce it?

I have not been able to produce an isolated sample project. However, I have at least some idea of what is related to the problem. I found that if I comment out the content of the *block* and *release* functions in ClientDocument.js the problem seems to disappear in my applications. That is all I have found up to now. I hope it is in some way helpful.
Comment 3 Sudesh Bulathsinhala CLA 2012-02-16 08:11:45 EST
Created attachment 211104 [details]
simple project with RAP mail demo

hi,

this bug is reproducible with attached RAP mail app demo.
run the RAP demo mail app attached, and click the "Open Message" action.

in MessagePopupAction class, i'm using UIJob
here is the sample code..

public void run() {
   final UIJob job = new UIJob("") {
      @Override
      public IStatus runInUIThread(final IProgressMonitor monitor) {
              MessageDialog.openInformation(window.getShell(), 
                                            "Open",
				            "Open Message Dialog!");
      return Status.OK_STATUS;
      }
   };
   job.setUser(true);
   job.schedule();
}


when using UIJob, the dialog exit behavior is frozen.

regards,
sudesh bulathsinhala
Comment 4 Austin Riddle CLA 2012-02-16 12:31:41 EST
Thanks Sudesh!
Comment 5 Ivan Furnadjiev CLA 2012-02-17 05:38:06 EST
Thanks, Sudesh. I can reproduce the issue with your snippet.
Comment 6 Ivan Furnadjiev CLA 2012-02-17 06:13:36 EST
The issue is interesting: actually we have two *modal* shells created one after another. The first one is a "progress monitor" shell, the second one is the MessageDialog opened in the UIJob#runInUIThread. When you press on the MessageDialog OK button it is successfully closed, but the "progress monitor" shell stays *below* the main shell in a hung state and keep the blocking overlay opened.
Comment 7 Ivan Furnadjiev CLA 2012-02-17 06:23:01 EST
To be precise the first shell is a ProgressMonitorFocusJobDialog.
Comment 8 Ivan Furnadjiev CLA 2012-02-17 07:14:03 EST
First, the bug does not exists with RAP 1.4. It is a regression from the protocol migration. The problem is in the ShellAdapter#factory where the Shell is opened (call result.show()) when Shell is created. This is completely wrong. You could create a Shell without open it (make it active and visible). A fast and dirty hack in ShellAdapter to open the shell when "active" property is set to true solves the problem. Looking for a clean solution.
Comment 9 Ivan Furnadjiev CLA 2012-02-17 09:12:46 EST
Created attachment 211181 [details]
Proposed patch

This patch uses the old (from 1.4) method adopted to the protocol to render the shell opening. I've created a property "opened" instead of method "open" as based on the comments in the LCA order matters: opened, active, mode.
Austin, could you give it a try with your applications?
Tim, do you have any concerns?
Comment 10 Tim Buschtoens CLA 2012-02-17 11:54:10 EST
I dont quite get why we need "opend" and "visibility" - both do the same on the client, don't they, only that open also calls centerToBrowser before.
Comment 11 Ivan Furnadjiev CLA 2012-02-17 13:02:02 EST
(In reply to comment #10)
> I dont quite get why we need "opend" and "visibility" - both do the same on the
> client, don't they, only that open also calls centerToBrowser before.
"visibility" is a control property and it is set after the other Shell properties. Based on the comments in the old/current LCA "open" *must* be called before "mode" and "bounds". But if this is not obligatory anymore (we have to check all old related bugs) we could try to stay only with "visibility" property.
Comment 12 Paul Bilnoski CLA 2012-02-24 14:50:16 EST
I have found another case that can be used to reproduce this issue. I used the following code in an eclipse.ui command handler, but it could just as easily be placed on any user action such as a button click.

Shell sh = HandlerUtil.getActiveShellChecked(event);
MessageDialog md = new MessageDialog(sh, "", null, "message", MessageDialog.ERROR, new String[] {"OK"}, 0)
{
   @Override
   protected Control createDialogArea(Composite parent)
   {
      throw new IllegalStateException("dialog failed creation");
   }
};
int result = md.open();

The dialog goes through the process of opening, which notifies the client and displays the lightbox, but the dialog's construction was halted via runtime exception and the lightbox never went away. I suspect something on the client needs a construct similar to try/finally to ensure it is properly cleaned up.
Comment 13 Ivan Furnadjiev CLA 2012-02-24 16:29:20 EST
Paul, I've modified the Controls Demo DialogTab with your snippet, but what I get is the "HTTP ERROR: 500" with "java.lang.IllegalStateException: dialog failed creation" as expected. Could you provide a complete self-running snippet to reproduce it?
Comment 14 Austin Riddle CLA 2012-02-24 18:32:09 EST
(In reply to comment #13)
Hello Ivan, 

I have tested your patch with Paul's use-case and it fixes the problem. Good work!
Comment 15 Ivan Furnadjiev CLA 2012-02-28 09:54:17 EST
Fixed in CVS HEAD without introducing new property in the protocol. Overrided "visibility" property instead as Tim suggested. Changes are in CVS HEAD.
Comment 16 Thomas Kratz CLA 2012-03-12 15:48:45 EDT
*** Bug 373884 has been marked as a duplicate of this bug. ***