Re: Cocoa-dev Digest, Vol 14, Issue 11
Re: Cocoa-dev Digest, Vol 14, Issue 11
- Subject: Re: Cocoa-dev Digest, Vol 14, Issue 11
- From: Ide Sous Le Bois <email@hidden>
- Date: Sun, 08 Jan 2017 05:15:54 +0100
Envoyé de mon smartphone BlackBerry 10.
Message d'origine
De: email@hidden
Envoyé: samedi 7 janvier 2017 21:01
À: email@hidden
Répondre à: email@hidden
Objet: Cocoa-dev Digest, Vol 14, Issue 11
Send Cocoa-dev mailing list submissions to
email@hidden
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.apple.com/mailman/listinfo/cocoa-dev
or, via email, send a message with subject or body 'help' to
email@hidden
You can reach the person managing the list at
email@hidden
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Cocoa-dev digest..."
Today's Topics:
1. UICollectionView cells sometimes drawn on top of section
header (Steve Christensen)
2. AVSimplePlayer in Swift? (Charles Jenkins)
3. Re: AVSimplePlayer in Swift? (Charles Srstka)
4. Re: NSWindow not redrawing subviews (Ken Thomases)
5. Re: NSWindow not redrawing subviews (Tamas Nagy)
6. Re: NSWindow not redrawing subviews (Ken Thomases)
7. Re: NSWindow not redrawing subviews (Tamas Nagy)
----------------------------------------------------------------------
Message: 1
Date: Fri, 06 Jan 2017 14:10:12 -0800
From: Steve Christensen <email@hidden>
To: Cocoa-Dev List <email@hidden>
Subject: UICollectionView cells sometimes drawn on top of section
header
Message-ID: <email@hidden>
Content-Type: text/plain; charset=us-ascii
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?
------------------------------
Message: 2
Date: Fri, 06 Jan 2017 22:32:13 -0500
From: Charles Jenkins <email@hidden>
To: "Cocoa-Dev (Apple)" <email@hidden>
Subject: AVSimplePlayer in Swift?
Message-ID:
<email@hidden>
Content-Type: text/plain; charset=UTF-8
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
------------------------------
Message: 3
Date: Fri, 06 Jan 2017 21:45:03 -0600
From: Charles Srstka <email@hidden>
To: Charles Jenkins <email@hidden>
Cc: "Cocoa-Dev \(Apple\)" <email@hidden>
Subject: Re: AVSimplePlayer in Swift?
Message-ID: <email@hidden>
Content-Type: text/plain; charset=utf-8
> On Jan 6, 2017, at 9:32 PM, Charles Jenkins <email@hidden> 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
------------------------------
Message: 4
Date: Fri, 06 Jan 2017 23:27:04 -0600
From: Ken Thomases <email@hidden>
To: Tamas Nagy <email@hidden>
Cc: Cocoa-Dev List <email@hidden>
Subject: Re: NSWindow not redrawing subviews
Message-ID: <email@hidden>
Content-Type: text/plain; charset=utf-8
On Jan 6, 2017, at 10:14 AM, Tamas Nagy <email@hidden> 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
------------------------------
Message: 5
Date: Sat, 07 Jan 2017 07:59:27 +0100
From: Tamas Nagy <email@hidden>
To: Ken Thomases <email@hidden>
Cc: Cocoa-Dev List <email@hidden>
Subject: Re: NSWindow not redrawing subviews
Message-ID: <email@hidden>
Content-Type: text/plain; charset=utf-8
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
------------------------------
Message: 6
Date: Sat, 07 Jan 2017 01:55:58 -0600
From: Ken Thomases <email@hidden>
To: Tamas Nagy <email@hidden>
Cc: Cocoa-Dev List <email@hidden>
Subject: Re: NSWindow not redrawing subviews
Message-ID: <email@hidden>
Content-Type: text/plain; charset=utf-8
On Jan 7, 2017, at 12:59 AM, Tamas Nagy <email@hidden> 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
------------------------------
Message: 7
Date: Sat, 07 Jan 2017 10:23:27 +0100
From: Tamas Nagy <email@hidden>
To: Ken Thomases <email@hidden>
Cc: Cocoa-Dev List <email@hidden>
Subject: Re: NSWindow not redrawing subviews
Message-ID: <email@hidden>
Content-Type: text/plain; charset=utf-8
Makes sense, thanks Ken!
> On 2017. Jan 7., at 8:55, Ken Thomases <email@hidden> wrote:
>
> On Jan 7, 2017, at 12:59 AM, Tamas Nagy <email@hidden> 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 (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins (at) lists.apple.com
https://lists.apple.com/mailman/listinfo/cocoa-dev
End of Cocoa-dev Digest, Vol 14, Issue 11
*****************************************
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden