BigZaphod / Chameleon

Chameleon is a port of Apple's UIKit for iOS (and some minimal related frameworks) to Mac OS X.
http://chameleonproject.org/
BSD 3-Clause "New" or "Revised" License
3.45k stars 570 forks source link

UIKitView goes blank after app restart when using fast user switching #76

Open raytrodd opened 12 years ago

raytrodd commented 12 years ago

Users of my application have run into this bug while using fast user switching on mac osx lion. The specific issue occurs when a Chameleon app restarts while the owner is 'switched out' and another user is logged in. This may seem like an odd case, but this occurs when users of my application are "autoupdated" while their user account is 'switched out'.

I have a mac book pro running osx lion.

This is the simplest way to repro: I have a mac book pro running osx lion. 1.) Login to your Mac as 'User A' 1.) Create a new user account 'User B', and ensure that 'fast user switching' is enabled. 2.) Build the BigApple example application, and copy it to ~/Applications 3.) run this command from the command line 'sleep 10 ; open ~/Applications/BigApple.app'. The sleep will give you enough time to execute the next step. 4.) quickly 'fast user switch' to 'User B'. This needs to be completed before the BigApple is launched. 5.) wait for 10 seconds until BigApple is running under 'User A'. 6.) fast user switch back to 'User A'

Expected: You see BigApple running and the screen renders as normal

Actual: You see a blank screen.

It appears the the UIKitView stops rendering all together. The application seems to be responsive and executing, but no UI is being drawn. I have seen a similar issue when the app is running and the machine switches to using the integrated graphics card from the descrete graphics card.

Any help would be appreciated. Perhaps there is a workaround I could employ in these cases to get the view hierarchy re-initialized.

BigZaphod commented 12 years ago

I would actually like to know a solution for this as well. We've had reports of oddities when fast user switching while Twitterrific is the active app. Upon return to the original user, the app is basically frozen or not rendering correctly. Something weird is going on.

On Dec 6, 2011, at 8:37 PM, raytrodd reply@reply.github.com wrote:

Users of my application have run into this bug while using fast user switching on mac osx lion. The specific issue occurs when a Chameleon app restarts while the owner is 'switched out' and another user is logged in. This may seem like an odd case, but this occurs when users of my application are "autoupdated" while their user account is 'switched out'.

I have a mac book pro running osx lion.

This is the simplest way to repro: I have a mac book pro running osx lion. 1.) Login to your Mac as 'User A' 1.) Create a new user account 'User B', and ensure that 'fast user switching' is enabled. 2.) Build the BigApple example application, and copy it to ~/Applications 3.) run this command from the command line 'sleep 10 ; open ~/Applications/BigApple.app'. The sleep will give you enough time to execute the next step. 4.) quickly 'fast user switch' to 'User B'. This needs to be completed before the BigApple is launched. 5.) wait for 10 seconds until BigApple is running under 'User A'. 6.) fast user switch back to 'User A'

Expected: You see BigApple running and the screen renders as normal

Actual: You see a blank screen.

It appears the the UIKitView stops rendering all together. The application seems to be responsive and executing, but no UI is being drawn. I have seen a similar issue when the app is running and the machine switches to using the integrated graphics card from the descrete graphics card.

Any help would be appreciated. Perhaps there is a workaround I could employ in these cases to get the view hierarchy re-initialized.


Reply to this email directly or view it on GitHub: https://github.com/BigZaphod/Chameleon/issues/76

raytrodd commented 12 years ago

Yes, I have also run into the that issue as well. This also repros with the "BigApple" example app. Simply run big apple, switch to a different user, switch back. Clicking on the button now has no effect.

It appears that the events are still being fired, its just that nothing is actually getting rendered. For that specific issue, I found a fairly hacky workaround, which I am using in my application.

Listen for the NSWorkspaceSessionDidBecomeActiveNotification:

[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self
                                                         selector:@selector(switchHandler:)
                                                             name:NSWorkspaceSessionDidBecomeActiveNotification
                                                           object:nil];

In the switch handler, brutally force the view hierarchy to reload:

- (void)switchHandler:(NSNotification*) notification {
    [window setContentView:[window contentView]];
    [chameleonNSView performSelector:@selector(configureLayers)];
}

Unfortunately, this does not solve the issue when the application is actually restarted while switched out. These issues must be related in some way.