Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] what's happening when we alt tab to another window and give input in that new window and come back to the browser? #733

Closed
shikamu opened this issue Aug 9, 2023 · 9 comments · Fixed by #759
Assignees

Comments

@shikamu
Copy link

shikamu commented Aug 9, 2023

Describe the Bug

I can use all sort of tools (pan, zoom, all the ROI tools) and then if I alt tab to another window and perform some actions in that new window (use mouse wheel for instance) and then come back to my browser with my cornerstone3d app, then I can't pan or use any of the ROI tools anymore

Steps to Reproduce

  1. have an external app open (visual studio, visual code, notepad++, whatever)
  2. browse to one of the live examples (tried with chrome and firefox on windows 11), for instance https://www.cornerstonejs.org/live-examples/doubleclickwithstackannotationtools
  3. observe that you can render some lines with the default tool (length)
  4. alt tab to your external application (e.g. visual studio) and scroll using mouse wheel
  5. alt tab back to the browser with the cornerstone3d example, observe that you can no longer render annotations

The following gif showcases just that:

2023-08-09_17h04_53

what's interesting is that if you move switch to another window by clicking in the window (let's say you had the browser and visual studio side by side) and you just click in visual studio, scroll using the mouse wheel, and then come back to the browser, everything is working. The problem only occurs if we are using the alt+tab combination.

The current behavior

something seems to be happening when we alt tab out of the browser and perform some input. The bug does not seem to occur if we simply alt tab, do nothing, and come back to the browser.

The expected behavior

When I alt tab to another app and then come back to the browser, I expect to be able to continue using all the cornerstone tools on the image that's rendered.

OS

Windows 11

Node version

16.14.2

Browser

chrome 115.0.5790.171 (Official Build) (64-bit), firefox 116.0.2 (64-bit)

@shikamu shikamu changed the title [Bug] what's happening when we alt tab to another window and give input in that new window and come back? [Bug] what's happening when we alt tab to another window and give input in that new window and come back to the browser? Aug 9, 2023
@sedghi
Copy link
Member

sedghi commented Aug 15, 2023

I can't reproduce what you say, did you try in-congnito? maybe you have some shortcuts/extensions that is messing with cs3d

CleanShot 2023-08-15 at 10 24 01

@shikamu
Copy link
Author

shikamu commented Aug 16, 2023

This issue is quite strange... I've tried in incognito, it's also happening, I've also tried in Edge, which is a browser I almost never use, same with firefox, so I'm confident I don't have any extra extensions for these.

I've just noticed that if you come back to the cornerstone3d app by pressing alt tab, the issue does not occur, it seems to occur if you click back in the browser that has the cornerstone app. I've recorded another demo:

2023-08-16_07h22_31

the first time, I draw a line, then I alt tab, I scroll in the new window (according to my latest attempt that's not even needed), I click in the cornerstone window, and then I try to draw a line but I can't do anything anymore.
Then I refresh the page, draw a line again, alt tab, scroll in the new window, and alt tab back to the cornerstone app, and I guess this is what you did and yes indeed in that case apparently I'm able to render new lines and use the app as expected.

Are you able to reproduce my issue if you have 2 windows side by side, 1 with a cornerstone app and one with another browser window or w/e, draw a line in cornerstone, then alt tab, scroll in that new window and then click back in the cornerstone window and try to render another line, for me that does not work.

thanks for your time!

@HireGuerard
Copy link

HireGuerard commented Aug 22, 2023

@shikamu I'm also able to reproduce this in our app (we've two side-by-side stack viewers, and when alt-tabbing in and out the zoom/pan tools will stop working. scrolling through the other images does continue to work however). Initially we assumed it was a bug on our end...but seems like if it is it's present in the examples too.

I'll let you know if I find any work(hack)arounds in the meantime

Edit: It's worth noting that the tools will sometimes kick back on if i alt-tab out and back in again. @sedghi is there some cornerstone lib debug-mode or other options i can enable to maybe help try and identify the issue?

@HireGuerard
Copy link

HireGuerard commented Aug 22, 2023

#317 Seems like a duplicate w/ a known fix(?) Any chance the cornerstone team could merge a similar change as the hack mentioned?

Also i've a consistent repro now; when i click in it works fine. Alt-tab in it's broken. Edit: this isn't really a full "repro" but the issue above does seem to be the root-cause i.e. if I keyup/down the alt (or any key for that matter) key after it's stuck it works again.

@shikamu
Copy link
Author

shikamu commented Aug 23, 2023

@sedghi any thought ?

@diaztula
Copy link

diaztula commented Aug 27, 2023

I had the same issue and found that when you alt-tab to another window, then go back to the cornerstone tab and click (either left or right click), the mouse click event is triggered with the "ALT" key modifier on, even if you are no longer pressing the ALT key.

In this situation the tool is not working anymore because the mouse click event does not match the initial mouse binging that is only mouse button, not button + ALT. The current active tool is not detected because of this.

I also found (similar to @HireGuerard) that if you press the ALT key, the tool works again, likely becase the ALT key modifier in the mouse click event is cleared when you release the ALT key.

A temporary workaround that works for my case is to add two bindings for the tool, one with the mouse button, and another with the mouse button plus the modifier key ALT.

toolGroup.setToolActive(yourToolName, {
    bindings: [
        {
            mouseButton: MouseBindings.Primary,
        },
        {
            mouseButton: MouseBindings.Primary,
            modifierKey: 18, // ALT key
        }
    ]
});

Please note this is a workaround and might not work for you if you use the ALT + click event to do someting else in your application.

@jbocce
Copy link
Contributor

jbocce commented Aug 29, 2023

Hello @diaztula, @shikamu and @HireGuerard, at your convenience please have a look at PR #759 and provide any pertinent feedback. Thanks so much!

@shikamu
Copy link
Author

shikamu commented Aug 29, 2023

@jbocce thanks for the fix! I haven't tried the result of your PR but from what you describe in it, it seems to be spot on!

@diaztula
Copy link

Hello @jbocce, thanks for taking care of fixing this, seems to be a solution!
Cheers

sedghi pushed a commit that referenced this issue Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants