NSWindow not redrawing subviews

2017-01-06 Thread Tamas Nagy
Hi List,

I ran into an issues with a multi-thread, multi-window app, where one or more 
windows stop displaying after a while. This happens rarely and on 10.10.5 - at 
least I was not able to reproduce the problem anywhere else.

And by saying a window stop displaying I mean there are subviews that has been 
marked to be fully redrawn by setNeedsDisplay:YES on the main thread, but views 
won’t be redrawn. The window still processing events, so I can click on buttons 
for example which sending their actions, etc. Also if I manually send a 
-display message to [self window] the subviews going to be redrawn once, but 
then they are stuck again.

I’ve overridden setNeedsDisplay: to check out what is going on, and of course 
the views are on a valid NSWindow object, autoDisplay is enabled, and also the 
window returns YES to viewsNeedsDisplay.

When the issue is happening the NSWindow object won’t call -display or 
-displayIfNeeded, so probably this is why the window not getting redrawn.

I’m not sure what could make the NSWindow object to behave this way, maybe I’m 
doing something silly here?

Any insights would be appreciated!

Thanks!

Best,
Tamas 
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

UICollectionView cells sometimes drawn on top of section header

2017-01-06 Thread Steve Christensen
iOS 10.

I'm seeing some odd behavior where occasionally collection view cells are drawn 
on top of their section header view instead of behind it. When I use the view 
inspector in Xcode then I do, in fact, see the cells in front of the section 
header.

These are pretty generic cells that contain an image. The only thing special is 
that the image is loaded asynchronously and then set on the cells UIImageView 
in a completion block on the main thread.

Has anybody else run across this behavior before?


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


AVSimplePlayer in Swift?

2017-01-06 Thread Charles Jenkins
Has anyone recoded Apple's AVSimplePlayer example in Swift?

I’m trying to do that in order to get some AVFoundation experience in
Swift, and I’m having a bit of trouble. I can’t figure out how to do the
bindings to currentTime and duration.


   - If I do them the easy way, using didSet clause, everything works and I
   can play the video and use the Rewind and Fast Forward buttons to alter
   playback rate, but I can’t scrub using the time slider.



   - If I imitate the ObjC version and try to do the bindings in IB, the
   time slider’s maxValue and value bindings don’t work (won’t compile)
   because duration and currentTime are not NSNumbers.



   - And if I change duration and currentTime to computed variables based
   on NSNumber, the video won’t play at all.


Any suggestions?

-- 

Charles
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: AVSimplePlayer in Swift?

2017-01-06 Thread Charles Srstka
> On Jan 6, 2017, at 9:32 PM, Charles Jenkins  wrote:
> 
>   - If I imitate the ObjC version and try to do the bindings in IB, the
>   time slider’s maxValue and value bindings don’t work (won’t compile)
>   because duration and currentTime are not NSNumbers.

They don’t have to be NSNumbers; KVO automatically wraps primitive number types 
in NSNumbers for you. What do you mean by “won’t compile”? IB and KVO all occur 
at runtime, not compile-time.

Anyway, the thing to make sure about is that you’ve declared all KVO-compliant 
properties with the ‘dynamic’ keyword. If you haven’t, that could easily 
account for things not working properly.

Charles

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSWindow not redrawing subviews

2017-01-06 Thread Ken Thomases
On Jan 6, 2017, at 10:14 AM, Tamas Nagy  wrote:
> 
> I ran into an issues with a multi-thread, multi-window app, where one or more 
> windows stop displaying after a while. […]

> And by saying a window stop displaying I mean there are subviews that has 
> been marked to be fully redrawn by setNeedsDisplay:YES on the main thread, 
> but views won’t be redrawn.

You say you're calling -setNeedsDisplay: on the main thread, but other than 
that, what do you mean by "multi-thread, multi-window app"?  Are you doing 
_any_ GUI manipulation from background threads?  If so, what?

