On OS X, when switching from another app to Blender via Mission Control, it doesn't work. #42305

Closed
opened 2014-10-19 21:07:34 +02:00 by Claudio D. · 38 comments

System Information
Operating system: OS X 10.9.5
Graphics card: NVIDIA GeForce GT 650M 1024 MB

Blender Version
Broken: I have seen it since 2.69.0 to 2.72a (haven't tested it on any version prior 2.69.0)

Short description of error

On OS X, when switching from another app to Blender via Mission Control (the OS X feature that spreads out in your screen every window/app you have open) it doesn't switch. Blender kind of hides in the back, you need to repeat the process and then it works fine. Here is a dropbox link to a quick video for easier understanding, sorry if I can't explain myself with words:

Link: https://www.dropbox.com/s/26je5zq5827tj43/Mission%20Control%20Error.mov?dl=0

Exact steps for others to reproduce the error
With Blender opened, switch to another app, then via Mission Control select Blender. It will hide itself.

**System Information** Operating system: OS X 10.9.5 Graphics card: NVIDIA GeForce GT 650M 1024 MB **Blender Version** Broken: I have seen it since 2.69.0 to 2.72a (haven't tested it on any version prior 2.69.0) **Short description of error** On OS X, when switching from another app to Blender via Mission Control (the OS X feature that spreads out in your screen every window/app you have open) it doesn't switch. Blender kind of hides in the back, you need to repeat the process and then it works fine. Here is a dropbox link to a quick video for easier understanding, sorry if I can't explain myself with words: > Link: https://www.dropbox.com/s/26je5zq5827tj43/Mission%20Control%20Error.mov?dl=0 **Exact steps for others to reproduce the error** With Blender opened, switch to another app, then via Mission Control select Blender. It will hide itself.
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @claudio-10

Added subscriber: @claudio-10

Added subscriber: @FloridaJo

Added subscriber: @FloridaJo

I can't recreate that here on OS X 10.10 AMD Radeon HD 6770M 512 MB.

I can't recreate that here on OS X 10.10 AMD Radeon HD 6770M 512 MB.
Author

Forgot to mention this is a retina display. I remember not so long ago there was a weird error when adding nodes (the nodes didn't add where the cursor was) that only happened on a retina display. Maybe this also happens only on a retina display? Also, this only happens with Blender.

Thanks for your help.

Forgot to mention this is a retina display. I remember not so long ago there was a weird error when adding nodes (the nodes didn't add where the cursor was) that only happened on a retina display. Maybe this also happens only on a retina display? Also, this only happens with Blender. Thanks for your help.
jens verwiebe was assigned by Campbell Barton 2014-10-20 09:16:24 +02:00
Member

Cannot reproduce here on MacPro with AMD gpu atm.
Can only guess its something with retina and backbuffer
preventing Blender to be frontmost app on the first call.

Can somebody with NV try ?

Jens

Cannot reproduce here on MacPro with AMD gpu atm. Can only guess its something with retina and backbuffer preventing Blender to be frontmost app on the first call. Can somebody with NV try ? Jens

Added subscribers: @ThomasDinges, @Sergey

Added subscribers: @ThomasDinges, @Sergey

@ThomasDinges, you've got mac for as long as i concerned.

@ThomasDinges, you've got mac for as long as i concerned.

Cannot confirm this either, I open Blender, go to Safari, then via Mission Control back to Blender, opens fine.

Cannot confirm this either, I open Blender, go to Safari, then via Mission Control back to Blender, opens fine.

Added subscriber: @donfabio

Added subscriber: @donfabio

I can actually reproduce this behavior and remember it bothering me in earlier versions of Blender...

I'm also on a 15" Retina MacBook Pro.
OS: OS X 10.10
Graphics: GeForce GT 750M

I tried to debug this issue on the current master branch. The event flow is exactly the same as if you would use command+tab (windowDidBecomeKey is received when switching to Blender and windowDidResignKey when switching to another application). It appears the window just gets ordered to the background. Repeating the Mission Control action orders the window on top (no additional windowDidBecomeKey is received).

Now I stumbled onto a weird solution for my system: I added a windowDidBecomeMain method to the CocoaWindowDelegate interface and this glitch doesn't appear anymore. I have no idea why, but it works for me.

FYI: the windowDidBecomeMain is received before windowDidBecomeKey message.

If you know how to compile Blender yourself I can provide you a patch so you can see if this works on your system, too.

I can actually reproduce this behavior and remember it bothering me in earlier versions of Blender... I'm also on a 15" Retina MacBook Pro. OS: OS X 10.10 Graphics: GeForce GT 750M I tried to debug this issue on the current master branch. The event flow is exactly the same as if you would use command+tab (windowDidBecomeKey is received when switching to Blender and windowDidResignKey when switching to another application). It appears the window just gets ordered to the background. Repeating the Mission Control action orders the window on top (no additional windowDidBecomeKey is received). Now I stumbled onto a weird solution for my system: I added a windowDidBecomeMain method to the CocoaWindowDelegate interface and this glitch doesn't appear anymore. I have no idea why, but it works for me. FYI: the windowDidBecomeMain is received before windowDidBecomeKey message. If you know how to compile Blender yourself I can provide you a patch so you can see if this works on your system, too.

Here's the patch: http://pastebin.com/v7Z8S3JR

Here's the patch: http://pastebin.com/v7Z8S3JR
Member

Must look at this first.
Normally we prepend [m_window makeKeyAndOrderFront:nil]; just fine.
Looks as something with the retina backbuffer is fishy.
I remeber i can simulate retina on my nin-retina gfx too.
Must check this over.

Jens

Must look at this first. Normally we prepend [m_window makeKeyAndOrderFront:nil]; just fine. Looks as something with the retina backbuffer is fishy. I remeber i can simulate retina on my nin-retina gfx too. Must check this over. Jens

I had a look at it again and you can forget my patch. It has nothing to do with the problem, sorry. I narrowed it down why it worked for me to a break point I had set which just prints the eventType in GHOST_SystemCocoa::handleWindowEvent without pausing execution... Disabling the break point leads to the old behavior. Replacing the break point with a printf statement has no effect on the glitch.

BTW: [m_window makeKeyAndOrderFront:nil] is only called once in the constructor

I had a look at it again and you can forget my patch. It has nothing to do with the problem, sorry. I narrowed it down why it worked for me to a break point I had set which just prints the eventType in GHOST_SystemCocoa::handleWindowEvent without pausing execution... Disabling the break point leads to the old behavior. Replacing the break point with a printf statement has no effect on the glitch. BTW: [m_window makeKeyAndOrderFront:nil] is only called once in the constructor
Member

Joel, can you please help me ?
Simulating retina res, i can still not reproduce this issue.

Try add prints or NSLOG to check if the windowDidBecomeKey
reponds when switching. If so please try add an: [[NSApp keyWindow] orderFront:nil];
after: systemCocoa->handleWindowEvent(GHOST_kEventWindowActivate, associatedWindow);

Your patch would not harm afaik, but i would rather understand the rootproblem first.

Jens

Joel, can you please help me ? Simulating retina res, i can still not reproduce this issue. Try add prints or NSLOG to check if the windowDidBecomeKey reponds when switching. If so please try add an: [[NSApp keyWindow] orderFront:nil]; after: systemCocoa->handleWindowEvent(GHOST_kEventWindowActivate, associatedWindow); Your patch would not harm afaik, but i would rather understand the rootproblem first. Jens

[[NSApp keyWindow] orderFront:nil]; after systemCocoa->handleWindowEvent(GHOST_kEventWindowActivate, associatedWindow); didn't help.

As I said earlier windowDidBecomeKey is received just when clicking on the window in Mission Control. Then the window goes back to its previous order. Repeating this orders the window on top. No additional windowDidBecomeKey is received as if the window was already key. It appears the window is actually key even though other windows are on top (mouse overs are received). No intermittent windowDidResignKey is received.

I also tried low resolution mode via the checkbox in the info panel and the glitch is still reproduceable.

If you only use Mission Control to switch between windows this glitch does not appear. Only when you combine it with command+tab.

[[NSApp keyWindow] orderFront:nil]; after systemCocoa->handleWindowEvent(GHOST_kEventWindowActivate, associatedWindow); didn't help. As I said earlier windowDidBecomeKey is received just when clicking on the window in Mission Control. Then the window goes back to its previous order. Repeating this orders the window on top. No additional windowDidBecomeKey is received as if the window was already key. It appears the window is actually key even though other windows are on top (mouse overs are received). No intermittent windowDidResignKey is received. I also tried low resolution mode via the checkbox in the info panel and the glitch is still reproduceable. If you only use Mission Control to switch between windows this glitch does not appear. Only when you combine it with command+tab.
Member

I could now reproduce this behavoiur by switching to another app with cmd-tab then with mission-control trying to go back.
Not sure if this is a system bug or if we can workaround this, anyway i beliece this is a cornercase in usage.

Tetsing some things ....

Jens

I could now reproduce this behavoiur by switching to another app with cmd-tab then with mission-control trying to go back. Not sure if this is a system bug or if we can workaround this, anyway i beliece this is a cornercase in usage. Tetsing some things .... Jens
Member

K, 'am 1 step further:

It has todo with mssioncontrol settings, if you disable the highestmost option ( duuno the exact engl. naming )
it goes away:
oddnes.png

Now must lookup, if we can influence this from inside the app, but seems a known bug: http://apple.stackexchange.com/questions/108852/mavericks-window-loses-focus-on-cmdtab

Jens

K, 'am 1 step further: It has todo with mssioncontrol settings, if you disable the highestmost option ( duuno the exact engl. naming ) it goes away: ![oddnes.png](https://archive.blender.org/developer/F119919/oddnes.png) Now must lookup, if we can influence this from inside the app, but seems a known bug: http://apple.stackexchange.com/questions/108852/mavericks-window-loses-focus-on-cmdtab Jens

I have the same options checked as you do but the glitch still appears...
Bildschirmfoto_2014-10-27_um_13.06.39.png

I have the same options checked as you do but the glitch still appears... ![Bildschirmfoto_2014-10-27_um_13.06.39.png](https://archive.blender.org/developer/F119922/Bildschirmfoto_2014-10-27_um_13.06.39.png)
Member

Okay, i think i have a solution, try this patch pls:

diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm
index 9e47ea1..a8bab88 100644
--- a/intern/ghost/intern/GHOST_WindowCocoa.mm
+++ b/intern/ghost/intern/GHOST_WindowCocoa.mm
@@ -86,6 +86,7 @@ enum {
 - (void)windowDidBecomeKey:(NSNotification *)notification
 {
        systemCocoa->handleWindowEvent(GHOST_kEventWindowActivate, associatedWindow);
+       [[NSRunningApplication currentApplication] activateWithOptions:(NSApplicationActivateAllWindows | NSApplicationActivateIgnoringOtherApps)];
 }
 
 - (void)windowDidResignKey:(NSNotification *)notification

Atm. checking if this has any unwanted impact.

Jens

Okay, i think i have a solution, try this patch pls: ``` diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm index 9e47ea1..a8bab88 100644 --- a/intern/ghost/intern/GHOST_WindowCocoa.mm +++ b/intern/ghost/intern/GHOST_WindowCocoa.mm @@ -86,6 +86,7 @@ enum { - (void)windowDidBecomeKey:(NSNotification *)notification { systemCocoa->handleWindowEvent(GHOST_kEventWindowActivate, associatedWindow); + [[NSRunningApplication currentApplication] activateWithOptions:(NSApplicationActivateAllWindows | NSApplicationActivateIgnoringOtherApps)]; } - (void)windowDidResignKey:(NSNotification *)notification ``` Atm. checking if this has any unwanted impact. Jens
Member

patch was truncated -> corrected

patch was truncated -> corrected

This works. :)
But it doesn't really go to the root of this problem. Now the window disappears in the background and immediately comes to the top again which looks weird. Also if you have multiple Blender windows and you're in another App and click on one Blender window all Blender windows are brought to the top.

But I agree the issue might be that Blender doesn't get activated but the window still becomes key.

Also I found these:
http://stackoverflow.com/questions/3747715/nswindow-not-activating
http://stackoverflow.com/questions/10759920/cocoa-windows-spawned-from-carbon-windows-are-reordered-by-mission-control
http://apple.stackexchange.com/questions/108852/mavericks-window-loses-focus-on-cmdtab

This works. :) But it doesn't really go to the root of this problem. Now the window disappears in the background and immediately comes to the top again which looks weird. Also if you have multiple Blender windows and you're in another App and click on one Blender window all Blender windows are brought to the top. But I agree the issue might be that Blender doesn't get activated but the window still becomes key. Also I found these: http://stackoverflow.com/questions/3747715/nswindow-not-activating http://stackoverflow.com/questions/10759920/cocoa-windows-spawned-from-carbon-windows-are-reordered-by-mission-control http://apple.stackexchange.com/questions/108852/mavericks-window-loses-focus-on-cmdtab
Member

Okay, try this, i think this is the right appoach:

diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm
index 9e47ea1..283f7a3 100644
--- a/intern/ghost/intern/GHOST_WindowCocoa.mm
+++ b/intern/ghost/intern/GHOST_WindowCocoa.mm
@@ -66,6 +66,7 @@ enum {
 }
 
 - (void)setSystemAndWindowCocoa:(GHOST_SystemCocoa *)sysCocoa windowCocoa:(GHOST_WindowCocoa *)winCocoa;
+- (void)windowDidBecomeMain:(NSNotification *)notification;
 - (void)windowDidBecomeKey:(NSNotification *)notification;
 - (void)windowDidResignKey:(NSNotification *)notification;
 - (void)windowDidExpose:(NSNotification *)notification;
@@ -82,7 +83,10 @@ enum {
        systemCocoa = sysCocoa;
        associatedWindow = winCocoa;
 }
-
+- (void)windowDidBecomeMain:(NSNotification *)notification
+{
+       [[NSRunningApplication currentApplication] activateWithOptions:(NSApplicationActivateAllWindows | NSApplicationActivateIgnoringOtherApps)];
+}
 - (void)windowDidBecomeKey:(NSNotification *)notification
 {
        systemCocoa->handleWindowEvent(GHOST_kEventWindowActivate, associatedWindow);
Okay, try this, i think this is the right appoach: ``` diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm index 9e47ea1..283f7a3 100644 --- a/intern/ghost/intern/GHOST_WindowCocoa.mm +++ b/intern/ghost/intern/GHOST_WindowCocoa.mm @@ -66,6 +66,7 @@ enum { } - (void)setSystemAndWindowCocoa:(GHOST_SystemCocoa *)sysCocoa windowCocoa:(GHOST_WindowCocoa *)winCocoa; +- (void)windowDidBecomeMain:(NSNotification *)notification; - (void)windowDidBecomeKey:(NSNotification *)notification; - (void)windowDidResignKey:(NSNotification *)notification; - (void)windowDidExpose:(NSNotification *)notification; @@ -82,7 +83,10 @@ enum { systemCocoa = sysCocoa; associatedWindow = winCocoa; } - +- (void)windowDidBecomeMain:(NSNotification *)notification +{ + [[NSRunningApplication currentApplication] activateWithOptions:(NSApplicationActivateAllWindows | NSApplicationActivateIgnoringOtherApps)]; +} - (void)windowDidBecomeKey:(NSNotification *)notification { systemCocoa->handleWindowEvent(GHOST_kEventWindowActivate, associatedWindow); ```

This still has the problem that it orders ALL Blender windows on top.

What works for me is this:
[(NSWindow*)associatedWindow->getOSWindow() orderFrontRegardless];

in windowDidBecomeKey

Interestingly [NSApp keyWindow] is nil in windowDidBecomeKey which looks to me like a bug...

This still has the problem that it orders ALL Blender windows on top. What works for me is this: [(NSWindow*)associatedWindow->getOSWindow() orderFrontRegardless]; in windowDidBecomeKey Interestingly [NSApp keyWindow] is nil in windowDidBecomeKey which looks to me like a bug...
diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm
index 9e47ea1..6514c98 100644
--- a/intern/ghost/intern/GHOST_WindowCocoa.mm
+++ b/intern/ghost/intern/GHOST_WindowCocoa.mm
@@ -86,6 +86,9 @@ enum {
 - (void)windowDidBecomeKey:(NSNotification *)notification
 {
        systemCocoa->handleWindowEvent(GHOST_kEventWindowActivate, associatedWindow);
+       
+       *work around for https:*developer.blender.org/T42305
+       [(NSWindow*)associatedWindow->getOSWindow() orderFrontRegardless];
 }
 
 - (void)windowDidResignKey:(NSNotification *)notification
``` diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm index 9e47ea1..6514c98 100644 --- a/intern/ghost/intern/GHOST_WindowCocoa.mm +++ b/intern/ghost/intern/GHOST_WindowCocoa.mm @@ -86,6 +86,9 @@ enum { - (void)windowDidBecomeKey:(NSNotification *)notification { systemCocoa->handleWindowEvent(GHOST_kEventWindowActivate, associatedWindow); + + *work around for https:*developer.blender.org/T42305 + [(NSWindow*)associatedWindow->getOSWindow() orderFrontRegardless]; } - (void)windowDidResignKey:(NSNotification *)notification ```
Member

Do u use the "seperate spaces" option ?

Jens

Do u use the "seperate spaces" option ? Jens

I adjusted my settings so they match yours. So I have "Monitore verwenden verschiedene Spaces" deactivated. Why do you ask?

Edit: tested with the option activated: works, too.

I adjusted my settings so they match yours. So I have "Monitore verwenden verschiedene Spaces" deactivated. Why do you ask? Edit: tested with the option activated: works, too.
Member

Just to assure we are talking about same prelimnaries.
Your tweak looks best atm., i compared with document based apps and the behaviour looks same ( textedit with several docs open ).

So perhaps we can use you diff after checking once over (?).

Jens

Just to assure we are talking about same prelimnaries. Your tweak looks best atm., i compared with document based apps and the behaviour looks same ( textedit with several docs open ). So perhaps we can use you diff after checking once over (?). Jens

Well there's still a small flicker sometimes as if the window gets put to the back in one frame and then to the top. It isn't perfect but basically it works...

Well there's still a small flicker sometimes as if the window gets put to the back in one frame and then to the top. It isn't perfect but basically it works...
Member

Didn't notice, we should get rid of any flicker i think.

Jens

Didn't notice, we should get rid of any flicker i think. Jens

I recorded a video of the flicker. It's just one frame. Also it doesn't always appear.
http://fabioarnold.de/videos/glitch.mov

I recorded a video of the flicker. It's just one frame. Also it doesn't always appear. http://fabioarnold.de/videos/glitch.mov
Author

I just did an update on OS X to 10.10 version. I didn't do a clean installation, I kept every program and settings, and the error seems to be gone. I tried 2.71, 2.72, 2.72a, 2.72b and now I don't get the error. I don't know what this might tell you about the error.

I just did an update on OS X to 10.10 version. I didn't do a clean installation, I kept every program and settings, and the error seems to be gone. I tried 2.71, 2.72, 2.72a, 2.72b and now I don't get the error. I don't know what this might tell you about the error.
Author

Ok so I don't know what is happening but as soon as I sent the last message I started to get the error again on 2.72b.

Ok so I don't know what is happening but as soon as I sent the last message I started to get the error again on 2.72b.

Please note the exact steps to reproduce this problem are:

  1. Press Command+Tab to switch to any other application
  2. Open Mission Control and click on the Blender window
    The Blender window should animate into position and before it finally arrives it will be ordered back into its old position.
Please note the exact steps to reproduce this problem are: 1. Press Command+Tab to switch to any other application 2. Open Mission Control and click on the Blender window The Blender window should animate into position and before it finally arrives it will be ordered back into its old position.
Member

Sorry, was away for some hours.
I must investigate this still a bit, it is not such imminent issue i think,
We should aim a clean solution for 2.73 though.

Jens

Sorry, was away for some hours. I must investigate this still a bit, it is not such imminent issue i think, We should aim a clean solution for 2.73 though. Jens

This issue was referenced by 8dbce41706

This issue was referenced by 8dbce41706be1e4c50d6e0a24db511bdaa37e4f0
Member

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Member

Closed by commit 8dbce41706.

Closed by commit 8dbce41706.
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
7 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#42305
No description provided.