[1.0.1] Linux: Screen capture sometimes fails to create a selection

Bug #1238027 reported by Luciana Moreira Sá de Souza
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SikuliX
In Progress
Medium
RaiMan

Bug Description

I am frequently having a problem with the screen capture for the IDE. The problem is that it does not seem to take the mouse events. I get to the gray screen to select the area to capture, but it does not do the selection (white rectangle with red lines). The only way out of the screen capture is by pressing ESC.

This does not happen every time, and so far I have not figured out how to consistently reproduce this issue.

Revision history for this message
Luciana Moreira Sá de Souza (lso) wrote :

I am seeing a similar problem with the Pattern Settings dialog. I click on the image thumbnail to set the screenshot filename and sometimes, all my mouse clicks on this screen end up in the ide rather than the dialog.

Revision history for this message
RaiMan (raimund-hocke) wrote :

at comment #1:

I made it separate bug since this a totally different situation

description: updated
summary: - Screen capture fails to create a selection
+ [1.0.1] Linux: Screen capture sometimes fails to create a selection
Changed in sikuli:
status: New → In Progress
importance: Undecided → Medium
assignee: nobody → RaiMan (raimund-hocke)
milestone: none → 1.1.0
Revision history for this message
Luciana Moreira Sá de Souza (lso) wrote :

Hey RaiMan,

On my machine it seems like the problem is resolved by doing the following:

On class org.sikuli.ide.ButtonCapture on line 108 the ide is set to visible and requests the focus after the prompt for the image selection.

    p.prompt("Select an image");
    try {
     Thread.sleep(500);
    } catch (Exception e) {
    }
    if (delay != 0) {
     ide.setVisible(true);
    }
    ide.requestFocus();

Change that to p.prompt("Select an image"); only.

Setting the ide to visible and request focus should only occur after the selection. This is done on the same class in the method update(EventSubject s)

Define SikuliIDE ide = SikuliIDE.getInstance();

Then at the end of the method:

                                 if (filename != null) {
     String fullpath = Utils.saveImage(simg.getImage(),
       filename, pane.getSrcBundle());
     if (fullpath != null) {
      captureCompleted(Utils.slashify(fullpath, false), cp);
      ide.setVisible(true);
      ide.requestFocus();
      return;
     }
    }
   }
   ide.setVisible(true);
   ide.requestFocus();
   captureCompleted(null, cp);

Works now for me. Tested on opensuse only.

Revision history for this message
RaiMan (raimund-hocke) wrote :

again thanks.

I guess, that the real problem behind has been the fact, that the IDE normally was not set invisible at the beginning of the capture()::run(), since the delay in most cases is not null.
And this might have been a conflict on Linux.

Nevertheless, i changed it this way:
public void capture(final int delay) {
  if (_isCapturing) {
    return;
  }
  Thread t = new Thread("capture") {
    @Override
    public void run() {
      _isCapturing = true;
      SikuliIDE ide = SikuliIDE.getInstance();
      ide.setVisible(false);
      try {
        Thread.sleep(delay);
      } catch (Exception e) {
      }
      OverlayCapturePrompt p = new OverlayCapturePrompt(null, ButtonCapture.this);
      p.prompt("Select an image");
    }
  };
  t.start();
}

... and moved the come back of the IDE window to the end of captureCompleted() (so we have it at the very end only once)

Revision history for this message
Luciana Moreira Sá de Souza (lso) wrote :

Hey RaiMan,

This fix did not resolve the problem. I just tested it on my machine. I am not sure yet of what is wrong, but the symptom is the same.

Revision history for this message
Luciana Moreira Sá de Souza (lso) wrote :

RaiMan I am not sure what cause the issue to appear again here. So far it only happened once. But once it appears, normally the screenshot feature does not work even if I try multiple times.

I suspect there is another bug related to the PatternSettings dialog also requesting focus and competing with the ide. Just a guess. I will try to investigate this problem today. You mentioned that you would create another bug for this on comment #2. Could you give me the bug number?

Besides that, I checked your code changes. Looks good :)

Revision history for this message
RaiMan (raimund-hocke) wrote :

ok thanks.

I will have a look on my Ubuntu 13.04 64 the next time, when I test there.

--- create another bug for this on comment #2
bug 1238546

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.