> The window still processing events, so I can click on buttons for example 
> which sending their actions, etc. Also if I manually send a -display message 
> to [self window] the subviews going to be redrawn once, but then they are 
> stuck again.
> 
> I’ve overridden setNeedsDisplay: to check out what is going on, and of course 
> the views are on a valid NSWindow object, autoDisplay is enabled, and also 
> the window returns YES to viewsNeedsDisplay.
> 
> When the issue is happening the NSWindow object won’t call -display or 
> -displayIfNeeded, so probably this is why the window not getting redrawn.

Are there any exceptions on the main thread, especially during a window display 
cycle, prior to this happening?

Have you implemented any properties or methods in your window subclass that 
might inadvertently shadow properties or methods of NSWindow?

Are you doing anything unusual with the main application object or its event 
loop or run loop?  Are you permanently running an inner loop inside of an 
event/run loop callout from the main loop?  Have you dispatched a block to the 
main dispatch queue that's still running?

Regards,
Ken


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSWindow not redrawing subviews

2017-01-06 Thread Tamas Nagy
Hi Ken,

> 
> You say you're calling -setNeedsDisplay: on the main thread, but other than 
> that, what do you mean by "multi-thread, multi-window app"?  Are you doing 
> _any_ GUI manipulation from background threads?  If so, what?

This is a video mixer app. There are multiple windows for controlling layers, 
effects, etc. Rendering is done on a CVDisplayLink thread by OpenGL. Whenever I 
need to update something on the UI from that CVDisplayLink thread I call 
dispatch_async(dispatch_get_main…).

But double-checking my code I found sometimes I call [NSSlider cell] 
setFloatValue:] from the CVDisplayLink thread followed by a 
setNeedsDisplayInRect… on the main thread, but [NSSlider cell] setFloatValue:] 
might be already calling setNeedsDisplay…? Than it could be the reason of the 
problem I guess.

Hmm, I should double-check if drawing is always happening from the main thread. 
What is the common way to do that? Can Instruments helpful to debug that? 

> 
> Are there any exceptions on the main thread, especially during a window 
> display cycle, prior to this happening?

No error message at all.

> 
> Have you implemented any properties or methods in your window subclass that 
> might inadvertently shadow properties or methods of NSWindow?

No.

> 
> Are you doing anything unusual with the main application object or its event 
> loop or run loop?  Are you permanently running an inner loop inside of an 
> event/run loop callout from the main loop?  Have you dispatched a block to 
> the main dispatch queue that's still running?

No, it does not seem to anything is blocking the main loop. All other windows 
are updating as expected and everything is running well on the main loop - and 
the problematic window even redraw it’s subviews correctly if I explicitly call 
[NSWindow displayIfNeeded].


Thanks!
Tamas
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSWindow not redrawing subviews

2017-01-06 Thread Ken Thomases
On Jan 7, 2017, at 12:59 AM, Tamas Nagy  wrote:
> 
> This is a video mixer app. There are multiple windows for controlling layers, 
> effects, etc. Rendering is done on a CVDisplayLink thread by OpenGL. Whenever 
> I need to update something on the UI from that CVDisplayLink thread I call 
> dispatch_async(dispatch_get_main…).
> 
> But double-checking my code I found sometimes I call [NSSlider cell] 
> setFloatValue:] from the CVDisplayLink thread followed by a 
> setNeedsDisplayInRect… on the main thread, but [NSSlider cell] 
> setFloatValue:] might be already calling setNeedsDisplay…? Than it could be 
> the reason of the problem I guess.

Yes, I would expect -setFloatValue: to call a -setNeedsDisplay… method and 
therefore it's not valid to call it from a background thread.

> Hmm, I should double-check if drawing is always happening from the main 
> thread. What is the common way to do that? Can Instruments helpful to debug 
> that? 

I'm not aware of any comprehensive way of doing that.

For calls to -setNeedsDisplay… methods, you can try overriding 
-setViewsNeedDisplay: in your window subclass and doing NSAssert([NSThread 
isMainThread], @"views marked as needing display from non-main thread") before 
calling through to super.  Of course, make sure assertions are enabled for your 
build configuration.

Regards,
Ken


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com