Re: Codesign broken in 10.11.4

2016-04-07 Thread Kevin Meaney
This may be relevant, though it does talk about issues with pref panes as well.

http://mjtsai.com/blog/2016/03/31/gatekeeper-bug-in-mac-os-x-10-11-4/

> On 7 Apr 2016, at 15:13, Trygve Inda  wrote:
> 
> My app is built on 10.11.3. It is a prefPane with one command line tool and
> three app bundles (four helper tools) in it's bundle. I am getting
> GateKeeper warnings on 10.11.4 systems, but not on anything else.
> 
> It is manually codesigned with my Developer ID... first the helper tool
> frameworks, then the helper tools themselves and then the prefPane. So
> everything is signed from the inside-out.
> 
> In terminal (on two different machines running 10.11.3) I get:
> 
> spctl -a -t exec -vv My.prefPane
> 
>  /Volumes/Path/To//My.prefPane: accepted
>  source=Developer ID
>  origin=Developer ID Application: My Company, Inc.
> 
> codesign --verbose=4 --deep --strict My.prefPane
> 
>  /Volumes/Path/To//My.prefPane: valid on disk
>  /Volumes/Path/To//My.prefPane: satisfies its Designated Requirement
> 
> 
> In terminal (on two different machines running 10.11.4) I get:
> 
> spctl -a -t exec -vv My.prefPane
> 
>  /Volumes/Path/To//My.prefPane: rejected
>  source=obsolete resource envelope
>  origin=Developer ID Application: My Company, Inc.
> 
> codesign --verbose=4 --deep --strict My.prefPane
> 
>  /Volumes/Path/To//My.prefPane: valid on disk
>  /Volumes/Path/To//My.prefPane: satisfies its Designated Requirement
> 
> 
> The codesign command is taken directly from what Xcode uses:
> 
> codesign --force --sign "Developer ID Application: My Company, Inc."
> --requirements "=designated => anchor apple generic and identifier
> \"com.mycompany.myproduct.helper\" and ((cert
> leaf[field.1.2.840.113635.100.6.1.9] exists) or (certificate
> 1[field.1.2.840.113635.100.6.2.6] exists and certificate
> leaf[field.1.2.840.113635.100.6.1.13] exists and certificate
> leaf[subject.OU] = \"MYAPPLE123\"))" --timestamp=none
> "$BASEPATH/My.prefPane/Contents/Resources/MyHelper.app"
> 
> 
> When I run the above spctl terminal command on the helpers within the bundle
> on 10.11.4, the three helper app bundles are accepted but the command line
> tool is rejected with "obsolete resource envelope".
> 
> If I copy that command line tool to a 10.11.3 system and run spctl, it is
> accepted.
> 
> I have spent more than a day on this and am at a loss as to what is
> happening.
> 
> Any ideas?
> 
> 
> 
> 
> ___
> 
> 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/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.com


___

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: Caching CIContext?

2015-11-27 Thread Kevin Meaney
I can imagine the possibility when the window is in the background with no part 
of the window visible that if the system is under memory pressure (System or 
GPU) that the backing store might be discarded which would then invalidate your 
CIContext.

You could save the pointer to the CGContext at the same time as creating your 
CIContext and then in your draw rect you could get the CGContext again using 
NSGraphicsContext.currentContext.graphicsPort and see if it is different to the 
one saved.

I am not sure that this would be sensible way of keeping track of whether you 
need to update your CIContext or not but it might be useful to help work out 
what is happening.

If you image view does not resize and is not too large a possible solution 
might be to have a bitmap context the size of the image view which is where the 
CIContext draws to and then you draw that to the image view. But that might be 
slower than just recreating the CIContext each time.

Kevin

> On 27 Nov 2015, at 13:39, thatsanicehatyouh...@me.com wrote:
> 
> Hi,
> 
> I have an NSImageView with a custom drawing routine. It works as expected 
> most of the time, but sometimes the image is not drawn - the reason was not 
> obvious. Once when this happened, I opened a popover window and saw that 
> image drawn in its background, so it appears I’m doing something incorrect 
> with the context.
> 
> This view draws a lot, and I heard in a WWDC video that it’s a good idea to 
> cache the context as it’s “expensive” to create. It looks roughly like this:
> 
> - (CIContext*)ciContext
> {
>if (_ciContext == nil) {
>CGContextRef cgContext;
>if (floor(NSAppKitVersionNumber) < NSAppKitVersionNumber10_10) {
>// anything up to 10.9.x
>cgContext = NSGraphicsContext.currentContext.graphicsPort;
>} else {
>// 10.10 or higher
>cgContext = NSGraphicsContext.currentContext.CGContext;
>}
> 
># create context
>_ciContext = [CIContext contextWithCGContext:cgContext ...
>}
>return _ciContext;
> }
> 
> In drawRect:, I use CoreImage to create a CIImage, draw it, then draw an 
> overlay on top of that:
> 
> - (void)drawRect:(NSRect)dirtyRect
> {
>// ... build image, then draw:
>[self.ciContext drawImage:image inRect:inRect fromRect:image.extent];
> 
>// draw overlay, obtaining the CGContextRef the same way as in the 
> CIContext above.
> }
> 
> Another data point: the image overlay is *always* drawn; the CIImage 
> sometimes is not.
> 
> Is it appropriate to cache a CIContext in this way? It feels like I’m missing 
> a lock/unlock, store/restore, or losing the context somewhere, but I’m not 
> sure exactly the correct approach.
> 
> Thanks!
> 
> Demitri
> 
> 
> 
> ___
> 
> 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/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.com


___

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: How to get a condensed San Francisco UIFont?

2015-10-07 Thread Kevin Meaney
I believe the CoreText attributes should work.

The attribute key of kCTFontTraitsAttribute with a value of TraitCondensed 
might do the trick.

Kevin

> On 8 Oct 2015, at 00:01, David Hoerl  wrote:
> 
> I'd like to do is get a condensed - or better yet - a bold (semi-bold) 
> condensed version of the "San Francisco" system font.
> 
> What I propose to do is get a "starter" font:
> 
>  let font = UIFont.preferredFontForTextStyle(UIFontTextStyleHeadline)
> 
> then get the font descriptor:
> 
>  let fd1 = font.fontDescriptor()
> 
> then add a "condensed" attribute:
> 
>  let fd2 = fd1.fontDescriptorByAddingAttributes[ the magic sauce ]
> 
>  let finalFont = UIFont(descriptor: fd2, size: 0)
> 
> My only problem is I don't know the "magic sauce", and there is a darth of 
> information on fontDescriptorByAddingAttributes (google it yourself).
> 
> I sure would appreciate anyone who can tell me, or point me in the right 
> direction, so I can find the "magic sauce" formula.
> 
> - David
> ___
> 
> 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/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.com


___

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: Lost memory, GCD, dispatch sources, ?Cocoa bindings & User interface

2015-09-16 Thread Kevin Meaney
I can't help but think that there should be a way to use xpc services as a nice 
solution to this problem.

Unfortunately xpc services are mostly designed around the idea that if the 
service dies the app can restart it when it needs. Whereas you need the service 
running your experiment and collecting data to stay running even if the app 
displaying the results dies. When the user restarts the application it connects 
to the still running service.

Kevin

Sent from my iPad

> On 16 Sep 2015, at 22:28, Jean Suisse  wrote:
> 
> 
>> But I agree that this all (meaning the contortions to get updates onto the 
>> main thread) seems like too much flash and not enough bang. The easiest way 
>> would be to dispatch the original update code in blocks onto the main thread 
>> asynchronously, thus serializing them and generating KVO notifications 
>> safely. 
> 
> I thought of that at first, to solve the uncommitted CA transactions issues. 
> But the syntax is ugly. And I didn’t want to post blocks from all over the 
> place to the main thread (I have 100+ NSTextfields with number formatters 
> updated every second… meaning as many blocks...).
> So I went for the updateUI solution, which is cleaner: It only requires me to 
> duplicate instance variables. 
> 
> At this point, I would like to add that instance variables (and their 
> UI–bound property counterpart) are mostly double with a few int, so  they 
> aren’t retained objects subjects to leaks.
> 
>> When I think about it in those terms, it’s clear (to me, at least) that the 
>> *real* problem is one of coalescing a potentially large number of updates 
>> over time. In other words, this thread is really about premature 
>> optimization and its ugly consequences.
> 
> The issue, to me, is to get my app to run for a few days without crashing. 
> The only way I have to make it work, currently, is by not updating the UI.
> This is a shame considering the time I spent arranging all those textfields 
> in a nice fashion to make it easily readable despite the large number of 
> displayed values (and also, IB gets really really slow with that many 
> controls on a view, making the design part a real pain).
> 
> ___
> 
> 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/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.com

___

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: Nullability annotation "best practice"

2015-08-16 Thread Kevin Meaney
I’ve annotated the public methods of the API of a framework and though I 
haven’t yet I will annotate internal methods and functions as well.

I found a small number of issues where my thinking had not been clear, and that 
having to stop and consider what was intended when annotating the public API 
for nullability exposed my lack of clarity. I did not have any recorded bugs in 
this case but I could see how the API could be used that would result in bugs, 
crashing or otherwise.

I would not be surprised if the same could be said of the private methods. I 
feel that there is value in annotating the private methods and functions and 
that this value is not insignificant.

The private API is much larger than the public, so a lot more work is required 
and it will probably be done incrementally, but that also means there is likely 
a lot more potential bugs.

I can understand why you might not annotate private methods, but I think a 
blanket ruling does not make sense.

Kevin

> On 16 Aug 2015, at 18:47, Quincey Morris 
>  wrote:
> 
> On Aug 16, 2015, at 09:10 , Seth Willits  wrote:
>> 
>> Really? This list has no opinions? That's hard to imagine :-)
> 
> Well, I do, but I didn’t post it because I didn’t think you’d like it.
> 
> I don’t think it’s worth annotating private methods at all (in general — I’m 
> sure there are specific cases where it’s a clear benefit). It seems to me 
> there are 2 main reasons why you’d want to:
> 
> 1. Documentation/API contract
> 
> When creating methods for *others* to use, such as at the API boundary of a 
> framework, the more clarity the better, and the more the compiler can check 
> the better. But for methods that are internal to an implementation, the 
> chances are that the “client" code will have been written before the 
> nullability is settled — or the nullability is obvious enough that the 
> annotation isn’t needed.
> 
> 2. Swift compatibility
> 
> This is the important case, because the nullability changes the type of the 
> interface when bridged into Swift.
> 
> 
> When neither of the above is a controlling consideration, for the majority of 
> pure Obj-C code, nullability annotations seem rather redundant. I see 3 
> issues:
> 
> a. Origination
> 
> For a method that originates an object pointer — typically an ‘init’ method 
> or a factory class method that basically wraps an ‘init’ — I think it’s 
> better not to return nil at all, in most cases. That is, if super init may 
> itself return nil, then you should test for that and crash, rather than just 
> passing on the nil.
> 
> If the originating method does need to indicate failure by returning nil, the 
> pattern I’ve adopted is *always* to return a NSError via a NSError** 
> parameter in the normal way. Not only is this self-annotating, both in the 
> interface and at every call site, it also promotes proper error handling by 
> making it clear when you’ve left an error unhandled at the call site.
> 
> b. Propagation
> 
> Once you’ve adopted a consistent origination pattern, then propagating object 
> pointers (that is, passing them around as parameters) stops being 
> problematic, mostly, since they mostly aren’t nil by accident …
> 
> c. Optionality
> 
> … except in the the case where you specify nil literally, as in the case of 
> an optional parameter value. Some such cases are already covered by Obj-C 
> coding patterns. For example, if you’re passing a dictionary of options, 
> passing nil instead of an empty dictionary is probably all the same to the 
> called code.
> 
> Sometimes it does matter. For example, when passing a completion block, it 
> really matters whether it can be nil or not, because invoking a nil block 
> pointer will crash. In such cases, the implementation (having decided whether 
> it will check for nil or require non-nil) *should*, I think, annotate the 
> method parameter, but I’d be inclined to do that in *both* the 
> @implementation and @interface if both exist, just like you would for 
> something like ‘const’.
> 
> 
> My argument in all this is that Obj-C has its own characteristic patterns for 
> handling nil object pointers, which may be diverse and situational, but have 
> been honed by time. The new annotations (including NS_DESIGNATED_INITIALIZER 
> and generics) seem to me to be geared towards reducing the impedance mismatch 
> with Swift, and I think it distorts Obj-C to Swift-ize it if it’s not 
> actually being bridged.
> 
> In the relatively rare cases where annotations resolve an existing pain point 
> (such as nil vs. non-nil completion block pointers), then use them. But I’m 
> unconvinced about the need for wholesale adoption.
> 
> 
> 
> ___
> 
> 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/mailma

Re: XPC Services & non-Sandboxed Applications

2015-07-18 Thread Kevin Meaney
Hi

I would watch session Cocoa Interprocess Communication with XPC from WWDC 2012. 
https://developer.apple.com/videos/wwdc/2012/ 
<https://developer.apple.com/videos/wwdc/2012/>
I certainly found it very helpful. I’ve taken quite comprehensive notes from 
that session see:

http://blog.yvs.eu.com/2013/07/cocoa-interprocess-communication-with-xpc/ 
<http://blog.yvs.eu.com/2013/07/cocoa-interprocess-communication-with-xpc/>

But I think you will still get value from watching the video.

Kevin

Kevin Meaney
Zukini Ltd
Sheffield S2 3LN
Company no: 9491832

> On 18 Jul 2015, at 15:26, SevenBits  wrote:
> 
> Hey all,
> 
> I’m currently in the process of re-writing one of my old apps and I have 
> decided to do so using modern Mac technology and APIs. The target is the Mac 
> App Store and thus my app needs to be sandboxed.
> 
> My app, for everyone's sake, is not document-based. The user can open files 
> by dragging them onto my app, or they can open them with the Open menu item. 
> What I’m looking to do is allow the user to press a button and have an 
> external XPC service start which then reads the opened file(s) and deletes 
> them off of the main thread (this is a simplification).
> 
> Since XPC services cannot present UI, I need to find a way to give the XPC 
> service access to the file(s) the user has selected. I know about 
> security-scoped bookmarks, and I have used them before, but I’m not certain 
> how to implement this. First off all:
> 
> 1) Apple’s docs say that non-document based apps don’t get sandboxing support 
> automatically handled for them, requiring the manual use of the NSFile* APIs. 
> Although when the user opens the file that should give my app access, I can’t 
> get this to translate into a working security-scoped bookmark.
> 
> 2) Apple says that app-scoped bookmarks can only be used by apps with the 
> same container as the app that created it. I don’t know if this means that 
> security-scoped bookmark data based across XPC will remain valid inside of 
> the XPC service. On the other hand, document-scoped bookmarks *can* be used 
> by other apps, but can’t point to folders, which might be a deal-breaker for 
> me.
> 
> Can someone enlighten me as to the best way to handle this? Here’s some 
> relevant code snippets:
> 
> - (void)application:(NSApplication *)sender openFiles:(NSArray *)fileNames {
>   NSLog(@"Files dragged on: %@", fileNames);
>   IncinerationWindowController *controller = 
> [[IncinerationWindowController alloc]
> initWithWindowNibName:@“IncinerationWindowController" 
> andListOfFiles:fileNames];
> }
> 
> - (instancetype)initWithWindowNibName:(NSString *)windowNibName 
> andListOfFiles:(NSArray *)dcArray {
>   self = [super initWithWindowNibName:windowNibName];
>   if (self) {
>   self->documentArray = dcArray;
>   self->securityURLArray = [[NSMutableArray alloc] 
> initWithCapacity:dcArray.count];
> 
>   self->isCurrentlyIncinerating = NO;
>   [self createSecurityBookmarks];
>   }
> 
>   return self;
> }
> 
> - (void)createSecurityBookmarks {
>   for (NSString *path in self->documentArray) {
>   NSError *error = nil;
>   NSURL *url = [[NSURL alloc] initFileURLWithPath:path];
> 
>   NSData *bookmarkData = [url 
> bookmarkDataWithOptions:NSURLBookmarkCreationWithSecurityScope 
> includingResourceValuesForKeys:nil relativeToURL:nil error:&error];
>   if (!bookmarkData) {
>   NSLog(@"Failed to create security scoped bookmark: %@", 
> error);
>   } else [securityURLArray addObject:bookmarkData];
>   }
> }
> ___
> 
> 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/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.com

___

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: Problem having a framework working in one of my targets (a screensaver)

2015-07-03 Thread Kevin Meaney
> 
> I don’t know what the executable_path is for a screensaver, you’d think it 
> was very much the same thing. So first simplest option is to work out what 
> that is and then just put the library at the place it expects to be, 
> @executable_path/../Frameworks/. As long as that’s within 
> your bundle somewhere, trivial to do. You can even put it somewhere else and 
> put a symlink in the bundle. 

The @executable_path for the Screen saver will be the path to the executable 
process that loads the OP’s screen saver plugin. in this case ScreenSaverEngine.

> 
> If you want to change it to something like @rpath/whatever then
> 
>   install_name_tool -id @rpath/whatever 

This is where I get confused. In my project not the original posters my 
framework has Installation Directory set to @rpath and everything works as I 
need it to thanks to that Mike Ash article. But if I do otool -D on the 
framework then I see @executable_path … etc. Making me conclude the rpath 
information was stored separately in the binary to the install name so my 
thinking was that modifying the install name wouldn’t help.

Kevin

___

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: Problem having a framework working in one of my targets (a screensaver)

2015-07-03 Thread Kevin Meaney
First result is the mike ash article I included in my first e-mail to this 
thread.

Kevin

> On 3 Jul 2015, at 10:48, Roland King  wrote:
> 
> www.google.com <http://www.google.com/>
> 
> "mike ash install_name_tool”
> 
> 
>> On 3 Jul 2015, at 17:45, Juanjo Conti  wrote:
>> 
>> Could you point me to that articles please?
>> 
>> On Fri, Jul 3, 2015 at 6:38 AM, Roland King > <mailto:r...@rols.org>> wrote:
>> 
>>> On 3 Jul 2015, at 17:29, Kevin Meaney >> <mailto:k...@yvs.eu.com>> wrote:
>>> 
>>> I’m not sure either of those will work.
>>> 
>>> On 3 Jul 2015, at 10:07, Roland King mailto:r...@rols.org>> 
>>> wrote:
>>>> 
>>>> There’s two other options
>>>> 
>>>> 1) Use install_name_tool to change the name in the library to the one you 
>>>> want. If it’s shorter, and it should be as the install name in that 
>>>> library seems rather long, you can do that
>>> 
>>> I don’t think modifying the Installation Directory will work. I’ve checked 
>>> my framework using otool as Juanjo mentioned he did. Building my Framework 
>>> I’ve set Installation Directory to @rpath but the name I see using otool 
>>> still says @executable_path/… etc. so there is some information set 
>>> elsewhere which informs the linker. So I don’t think editing the path using 
>>> install_name_tool will help.
>> 
>> I think it’ll work just fine, that’s what install_name_tool is there for, 
>> that’s what I’ve used it for and many others too. You change the install 
>> name of the thing you’re linking to before you link it and it shows up in a 
>> the right place in the final executable. 
>> 
>> I believe Mike Ash did a series of two great articles on this. 
>> 
>> 
>> 
>> 
>> -- 
>> Juanjo Conti http://goog_2023646312/>@carouselapps.com 
>> <mailto:jjco...@carouselapps.com>>
>> Software Engineer - Carousel Apps <https://carouselapps.com/>
>> 
>> 
>> Carousel Apps Limited, registered in England & Wales with registered number 
>> 7689440 and registered office Unit 2 Artbrand Studios, 7 Leathermarket 
>> Street, London SE1 3HN. Any communication sent by or on behalf of Carousel 
>> App Ltd or any of its subsidiary, holding or affiliated companies or 
>> entities (together "Watu") is confidential and may be privileged or 
>> otherwise protected. If you receive it in error please inform us and then 
>> delete it from your system. You should not copy it or disclose its contents 
>> to anyone. Messages sent to and from Watu may be monitored to ensure 
>> compliance with our internal policies and to protect our business. Emails 
>> are not secure and cannot be guaranteed to be error free. Anyone who 
>> communicates with us by email is taken to accept these risks.
> 

___

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: Problem having a framework working in one of my targets (a screensaver)

2015-07-03 Thread Kevin Meaney
I’m not sure either of those will work.

On 3 Jul 2015, at 10:07, Roland King  wrote:
> 
> There’s two other options
> 
> 1) Use install_name_tool to change the name in the library to the one you 
> want. If it’s shorter, and it should be as the install name in that library 
> seems rather long, you can do that

I don’t think modifying the Installation Directory will work. I’ve checked my 
framework using otool as Juanjo mentioned he did. Building my Framework I’ve 
set Installation Directory to @rpath but the name I see using otool still says 
@executable_path/… etc. so there is some information set elsewhere which 
informs the linker. So I don’t think editing the path using install_name_tool 
will help.

> 2) Craft the way you package your final product so the library IS in that 
> path relative to the executable. 

Except in this case the executable in question will be the screen saver process 
that loads Juanjo’s screensaver plugin.

There is possibly one solution. Modify the name using install_name_tool to 
/Library/Frameworks and install the Framework to /Library/Frameworks.

I still think going to the developers of the framework is the best approach.

Kevin

___

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: Problem having a framework working in one of my targets (a screensaver)

2015-07-03 Thread Kevin Meaney
You are correct making that change would break other apps. I’m not sure what 
the answer is. They might need to build 2 frameworks one with the changed 
installation directory and one without. They might choose to do that for you 
now but in the future, update the installation directory for the framework and 
be clear in release notes that the Runpath Search paths will need to be updated 
in their customers applications.

Kevin

> On 3 Jul 2015, at 09:44, Juanjo Conti  wrote:
> 
> I can do that. What do I ask, to change installation directory to @rpath? 
> Would that break the other apps using it?
> 
> On Fri, Jul 3, 2015 at 5:36 AM, Kevin Meaney  <mailto:k...@yvs.eu.com>> wrote:
> Ah, You might need to talk to the makers of the framework then.
> 
> Kevin
> 
>> On 3 Jul 2015, at 09:27, Juanjo Conti > <mailto:jjco...@carouselapps.com>> wrote:
>> 
>> Paddle.framework is not one of my targets, it's built by a third party, so I 
>> can't change it. It's this 
>> https://github.com/PaddleHQ/Mac-Framework/archive/master.zip 
>> <https://github.com/PaddleHQ/Mac-Framework/archive/master.zip>
>> 
>> On Fri, Jul 3, 2015 at 5:23 AM, Kevin Meaney > <mailto:k...@yvs.eu.com>> wrote:
> 
> 
> 
> 
> -- 
> Juanjo Conti http://goog_2023646312/>@carouselapps.com 
> <mailto:jjco...@carouselapps.com>>
> Software Engineer - Carousel Apps <https://carouselapps.com/>
> 
> 
> Carousel Apps Limited, registered in England & Wales with registered number 
> 7689440 and registered office Unit 2 Artbrand Studios, 7 Leathermarket 
> Street, London SE1 3HN. Any communication sent by or on behalf of Carousel 
> App Ltd or any of its subsidiary, holding or affiliated companies or entities 
> (together "Watu") is confidential and may be privileged or otherwise 
> protected. If you receive it in error please inform us and then delete it 
> from your system. You should not copy it or disclose its contents to anyone. 
> Messages sent to and from Watu may be monitored to ensure compliance with our 
> internal policies and to protect our business. Emails are not secure and 
> cannot be guaranteed to be error free. Anyone who communicates with us by 
> email is taken to accept these risks.

___

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: Problem having a framework working in one of my targets (a screensaver)

2015-07-03 Thread Kevin Meaney
Ah, You might need to talk to the makers of the framework then.

Kevin

> On 3 Jul 2015, at 09:27, Juanjo Conti  wrote:
> 
> Paddle.framework is not one of my targets, it's built by a third party, so I 
> can't change it. It's this 
> https://github.com/PaddleHQ/Mac-Framework/archive/master.zip 
> <https://github.com/PaddleHQ/Mac-Framework/archive/master.zip>
> 
> On Fri, Jul 3, 2015 at 5:23 AM, Kevin Meaney  <mailto:k...@yvs.eu.com>> wrote:

___

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: Problem having a framework working in one of my targets (a screensaver)

2015-07-03 Thread Kevin Meaney
Ah, the clarification helps.

Does that mean the framework you are loading is none of the targets you are 
listing? and that it is built in a different project?

Then you have set Runpath Search paths to @loader... in the correct target 
(Saver) but you need to remove setting Installation Directory to @rpath.

In the project->target that builds the framework you need to set Installation 
Directory to @rpath and rebuild.

Once doing this your screen saver should work. But your Screen Saver app won’t 
run. You will need to set the Runpath Search paths for the Application to 
@loader_path/../Frameworks as well.

Kevin

> On 3 Jul 2015, at 08:51, Juanjo Conti  wrote:
> 
> I think ScreensaverNinja target does not affect Saver target.
> 
> The Saver target builds a screen saver (a plugin in terms of XCode)
> I'm trying to use the Paddle framework in both, a desktop app 
> (ScreensaverNinja target) and in the screensaver (Saver target).
> 
> In the desktop app works and in the screensaver not.
> 
> Was I clear? Is your reply still valid? What else should I try?
> 
> Thanks,
> 


___

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: Problem having a framework working in one of my targets (a screensaver)

2015-07-03 Thread Kevin Meaney
You need to set the Runpath Search paths in your ScreensaverNinja target to 
@loader_path/../Frameworks not the target Saver which I’m assuming is building 
your framework.

I’m assuming here your ScreenSaver is built from the ScreensaverNinja target 
(the one with the application icon).

Kevin

> On Thu, Jul 2, 2015 at 8:22 PM, Juanjo Conti  > wrote:
> Like this? http://i.imgur.com/4L974ZH.png 
> 
> The problem continues. I'll read the article. Thanks.
> 

___

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: Problem having a framework working in one of my targets (a screensaver)

2015-07-02 Thread Kevin Meaney
I had similar issues when wanting to load a framework. My specific problem was 
loading the framework in an application that was then being loaded when I was 
using IBDesignable.

This article by Mike Ash was extremely helpful at understanding what was 
happening.

https://www.mikeash.com/pyblog/friday-qa-2009-11-06-linking-and-install-names.html
 


I think your issue is that when linking your framework you need to set the 
installation directory path to @rpath. You have done half of what you need by 
setting Runpath Search Path to loader_path/../Frameworks. Once your have 
changed the installation directory when building the framework you will also 
need to change the Runpath Search Path when linking your application.

I hope that helps.

Kevin
> On 2 Jul 2015, at 20:12, Juanjo Conti  wrote:
> 
> More on this. It I change the Runpath Search Path for the target in
> question to use loader_path instead of executable_path, the error still
> mention executable_path. Why?
> 
> 

___

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: Simple Swift question

2015-06-30 Thread Kevin Meaney
Also the nifty new defer statement works well along with multiple guards if you 
need to do any cleanup when exiting the scope. The combination is great.

Kevin

> On 29 Jun 2015, at 23:43, Rick Mann  wrote:
> 
> 
>> On Jun 29, 2015, at 15:35 , Jens Alfke  wrote:
>> 
>> The unsightly nesting of the if-lets can be avoided with the nifty new 
>> ‘guard’ statement in Swift 2.
> 
> Ah, yes, that's what I should be using. Thanks!
> 
> 
> -- 
> Rick Mann
> rm...@latencyzero.com
> 
> 
> 
> ___
> 
> 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/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.com


___

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: Obtaining an CIImage from an unbounded CIFilter?

2015-06-21 Thread Kevin Meaney
You crop it using the CICrop filter.

> On 19 Jun 2015, at 22:56, Carl Hoefs  wrote:
> 
> I'm using CoreImage in a Cocoa app and I’m trying to obtain the outputImage 
> (CIImage) of a CICircleSplashDistortion CIFilter. I know that there are 
> certain filters whose output is unbounded, such as this one. So how do I 
> manage such a filter’s outputImage?
> 
> : CGImageProviderCreate: invalid image provider size: 1.79769e+308 x 
> 1.79769e+308.
> : CGImageCreate: invalid image width.
> Overflow allocating bitmap backing store.  Cannot back bitmap with 8589934592 
> bytes per row, 2147483648 height, and 1 planes.
> 

___

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: Language options: Objective-C, Swift, C or C++?

2015-06-16 Thread Kevin Meaney

> The other major problem I ran into — unrelated, but I’m mentioning it in case 
> someone wants to jump in and tell me the easy way — is that I’m trying to use 
> frameworks in order to break the project into modules so that I can use the 
> access controls (private and internal) to keep implementation details of 
> related groups of files out of the grasp of unrelated code. This is in a 
> cross-platform (OS X, iOS) project with shared code. Since the different 
> platforms need different frameworks, and the frameworks/modules have to have 
> different names to tell them apart, I can’t share source code files across 
> platforms because of the “import” statements. Maybe I’m missing something 
> obvious here.
> 

I have a similar related problem.

My cross platform project builds both iOS and OS X Frameworks. I run the same 
test code on the iOS and OS X frameworks. In my swift test code I use #if 
os(iOS) to differentiate.

#if os(iOS)
import UIKit
import MovingImagesiOS
import Photos
#endif

I also have a small number of cases where I use.

#if os(OSX)

and I have a couple of tests that don’t work on the iOS simulator and I use the

#if !(os(iOS) && arch(x86_64))

to exclude.

Kevin

>> And now I know what Kyle looks like too!
> 
> What’s the video?
> 
> 
> 
> ___
> 
> 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/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.com


___

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: [PSA] OSStatus.com -- Error code lookup

2015-05-31 Thread Kevin Meaney
Hi Seth,

Thanks for this. It is a great resource. I just tried to embed a link to a 
search for all the CoreVideo error codes into a tweet, but twitter doesn’t like 
the tick mark as a character in a url. Can you change that?

Kevin

> On 31 May 2015, at 05:46, Michael David Crawford  wrote:
> 
> May I Bear Your Firstborn?
> Michael David Crawford, Consulting Software Engineer
> mdcrawf...@gmail.com 
> http://www.warplife.com/mdc/ 
> 
>   Available for Software Development in the Portland, Oregon Metropolitan
> Area.
> 
> 
> On Sat, May 30, 2015 at 9:38 PM, Seth Willits  > wrote:
>> 
>> I can't tell you how many times over the years I've been frustrated by 
>> having to manually search multiple frameworks' header files to look up what 
>> the symbol or description for an error code value was. (I know 'macerror' 
>> exists, but I have never had any luck with it. I consider it useless.)
>> 
>> I finally got fed up, wrote some code, and made a website. So, here's v1.
>> http://www.osstatus.com/
>> 
>> I hope someone besides me finds it useful. ;-)
>> 
>> 
>> --
>> Seth Willits
>> 
>> 
>> 
>> 
>> ___
>> 
>> 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/mdcrawford%40gmail.com 
>> 
>> 
>> This email sent to mdcrawf...@gmail.com 
> 
> ___
> 
> 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/ktam%40yvs.eu.com 
> 
> 
> This email sent to k...@yvs.eu.com 
___

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: IB_DESIGNABLE - anyone got it to work?

2015-05-12 Thread Kevin Meaney

> On 12 May 2015, at 08:33, Roland King  wrote:
> 
> 
>> On 12 May 2015, at 14:43, Graham Cox  wrote:
>> 
>> I’m exploring the use of the new IB_DESIGNABLE macro to preview a custom 
>> view live in IB.
>> 
>> It keeps complaining that my view is taking too long to draw, over 200mS, 
>> which seems to be a limit built into IB. However, when I measure the time 
>> myself for drawing, it’s nowhere near this long - 10mS max, typically 2mS. 
>> Because of this constant and apparently erroneous complaint, IB doesn’t show 
>> my custom view. I’ve even tried to do some minimal drawing (just filling the 
>> dirty rect) for just the Interface Builder target, but I get the same 
>> problem, so it’s pretty clear that the timeout is nothing to do with my 
>> drawing.
>> 
>> At other times IB complains that the rendering agent “crashed”, though it’s 
>> actually an exception from the bowels of Core Graphics. My usual drawing 
>> code never triggers the same exception, only when it’s drawn by the IB 
>> rendering agent.
>> 
>> Has anyone been able to make this work?
>> 
>> —Graham
> 
> I have been able to make it work but it’s not been a trouble-free experience. 
> There was at least one version of Xcode I couldn’t make it work at all. I’ve 
> had other times that a quit/restart was needed to get it going. 
> 
> I suspect that this is not your problem but I will mention I have a bug 
> report out that the IB render code calls initWithFrame: which isn’t required 
> in Swift and I hadn’t in one case implemented it, so it just crashed, or hung 
> or both. You’re most-likely in obj-c so that is unlikely to be your issue. 
> You could override it anyway just for good measure. 
> 
> The docs and the WWDC video say the custom control must be in a framework but 
> I believe that’s not actually true, or no-longer true as of the released 
> Xcode 6? There was a note somewhere about this but I can’t find it now and 
> neither can google.

Correct, the custom control does not have to be in a framework. I should 
clarify from my previous e-mail that my custom control is not in a Framework, 
but it does call into a framework to do the drawing which is unrelated to any 
IB_DESIGNABLE requirements.

Kevin


___

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: IB_DESIGNABLE - anyone got it to work?

2015-05-12 Thread Kevin Meaney
I am using this in in swift code that then calls into objective-c. I could not 
get it to work at first but that was because the drawing code was in a 
objective-c framework where the framework was being loaded with a run path 
search path that was relative to the application. I had to modify the framework 
path to @rpath and switch to loading it using @loader_path.

It works now, but does seem fragile.

Kevin

Sent from my iPad

> On 12 May 2015, at 07:43, Graham Cox  wrote:
> 
> I’m exploring the use of the new IB_DESIGNABLE macro to preview a custom view 
> live in IB.
> 
> It keeps complaining that my view is taking too long to draw, over 200mS, 
> which seems to be a limit built into IB. However, when I measure the time 
> myself for drawing, it’s nowhere near this long - 10mS max, typically 2mS. 
> Because of this constant and apparently erroneous complaint, IB doesn’t show 
> my custom view. I’ve even tried to do some minimal drawing (just filling the 
> dirty rect) for just the Interface Builder target, but I get the same 
> problem, so it’s pretty clear that the timeout is nothing to do with my 
> drawing.
> 
> At other times IB complains that the rendering agent “crashed”, though it’s 
> actually an exception from the bowels of Core Graphics. My usual drawing code 
> never triggers the same exception, only when it’s drawn by the IB rendering 
> agent.
> 
> Has anyone been able to make this work?
> 
> —Graham
> 
> 
> 
> ___
> 
> 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/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.com

___

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: Rotate a standard Cocoa control?

2015-05-10 Thread Kevin Meaney
I have recently done something similar for an angular slider. Like Graham the 
control responds to the scroll wheel. But as well I allow changing of the value 
by holding down the command key when moving the mouse.

Tracking a circular path is much easier if you are not at the same time holding 
down the mouse button down. Also to make it easier for the user the value is 
determined purely from the angle which is calculated from the center of the 
control rather than the user having to hold the mouse exactly within the track 
whilst moving. I also use Dave DeLong’s maths parser to calculate the value 
from the position so that the relationship between position and value just 
requires the evaluation of the equation.

Kevin

> On 10 May 2015, at 05:38, Steve Mills  wrote:
> 
> On May 9, 2015, at 23:20:08, Graham Cox  wrote:
>> 
>> Me too, which is why it does :)
> 
> Heh, I didn’t notice that before. One thing I’d suggest: When the knob is set 
> to stop on tick marks, the scroll event should take it immediately to the 
> next/prev tick instead of waiting for the float value to get close enough to 
> the next tick value.
> 
> I also found it a bit disconcerting that the inc/dec action was dependent on 
> whether you mouseDown’d on the left or right side. I usually just aim for the 
> center, then click and drag, so that would make upward drags increase 
> sometimes and decrease other times. I kinda expect an upward drag to always 
> increase, because at this point, where a vertical drag will rotate a knob, 
> we’ve gone beyond trying to simulate a real-world action that’s easier done 
> with fingers, and instead going with an action that’s easier to do with the 
> mouse. Know what I mean?
> 
> --
> Steve Mills
> Drummer, Mac geek
> 
> 
> ___
> 
> 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/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.com


___

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: Why is NSString.UTF8String unavailable in Swift?

2015-03-21 Thread Kevin Meaney


Sent from my iPad

> On 21 Mar 2015, at 23:41, Jens Alfke  wrote:
> 
> 
>> On Mar 21, 2015, at 2:13 PM, Quincey Morris 
>>  wrote:
>> 
>> Well, “String” is not “NSString”.
> 
> Sure, but it’s bridged with NSString. The “Using Swift With Cocoa” book says: 
> “Swift automatically bridges between the String type and the NSString class. 
> This means that anywhere you use an NSString object, you can use a Swift 
> String type instead  … you should almost never need to use the NSString class 
> directly in your own code.”

But the bridging only happens if you import Foundation, otherwise there is no 
NSString to bridge with.

> 
>>var str = "Hello, playground” as NSString
>>str.cStringUsingEncoding(NSUTF8StringEncoding) // OK
>>str.UTF8String  // OK
> 
> -cStringUsingEncoding: and several other NSString methods I’ve tried work 
> without the “as NSString” trick; what’s special about “UTF8String”?
> 
> —Jens
> ___
> 
> 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/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.com

___

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: Mac OS X - Inter-Application Communications

2015-03-06 Thread Kevin Meaney

> On 6 Mar 2015, at 11:34, Dave  wrote:
> 
> Hi,
> 
>> I think you might need to provide some more info about your architecture and 
>> I also think you need to ask your questions in the xpc devforums list: 
>> https://devforums.apple.com/community/mac/coreos/xpc 
>>  because if you get an 
>> answer there it is more likely to be well informed.
> 
> Thanks Kevin, I’ll take a look at the XPC forum.
> 
>> I am a little confused by your terminology. I’d call an Application a 
>> process that a user interacts with (that displays the menu bar) but I 
>> wouldn’t call the four items listed above Applications.
> 
> 
> Yes, it is confusing and I think I called it this because it’s referred to as 
> a “Faceless Background Application” (FBA) in some places. I’ve just started 
> this project and I’m a little confused about some of the things I need to do 
> myself, but I think I have it clear in my head what is needed now, there are 
> two things that are needed:
> 
> 1.  Have some kind of background monitor (FBA?) that detects certain 
> conditions and when a trigger condition is met, send it to a regular Mac 
> Application (with a UI). There is no need for any of the Application(s) to 
> send anything to this FBA. 

This approach will awkward to implement because it is opposite to the way XPC 
is designed. The XPC design is intended for a process such as a (LoginItem, 
LaunchAgent, LaunchDaemon, XPC service) to provide a service, so when your GUI 
Application needs a task to be done that is provided by a service it sends that 
service a message which the service handles and then sends a reply back to the 
application using the connection initiated by the application.

It is likely possible to achieve the opposite goal by the application first 
sending a message to your monitor and the monitor keeps the connection open, 
details of how to achieve this other than just waiting to reply until the 
monitor trigger condition is met I can’t help with. 

> 
> 2.  Have some kind of “Service" that owns an SQLite database and allows other 
> applications to send read/write requests to it.

This would be a launch agent or a login item.

> 
> I was confusing the two before, probably because in the specification I have, 
> the two are shown as one unit.  At the moment I am concentrating on the 
> Monitor (1) above, as the database manager is not needed until further on in 
> the project.
> 
> Given the that I have two “applications” (for want of a better term) 
> LTWMonitor and LTWAppX, then on the face of it and ignoring any OS 
> requirements for the moment, this is what needs to happen:
> 
> LTWMonitor will be Launched when the User Logs.
> LTWMonitor will then launch LTWAppX as part of its initialisation. 
> LTWAppX will launch and do nothing, waiting for an “Event” from LTWMonitor.

If I was you I would consider putting your LTWAppX in the list of the users 
login items and after it starts it launches the monitor by sending the monitor 
a XPC request.

> 
> Once this has happened:
> 
> If LTWMonitor detects a Trigger condition, it will send it to LTWAppX.
> When LTWAppX receives the message from LTWMonitor, it take the appropriate 
> Actions (e.g. display an appropriate UI) for the message received.
> 
> Given this, should I be considering XPC for the UIMonitor? One concern I have 
> it what it needs to be very responsive and as far as I know XPC is the 
> fastest solution and is the preferred modern way of achieving this.

Performance wise I am happy with XPC but then your requirements may be 
different.

Kevin


___

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: Mac OS X - Inter-Application Communications

2015-03-05 Thread Kevin Meaney
On 5 Mar 2015, at 19:29, Dave  wrote:
> 
> Hi,
> 
> I’m really confused as it what type of a Application I need to create, from 
> reading the "Daemons and Services Programming Guide", it lists:
> 
> Login Item.
> XPC Service.
> Launch Daemon.
> Lauch Agent.
> 
> On the face of it, a LogIn Item seems to be what i am looking for, but its 
> unclear (at least to me) if I can host an XPC service inside this type of 
> application?

I think you might need to provide some more info about your architecture and I 
also think you need to ask your questions in the xpc devforums list: 
https://devforums.apple.com/community/mac/coreos/xpc 
 because if you get an 
answer there it is more likely to be well informed.

I am a little confused by your terminology. I’d call an Application a process 
that a user interacts with (that displays the menu bar) but I wouldn’t call the 
four items listed above Applications.

The four items you listed above can all communicate using the XPC interprocess 
communication protocol but I doubt you’ll be able to install an XPC service 
within any of them and work with that as well. 

> 
> I noticed in XCode 6, you can create an XPC Service Application, so I created 
> one, compiled it and placed the Application file in Startup Items, it seems 
> to load up ok, at least I get a terminal window opened pointing to the App’s 
> bundle.
> 
> I am not intending on Sandboxing this.

I’m fairly certain that the XPC Service requires the Application that contains 
it has to be sandboxed. I would recommend for confirmation that you follow this 
up on the devforums list linked to above.

> 
>> I think as long as the OP is not intending to sandbox then using a 
>> LaunchAgent or LoginItem for communicating with a XPC will work but I doubt 
>> that using an XPC service will do this.
> 
> I’m not sure what you mean by this? 

OP is Original Poster which is you, and later on in that sentence I confused 
things. Let me rephrase:

I think as long as Dave is not intending to sandbox his Application then using 
a LaunchAgent or LoginItem for communicating via XPC will work but I doubt that 
an XPC service will do this.

I struggled badly with this about 20 months ago. The documentation is either 
directed at people writing XPC services in sandboxed applications or written 
for unix developers used to writing daemons and describes how to achieve 
similar goals on OSX using language unix developers would understand, whereas 
writing LaunchAgents or LoginItems fit somewhere between the two. Persistence 
does win out. I wish I could be more certain in my replies but 20 months is 
long enough for certain details to be forgotten.

Kevin

___

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: Mac OS X - Inter-Application Communications

2015-03-03 Thread Kevin Meaney
On 3 Mar 2015, at 16:56, Kyle Sluder  wrote:
> 
> On Tue, Mar 3, 2015, at 05:50 AM, Dave wrote:
>> I have the high level flow worked out now, but I’m not sure of what to
>> use in order to Send Events between my Applications and whether I need to
>> have one App (e.g. the Background App or another dedicated
>> “DatabaseManager” Background App) solely responsible for accessing the
>> database so as to ensure it’s in sync and that updates are run in the
>> correct order.
>> 
>> I was thinking of using IPC/XPC as a means of doing this and I’m reading
>> “Daemons and Services Programming Guide”.
>> 
>> Any advice or suggestions as to best way of achieving this would be
>> greatly appreciated.
> 
> The modern way to do this would be to have an XPC service exclusively
> own the database, and have all other applications talk to the XPC
> service to request data.

I think as long as the OP is not intending to sandbox then using a LaunchAgent 
or LoginItem for communicating with a XPC will work but I doubt that using an 
XPC service will do this. You might just be able to make it work using XPC 
services for example if you have one all encompassing sandboxed App which 
contains multiple XPC services that do different tasks.

You might find the WWDC session 308 from 2012 useful.

I’ve an example project on github for a launch agent that uses XPC. I’m sorry I 
haven’t updated since implementing in Xcode 5. 
https://github.com/SheffieldKevin/LaunchAgent

Kevin



___

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: Human-understandable process name

2015-02-13 Thread Kevin Meaney
Apologies. Having just reread that forum post rather than working from what I 
remembered it is about the relationship between the processes rather than 
process names.

You might still we'll be in luck.

Kevin

Sent from my iPad

> On 13 Feb 2015, at 21:05, Andrew Keller  wrote:
> 
> Hello all,
> 
> I’m not sure if this is the correct list, but I figure I’ll start somewhere.
> 
> I’m writing a program that collects activity statistics on other running 
> programs (in particular, network usage statistics).  I have already 
> successfully harvested the statistics I want, organized by the PID and name 
> of the process, however I’d like to do a better job communicating this 
> information to the user.  I am intrigued by Mac OS 10.10’s ability to report 
> “Apps using significant energy”; it seems to have the ability to get a 
> commonly understood human-readable program name, even when the process in 
> question is a helper app with a different name.  Is this ability replicable 
> in third party applications?
> 
> Thanks,
> - Andrew Keller
> 
> 
> ___
> 
> 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/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.com

___

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: Human-understandable process name

2015-02-13 Thread Kevin Meaney
The answer to this question on devforums suggests you might be out of luck. 
https://devforums.apple.com/message/1092608#1092608

Sent from my iPad

> On 13 Feb 2015, at 21:05, Andrew Keller  wrote:
> 
> Hello all,
> 
> I’m not sure if this is the correct list, but I figure I’ll start somewhere.
> 
> I’m writing a program that collects activity statistics on other running 
> programs (in particular, network usage statistics).  I have already 
> successfully harvested the statistics I want, organized by the PID and name 
> of the process, however I’d like to do a better job communicating this 
> information to the user.  I am intrigued by Mac OS 10.10’s ability to report 
> “Apps using significant energy”; it seems to have the ability to get a 
> commonly understood human-readable program name, even when the process in 
> question is a helper app with a different name.  Is this ability replicable 
> in third party applications?
> 
> Thanks,
> - Andrew Keller
> 
> 
> ___
> 
> 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/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.com

___

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: Crash in libsystem_kernel.dylib`__workq_kernreturn:

2015-01-25 Thread Kevin Meaney
What are you using for memory management then? Manual, GC?

Sent from my iPad

On 25 Jan 2015, at 22:57, Trygve Inda  wrote:

>>> On Jan 25, 2015, at 12:33 , Trygve Inda  wrote:
>>> 
>>> It does seem like if I remove a call to
>>> 
>>> NSData* imageData = [[self myImageRep]
>>> representationUsingType:NSJPEGFileType properties:imageProperties];
>>> 
>>> It no longer crashes, but the crash happens 3-5 seconds after this call when
>>> my program should be idle.
>> 
>> It sounds like a memory management bug. What’s the context of the above line
>> of code? Is it in a block? Are you using ARC?
> 
> No ARC and not in a block. I am trying to make a jpg file from a
> NSBitmapImageRep which works fine, but sometimes I get a crash... Even
> though the file is correctly produced.
> 
> 
> 
> 
> 
> ___
> 
> 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/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.com

___

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: CVPixelBuffer and Color profiles

2015-01-19 Thread Kevin Meaney
And what I wrote is here: 
https://github.com/SheffieldKevin/attributesforpreset/blob/master/attributesforpreset/output.txt


Sent from my iPad

> On 20 Jan 2015, at 01:39, Kevin Meaney  wrote:
> 
> Forgot to mention. I wrote a little something a few days ago that iterates 
> through the export presets and prints out the audio and video settings.
> 
> It uses a private Apple API so it's not for production code but the output is 
> useful to look at. It was the output from this command line tool that led me 
> to the Wikipedia pages.
> 
> Kevin
> 
> Sent from my iPad
> 
>> On 19 Jan 2015, at 17:53, Quincey Morris 
>>  wrote:
>> 
>>> On Jan 19, 2015, at 04:02 , Kevin Meaney  wrote:
>>> 
>>> What I'd like to be able to do is to compare profiles obtained this way 
>>> with what I think must be AVFoundation's equivalent e.g.:
>>> 
>>>AVVideoColorPropertiesKey : [
>>>AVVideoColorPrimariesKey : AVVideoColorPrimaries_ITU_R_709_2,
>>>AVVideoTransferFunctionKey : 
>>> AVVideoTransferFunction_ITU_R_709_2,
>>>AVVideoYCbCrMatrixKey : AVVideoYCbCrMatrix_ITU_R_601_4
>>>],
>>> 
>>> But the documentation is so poor, I do not understand what things like 
>>> AVVideoColorPrimaries_ITU_R_709_2 mean, Apple docs don't help and my duck 
>>> duck go searches haven't helped.
>> 
>> Yes, this sucks, but it’s not quite Apple’s fault. This area (colorspaces) 
>> is a morass of disconnected information, and you have no real alternative to 
>> putting it together yourself. Each information source has different 
>> assumptions about your prior knowledge, your intentions and your workflow, 
>> and so doesn’t bother to connect its information to anything else. In many 
>> cases, you can’t even tell for sure which *direction* data is moving, let 
>> alone what’s happening to it.
>> 
>> Wikipedia is a good place to start. “ITU_R_709_2” refers to ITU Rec. BT-709:
>> 
>>  http://en.wikipedia.org/wiki/Rec._709
>> 
>> “ITU_R_601” is ITU Rec. BT-601:
>> 
>>  http://en.wikipedia.org/wiki/Rec._601
>> 
>> These are broadcast TV standards, and therefore (of course) integral to 
>> movie-making, because … kittens. 709 is HD, 601 is SD. Color primaries are a 
>> way of describing a color space, so (in combination with information from 
>> another color space) can be used to derive a method of converting from one 
>> color space to another. Transfer functions and matrixes are each an entire 
>> method of converting HD or SD colors to RGB. (RGB in what colorspace? Beats 
>> me. Just RGB, because … fluffy kittens.)
>> 
>>> When I get info about a movie file in Finder some will include a color 
>>> profile name e.g.: HD (1-1-1)
>>> If I get info for an image file created from a movie using 
>>> AVAssetImageGenerator then the profile name is: Composite NTSC. But I have 
>>> no idea how to get this information in code. CGColorSpaceCopyName doesn't 
>>> work as it is only returns a string from a CGColorSpace created with 
>>> CGColorSpaceCreateWithName.
>>> 
>>> What I'd like to know is, is the color profile of the image generated from 
>>> an imported movie the same as the color profile equivalent for the movie 
>>> (see AVFoundation color property keys above) I'm creating from individual 
>>> frames? It would be ideal if I could keep everything using the same profile 
>>> color space in my processing pipeline.
>> 
>> Because different color space names may imply different underlying color 
>> space conversion technologies, about all a mere mortal can do is compare 
>> names. However, I’m not sure what “keep” means in that last sentence. If you 
>> have an input image file, it already has a color space (explicit or 
>> implied). Your output movie has a color space that you specified when you 
>> started. If they don’t match, there’s nothing you can do to “keep” them the 
>> same, you simply have to do a conversion.
>> 
>> It’s the AVAssetWriter’s job to make the conversion for you. The point is 
>> you don’t *want* to deal with anything beyond that.
>> 
>> “It’s kittens all the way down.”
>> 
___

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: CVPixelBuffer and Color profiles

2015-01-19 Thread Kevin Meaney
Forgot to mention. I wrote a little something a few days ago that iterates 
through the export presets and prints out the audio and video settings.

It uses a private Apple API so it's not for production code but the output is 
useful to look at. It was the output from this command line tool that led me to 
the Wikipedia pages.

Kevin

Sent from my iPad

> On 19 Jan 2015, at 17:53, Quincey Morris 
>  wrote:
> 
>> On Jan 19, 2015, at 04:02 , Kevin Meaney  wrote:
>> 
>> What I'd like to be able to do is to compare profiles obtained this way with 
>> what I think must be AVFoundation's equivalent e.g.:
>> 
>>AVVideoColorPropertiesKey : [
>>AVVideoColorPrimariesKey : AVVideoColorPrimaries_ITU_R_709_2,
>>AVVideoTransferFunctionKey : 
>> AVVideoTransferFunction_ITU_R_709_2,
>>AVVideoYCbCrMatrixKey : AVVideoYCbCrMatrix_ITU_R_601_4
>>],
>> 
>> But the documentation is so poor, I do not understand what things like 
>> AVVideoColorPrimaries_ITU_R_709_2 mean, Apple docs don't help and my duck 
>> duck go searches haven't helped.
> 
> Yes, this sucks, but it’s not quite Apple’s fault. This area (colorspaces) is 
> a morass of disconnected information, and you have no real alternative to 
> putting it together yourself. Each information source has different 
> assumptions about your prior knowledge, your intentions and your workflow, 
> and so doesn’t bother to connect its information to anything else. In many 
> cases, you can’t even tell for sure which *direction* data is moving, let 
> alone what’s happening to it.
> 
> Wikipedia is a good place to start. “ITU_R_709_2” refers to ITU Rec. BT-709:
> 
>   http://en.wikipedia.org/wiki/Rec._709
> 
> “ITU_R_601” is ITU Rec. BT-601:
> 
>   http://en.wikipedia.org/wiki/Rec._601
> 
> These are broadcast TV standards, and therefore (of course) integral to 
> movie-making, because … kittens. 709 is HD, 601 is SD. Color primaries are a 
> way of describing a color space, so (in combination with information from 
> another color space) can be used to derive a method of converting from one 
> color space to another. Transfer functions and matrixes are each an entire 
> method of converting HD or SD colors to RGB. (RGB in what colorspace? Beats 
> me. Just RGB, because … fluffy kittens.)
> 
>> When I get info about a movie file in Finder some will include a color 
>> profile name e.g.: HD (1-1-1)
>> If I get info for an image file created from a movie using 
>> AVAssetImageGenerator then the profile name is: Composite NTSC. But I have 
>> no idea how to get this information in code. CGColorSpaceCopyName doesn't 
>> work as it is only returns a string from a CGColorSpace created with 
>> CGColorSpaceCreateWithName.
>> 
>> What I'd like to know is, is the color profile of the image generated from 
>> an imported movie the same as the color profile equivalent for the movie 
>> (see AVFoundation color property keys above) I'm creating from individual 
>> frames? It would be ideal if I could keep everything using the same profile 
>> color space in my processing pipeline.
> 
> Because different color space names may imply different underlying color 
> space conversion technologies, about all a mere mortal can do is compare 
> names. However, I’m not sure what “keep” means in that last sentence. If you 
> have an input image file, it already has a color space (explicit or implied). 
> Your output movie has a color space that you specified when you started. If 
> they don’t match, there’s nothing you can do to “keep” them the same, you 
> simply have to do a conversion.
> 
> It’s the AVAssetWriter’s job to make the conversion for you. The point is you 
> don’t *want* to deal with anything beyond that.
> 
> “It’s kittens all the way down.”
> 
___

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: CVPixelBuffer and Color profiles

2015-01-19 Thread Kevin Meaney

On 19 Jan 2015, at 17:53, Quincey Morris  
wrote:

> On Jan 19, 2015, at 04:02 , Kevin Meaney  wrote:
>> 
>> What I'd like to be able to do is to compare profiles obtained this way with 
>> what I think must be AVFoundation's equivalent e.g.:
>> 
>>AVVideoColorPropertiesKey : [
>>AVVideoColorPrimariesKey : AVVideoColorPrimaries_ITU_R_709_2,
>>AVVideoTransferFunctionKey : 
>> AVVideoTransferFunction_ITU_R_709_2,
>>AVVideoYCbCrMatrixKey : AVVideoYCbCrMatrix_ITU_R_601_4
>>],
>> 
>> But the documentation is so poor, I do not understand what things like 
>> AVVideoColorPrimaries_ITU_R_709_2 mean, Apple docs don't help and my duck 
>> duck go searches haven't helped.
> 
> Yes, this sucks, but it’s not quite Apple’s fault. This area (colorspaces) is 
> a morass of disconnected information, and you have no real alternative to 
> putting it together yourself. Each information source has different 
> assumptions about your prior knowledge, your intentions and your workflow, 
> and so doesn’t bother to connect its information to anything else. In many 
> cases, you can’t even tell for sure which *direction* data is moving, let 
> alone what’s happening to it.
> 
> Wikipedia is a good place to start. “ITU_R_709_2” refers to ITU Rec. BT-709:
> 
>   http://en.wikipedia.org/wiki/Rec._709
> 
> “ITU_R_601” is ITU Rec. BT-601:
> 
>   http://en.wikipedia.org/wiki/Rec._601

I've read those articles recently, but well kittens could get as much practical 
information out of them as I have in terms of understanding how this fits 
together within AV Foundation.

>> 
>> What I'd like to know is, is the color profile of the image generated from 
>> an imported movie the same as the color profile equivalent for the movie 
>> (see AVFoundation color property keys above) I'm creating from individual 
>> frames? It would be ideal if I could keep everything using the same profile 
>> color space in my processing pipeline.
> 
> Because different color space names may imply different underlying color 
> space conversion technologies, about all a mere mortal can do is compare 
> names. However, I’m not sure what “keep” means in that last sentence. If you 
> have an input image file, it already has a color space (explicit or implied). 
> Your output movie has a color space that you specified when you started. If 
> they don’t match, there’s nothing you can do to “keep” them the same, you 
> simply have to do a conversion.
> 
> It’s the AVAssetWriter’s job to make the conversion for you. The point is you 
> don’t *want* to deal with anything beyond that.

If I'm reading frames from a HD video, doing some processing of those frames 
and writing a HD video with those frames there is a good chance input and 
output are using the same profile. When that is the case I'd like not to do 
unnecessary color space conversions.

> “It’s kittens all the way down.”

More kittens are always part of the solution.

Kevin

___

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: CVPixelBuffer and Color profiles

2015-01-19 Thread Kevin Meaney
Thanks Quincey,

I've now pulled a color profile from a CVPixelBuffer obtained from iterating 
through video frames of a movie file which I can use when creating my 
CGBitmapContext which I hadn't been doing before so I'm sure this will also 
work going the other way.

What I'd like to be able to do is to compare profiles obtained this way with 
what I think must be AVFoundation's equivalent e.g.:

AVVideoColorPropertiesKey : [
AVVideoColorPrimariesKey : AVVideoColorPrimaries_ITU_R_709_2,
AVVideoTransferFunctionKey : 
AVVideoTransferFunction_ITU_R_709_2,
AVVideoYCbCrMatrixKey : AVVideoYCbCrMatrix_ITU_R_601_4
],

But the documentation is so poor, I do not understand what things like 
AVVideoColorPrimaries_ITU_R_709_2 mean, Apple docs don't help and my duck duck 
go searches haven't helped.

When I get info about a movie file in Finder some will include a color profile 
name e.g.: HD (1-1-1)
If I get info for an image file created from a movie using 
AVAssetImageGenerator then the profile name is: Composite NTSC. But I have no 
idea how to get this information in code. CGColorSpaceCopyName doesn't work as 
it is only returns a string from a CGColorSpace created with 
CGColorSpaceCreateWithName.

What I'd like to know is, is the color profile of the image generated from an 
imported movie the same as the color profile equivalent for the movie (see 
AVFoundation color property keys above) I'm creating from individual frames? It 
would be ideal if I could keep everything using the same profile color space in 
my processing pipeline.

Kevin

On 19 Jan 2015, at 01:56, Quincey Morris  
wrote:

> On Jan 18, 2015, at 17:22 , Kevin Meaney  wrote:
>> 
>> How can I make sure that the CGBitmapContext and CVPixelBuffer view the 
>> pixel data in the same way from a color matching perspective?
> 
> You can attach a color space to the pixel buffer as follows:
> 
>   CVBufferSetAttachment (pixelBuffer, kCVImageBufferCGColorSpaceKey, …, 
> kCVAttachmentMode_ShouldNotPropagate);
> 
> Depending on what you do next, I would expect the pixel buffer data to either 
> be converted to a destination color space, or to have its color space 
> propagated to the destination. (Note that the attachment mode “should not 
> propagate” refers to something unrelated, AFAIK. But I’m not an expert on any 
> of this.)
> 


___

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

CVPixelBuffer and Color profiles

2015-01-18 Thread Kevin Meaney
I would like to have a CVPixelBuffer function that returns the color profile of 
a CVPixelBuffer. I'm using the CVPixelBuffer data as a backing store when I 
create a CGBitmapContext and I would like to provide the appropriate color 
profile when I create the CGBitmapContext. The CVPixelBuffer is created from a 
CVPixelBufferPool which itself is created from an 
AVAssetWriterInputPixelBufferAdaptor.

Since my desire/need for the CVPixelBuffer function that returns a color 
profile that can be used as input for creating a CGBitmapContext is 
unfulfilled. How can I make sure that the CGBitmapContext and CVPixelBuffer 
view the pixel data in the same way from a color matching perspective?

Kevin

Sent from my iPad
___

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: Debugging memory leak in NSURLSession with ARC

2015-01-13 Thread Kevin Meaney
leaks, not bugs.

Kevin

On 13 Jan 2015, at 10:21, Kevin Meaney  wrote:

> On 13 Jan 2015, at 02:51, Graham Cox  wrote:
>> 
>>> On 13 Jan 2015, at 12:21 pm, Roland King  wrote:
>>> 
>>> Did you read the devforums thread I pointed you at a couple of weeks ago?
>> 
>> 
>> Umm, not sure Roland. I read the blog post by bbum about using Allocations, 
>> which is the one you linked in this thread. Did you mean something else? 
>> Forgive me, I can't locate the link if so.
>> 
>> If you're referring to bbum's post, I read that. I'm assuming that 
>> "heapshot" is now labelled "mark generations" but otherwise is the same 
>> thing. The problem with this in my case is that a "generation" is a new URL 
>> download and that's fired off automatically by either the previous one 
>> completing or a timer that's set to a variable time based on the "target 
>> time" of the playlist entry. There's no clear means for me to hit "mark 
>> generation" at exactly the right time. That might not matter all that much 
>> in that the process is continuous, so as long as I'm downloading a stream at 
>> a fairly steady rate, and hit the button at regular intervals, there should 
>> be a reasonable similarity between runs.
>> 
>> Doing that, I get inconclusive results. Most of the memory that is left is 
>> like this:
>> 
>> Snapshot Timestamp   Growth  # Persistent
>> Generation B 01:32.780.375   2.09 MB 38
>> VM: Performance tool data2.08 MB 4
>> 0x116816000  01:13.421.801   532.00 KB
>> 0x1162ed000  01:32.145.259   532.00 KB
>> 0x11614  01:23.051.011   532.00 KB
>> 0x1161e5000  01:02.847.030   532.00 KB
>> 
>> 
>> Which suggests it's memory allocated by Allocations itself.
>> 
>> But where I'm checking this over longer time periods isn't in Instruments at 
>> all, but in Xcode's memory viewer. Unfortunately that doesn't give me a 
>> breakdown, just an overall usage.
> 
> I went through a similar painful process in early November hunting down bugs. 
> I'm not using NSURLConnection so I can't really comment about that API and 
> I'm working on OS X. This comment and the remarks a little later in this 
> thread referring to Quinn triggered a recollection.
> 
> In desperation I looked at things using Activity Monitor's memory section and 
> turned on the columns Real Mem, Shared Mem, and Purgeable Mem. In my case 
> what I was seeing as a leak matched with the memory marked as purgeable.
> 
> Exactly what is meant by purgeable I don't know beyond the obvious.
> 
> Kevin
> 
> 
> 
> 
> 
> ___
> 
> 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/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.com

___

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: Debugging memory leak in NSURLSession with ARC

2015-01-13 Thread Kevin Meaney
On 13 Jan 2015, at 02:51, Graham Cox  wrote:
> 
>> On 13 Jan 2015, at 12:21 pm, Roland King  wrote:
>> 
>> Did you read the devforums thread I pointed you at a couple of weeks ago?
> 
> 
> Umm, not sure Roland. I read the blog post by bbum about using Allocations, 
> which is the one you linked in this thread. Did you mean something else? 
> Forgive me, I can't locate the link if so.
> 
> If you're referring to bbum's post, I read that. I'm assuming that "heapshot" 
> is now labelled "mark generations" but otherwise is the same thing. The 
> problem with this in my case is that a "generation" is a new URL download and 
> that's fired off automatically by either the previous one completing or a 
> timer that's set to a variable time based on the "target time" of the 
> playlist entry. There's no clear means for me to hit "mark generation" at 
> exactly the right time. That might not matter all that much in that the 
> process is continuous, so as long as I'm downloading a stream at a fairly 
> steady rate, and hit the button at regular intervals, there should be a 
> reasonable similarity between runs.
> 
> Doing that, I get inconclusive results. Most of the memory that is left is 
> like this:
> 
> Snapshot  Timestamp   Growth  # Persistent
> Generation B  01:32.780.375   2.09 MB 38
> VM: Performance tool data 2.08 MB 4
>  0x116816000  01:13.421.801   532.00 KB
>  0x1162ed000  01:32.145.259   532.00 KB
>  0x11614  01:23.051.011   532.00 KB
>  0x1161e5000  01:02.847.030   532.00 KB
> 
> 
> Which suggests it's memory allocated by Allocations itself.
> 
> But where I'm checking this over longer time periods isn't in Instruments at 
> all, but in Xcode's memory viewer. Unfortunately that doesn't give me a 
> breakdown, just an overall usage.

I went through a similar painful process in early November hunting down bugs. 
I'm not using NSURLConnection so I can't really comment about that API and I'm 
working on OS X. This comment and the remarks a little later in this thread 
referring to Quinn triggered a recollection.

In desperation I looked at things using Activity Monitor's memory section and 
turned on the columns Real Mem, Shared Mem, and Purgeable Mem. In my case what 
I was seeing as a leak matched with the memory marked as purgeable.

Exactly what is meant by purgeable I don't know beyond the obvious.

Kevin





___

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: Using AV Foundation to record m3u8 stream to disk

2014-12-15 Thread Kevin Meaney
I'm not certain if this is useful to you but Bob McCune on Twitter mentioned a 
new tech note about new avfoundation apis which specifically mentions reference 
movies. 

https://developer.apple.com/library/mac/technotes/tn2404/_index.html#//apple_ref/doc/uid/DTS40015060

I'd also recommend his book learning avfoundation.

Kevin

Sent from my iPad

> On 15 Dec 2014, at 02:57, Graham Cox  wrote:
> 
> Just an update on this, since I've made some useful progress, but I'm a bit 
> stuck again.
> 
> 
> I am able to download the video streams and write them to a .ts file which 
> plays fine in apps such as VLC (Quicktime Player not so much). So far this is 
> all done with NSURLSession, breaking apart the m3u8 file(s) and loading each 
> media chunk, reassembling them into the correct order and writing them to the 
> file.
> 
> What I'd like to do now is to have a live preview of what data is being 
> received (so far I just accumulate it to the file with no preview). AVPlayer 
> can do this all by itself, but I assume that it's going to be duplicating the 
> download, thus doubling the bandwidth I need. What I'd rather do is feed my 
> already downloaded chunks of data to an AVPlayer somehow. This is where the 
> AV Foundation programming guide and the framework itself is a bit daunting - 
> I don't really know which objects I need to be looking at. I'm thinking 
> AVCaptureInput... or is it AVCaptureInputPort, or maybe AVAssetReader. 
> Unfortunately this sort of low level extension of AV Foundation isn't well 
> covered in the programming guide.
> 
> Some useful pointers to the rough shape of what I need to do would get my 
> project moving again.
> 
> --Graham
> 
> 
> 
> 
> 
> 
>> On 9 Dec 2014, at 10:37 am, Graham Cox  wrote:
>> 
>> OK, thanks. I was hoping that I didn't need to delve into the internals of 
>> the m3u8 format itself, since AVPlayer/AVPlayerView handles it just fine - I 
>> just make a NSURL from the m3u8 url and away it goes.
>> 
>> By the way, it isn't just audio, it's video and audio and possibly other 
>> things - there are three tracks in the asset for the stream I tested with 
>> but I forget what the third is now (first two were video and audio).
>> 
>> It seems as if the architecture of AV Foundation allows what I want, but the 
>> actual implementation doesn't, *unless I've missed something*. I'm wondering 
>> if this gap in the implementation is deliberate for some reason, is there 
>> but requires some other combinaiton of parameters from the nes I've tried, 
>> on Apple's 'to do' list or is fundamentally not possible.
>> 
>> 
>> --Graham
>> 
>> 
>> 
>> 
>>> On 9 Dec 2014, at 4:50 am, dangerwillrobinsondan...@gmail.com wrote:
>>> 
>>> 
>>> 
>>> 
>>> Sent from my iPhone
 On 2014/12/09, at 1:38, Jens Alfke  wrote:
 
 m3u8 isn't a stream, it's simply a small playlist file that contains one 
 or more HTTP URLs, which resolve to audio files, usually MP3. In the case 
 of streaming, the HTTP audio resource uses the Shoutcast format, which is 
 basically just an audio stream that looks like an infinitely long MP3 file.
 
 So all you need to do is read the URL from the .m3u8 file (which is pretty 
 trivial; IIRC it's just a text file containing a URL) and use something 
 like NSURLConnection to read data from it and write it to a file with a 
 ".mp3" extension. Since it's a stream you'll never hit EOF so you'll want 
 to stop the connection after a while.
 
 If you need to write the audio into some other kind of movie file you 
 should be able to feed the data received from the URL into AVFoundation. 
 You'll just need to inform it that the data format is MP3.
>>> It is not limited to MP3 
>>> Http Live Streaming uses this playlist format. 
>>> Literally just a list of URLs really. Where each one is a short clip of 
>>> media content. 
>>> The content on the other end is usually small files as parts of the whole. 
>>> The u on the end means UTF8. 
>>> The video format could vary.  
>> 
>> 
>> ___
>> 
>> 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/graham.cox%40bigpond.com
>> 
>> This email sent to graham@bigpond.com
> 
> 
> ___
> 
> 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/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.com
___

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

Please do not post

AVFoundation error messages when getting frames from video tracks

2014-12-12 Thread Kevin Meaney
I've got the following code snippet which is part of code that creates a 
CGImage. The CGImage is created but the last line of this code snippet triggers 
the output of an error message to the console. The self._movieAsset is an 
AVURLAsset created from a local file on disk. I've tried some variations for 
the properties of the videoSettings dictionary without making a difference. For 
example whether kCVPixelBufferOpenGLCompatibilityKey is a property of the 
dictionary or not, has a value of @(YES)/@(NO) does not make any difference.

The console message is:
[18:45:59.824] openglVideoCompositor_SetProperty signalled err=-12784 
(kFigBaseObjectError_PropertyNotFound) (unrecognised property) at 
/SourceCache/CoreMedia/CoreMedia-1562.19/Prototypes/MediaConverter/VideoCompositing/FigVideoCompositor_OpenGL.c
 line 1424
[18:45:59.924]  Boss  figPlaybackBossPrerollCompleted: unexpected 
preroll-complete notification

==

CMTime frameTime = frame time when I want the frame taken at.
NSArray *tracks = A list of AVAssetTracks
AVAssetReader *assetReader;
assetReader = [[AVAssetReader alloc] initWithAsset:self._movieAsset
 error:nil];
if (!assetReader)
{
return nil;
}

NSDictionary *videoSettings = @{
(id)kCVPixelBufferPixelFormatTypeKey : 
@(kCVPixelFormatType_32ARGB),
(id)kCVPixelBufferOpenGLCompatibilityKey : @(YES)
};
AVAssetReaderVideoCompositionOutput *vidComp;
vidComp = [AVAssetReaderVideoCompositionOutput
assetReaderVideoCompositionOutputWithVideoTracks:tracks
   videoSettings:videoSettings];
AVVideoComposition *avVidComp;
avVidComp = [AVVideoComposition
videoCompositionWithPropertiesOfAsset:self._movieAsset];
vidComp.videoComposition = avVidComp;

if (![assetReader canAddOutput:vidComp])
{
return nil;
}

[assetReader addOutput:vidComp];
// We need a duration for the time range, to do that I'm pulling the
// min frame duration from the first video track. Need to think about
// what alternatives we might have.
AVAssetTrack *track = tracks.firstObject;
CMTimeRange range = CMTimeRangeMake(frameTime, track.minFrameDuration);
assetReader.timeRange = range;
if ([assetReader startReading])


___

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: Crash with ARC enabled on Xcode 6.1

2014-10-23 Thread Kevin Meaney
Personally I'd try and not call any objective-c code from a C++ static object. 
If it did look the appropriate solution then I'd make sure I was comfortable 
with my knowledge of the objective-c runtime and the order in which things are 
called before main is called.

Kevin

On 23 Oct 2014, at 13:02, Beinan Li  wrote:

> Thank you Kevin!
> I didn't know this before. This might be it because I did at some point 
> change the dictionary creation from the old API-based syntax to literals.
> Maybe I should move back to the API calls. I'll try that today.
> 
> Thanks,
> Beinan
> 
> 
> On Thu, Oct 23, 2014 at 5:18 AM, Kevin Meaney  wrote:
> 
> On 23 Oct 2014, at 00:34, Beinan Li  wrote:
> 
>> Oh! I did actually.
>> 
>> The method I posted belongs to an ObjC object which is wrapped by a C++ 
>> object.
>> That C++ object is a singleton (static). 
>> 
>> How is this going to affect ARC and why it didn't down-right crash a week 
>> ago before I upgraded Xcode?
> 
> I wouldn't worry about why it worked before. I don't think that helps, and if 
> you have any other cases they should be removed as well.
> 
> Array and dictionary literals are not evaluated at compile time but are 
> replaced with the objective-c calls to create the arrays and dictionaries. 
> This is very different to string literals.
> 
> From what I understand any code that is executed before main is called is 
> done so before the objective-c runtime is fully setup which means you have no 
> guarantees about what will work. In objective-c++ where you can create static 
> C++ objects that results in objective-c being called it is an easy way to 
> make difficult to track crashes.
> 
> I'd like confirmation from an apple engineer that my understanding is 
> correct. My quick perusal of the docs didn't find the info I was after.
> 
> Kevin
> 
>> Thanks,
>> Beinan
>> 
>> 
>> On Wed, Oct 22, 2014 at 7:00 PM, Kevin Meaney  wrote:
>> Your not creating a static C++ object anywhere are you? One that creates the 
>> dictionary before main gets called by any chance?
>> 
>> Kevin
>> 
>> Sent from my iPhone
>> 
>> > On 22 Oct 2014, at 22:45, Beinan Li  wrote:
>> >
>> > Note, the initial crashing function is merely translating a C++ enum to the
>> > AVFoundation builtin constants.
>> >
>> > Thanks,
>> > Beinan
>> >
>> >
>> >> On Wed, Oct 22, 2014 at 5:45 PM, Beinan Li  wrote:
>> >>
>> >> It is quite unpredictable.
>> >> At first it crashes at a dictionary creation line in a .mm implementation
>> >> like this:
>> >>
>> >> - (NSString*) getAVAudioSessionMode:(myAudioSessionMode)modeKey {
>> >> NSDictionary* modeDict = @{ // Here it crashes
>> >>   @(myAudioSessionModeDefault): AVAudioSessionModeDefault,
>> >>   @(myAudioSessionModeVoiceChat): AVAudioSessionModeVoiceChat,
>> >>   @(myAudioSessionModeGameChat): AVAudioSessionModeGameChat,
>> >>   @(myAudioSessionModeVideoRecording): AVAudioSessionModeVideoRecording,
>> >>   @(myAudioSessionModeMeasurement): AVAudioSessionModeMeasurement,
>> >>   @(myAudioSessionModeMoviePlayback): AVAudioSessionModeMoviePlayback,
>> >>   @(myAudioSessionModeVideoChat): AVAudioSessionModeVideoChat
>> >>   };
>> >> NSString* mode = [modeDict objectForKey:@
>> >> (mySettings.audioSession.eMode)];
>> >> return mode;
>> >> }
>> >>
>> >> The backtrace gives me:
>> >>
>> >> * thread #1: tid = 0x2403, 0x0013148c MyDemo`-[MyImp
>> >> getAVAudioSessionMode:](self=0x1e839a80, _cmd=0x002d3077,
>> >> modeKey=myAudioSessionModeDefault) + 676 at MyImp.mm:78, queue =
>> >> 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, 
>> >> address=0x0)
>> >>  * frame #0:
>> >> 0x0013148c MyDemo -[MyImp getAVAudioSessionMode:](self=0x1e839a80,
>> >> _cmd=0x002d3077, modeKey=myAudioSessionModeDefault) + 676 at MyImp.mm:78
>> >>
>> >> Then if I remove this dictionary all together and do it like this:
>> >>
>> >> - (NSString*) getAVAudioSessionMode:(myAudioSessionMode)modeKey {
>> >> return AVAudioSessionModeDefault;
>> >> }
>> >>
>> >> Then I get a crash right in the main.mm:
>> >>
>> >> int retVal = UIApplicationMain(argc, argv, nil, @"MyDemoAppDelegate");
>> >>
>> >> backtrace:
>>

Re: Crash with ARC enabled on Xcode 6.1

2014-10-23 Thread Kevin Meaney

On 23 Oct 2014, at 00:34, Beinan Li  wrote:

> Oh! I did actually.
> 
> The method I posted belongs to an ObjC object which is wrapped by a C++ 
> object.
> That C++ object is a singleton (static). 
> 
> How is this going to affect ARC and why it didn't down-right crash a week ago 
> before I upgraded Xcode?

I wouldn't worry about why it worked before. I don't think that helps, and if 
you have any other cases they should be removed as well.

Array and dictionary literals are not evaluated at compile time but are 
replaced with the objective-c calls to create the arrays and dictionaries. This 
is very different to string literals.

From what I understand any code that is executed before main is called is done 
so before the objective-c runtime is fully setup which means you have no 
guarantees about what will work. In objective-c++ where you can create static 
C++ objects that results in objective-c being called it is an easy way to make 
difficult to track crashes.

I'd like confirmation from an apple engineer that my understanding is correct. 
My quick perusal of the docs didn't find the info I was after.

Kevin

> Thanks,
> Beinan
> 
> 
> On Wed, Oct 22, 2014 at 7:00 PM, Kevin Meaney  wrote:
> Your not creating a static C++ object anywhere are you? One that creates the 
> dictionary before main gets called by any chance?
> 
> Kevin
> 
> Sent from my iPhone
> 
> > On 22 Oct 2014, at 22:45, Beinan Li  wrote:
> >
> > Note, the initial crashing function is merely translating a C++ enum to the
> > AVFoundation builtin constants.
> >
> > Thanks,
> > Beinan
> >
> >
> >> On Wed, Oct 22, 2014 at 5:45 PM, Beinan Li  wrote:
> >>
> >> It is quite unpredictable.
> >> At first it crashes at a dictionary creation line in a .mm implementation
> >> like this:
> >>
> >> - (NSString*) getAVAudioSessionMode:(myAudioSessionMode)modeKey {
> >> NSDictionary* modeDict = @{ // Here it crashes
> >>   @(myAudioSessionModeDefault): AVAudioSessionModeDefault,
> >>   @(myAudioSessionModeVoiceChat): AVAudioSessionModeVoiceChat,
> >>   @(myAudioSessionModeGameChat): AVAudioSessionModeGameChat,
> >>   @(myAudioSessionModeVideoRecording): AVAudioSessionModeVideoRecording,
> >>   @(myAudioSessionModeMeasurement): AVAudioSessionModeMeasurement,
> >>   @(myAudioSessionModeMoviePlayback): AVAudioSessionModeMoviePlayback,
> >>   @(myAudioSessionModeVideoChat): AVAudioSessionModeVideoChat
> >>   };
> >> NSString* mode = [modeDict objectForKey:@
> >> (mySettings.audioSession.eMode)];
> >> return mode;
> >> }
> >>
> >> The backtrace gives me:
> >>
> >> * thread #1: tid = 0x2403, 0x0013148c MyDemo`-[MyImp
> >> getAVAudioSessionMode:](self=0x1e839a80, _cmd=0x002d3077,
> >> modeKey=myAudioSessionModeDefault) + 676 at MyImp.mm:78, queue =
> >> 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
> >>  * frame #0:
> >> 0x0013148c MyDemo -[MyImp getAVAudioSessionMode:](self=0x1e839a80,
> >> _cmd=0x002d3077, modeKey=myAudioSessionModeDefault) + 676 at MyImp.mm:78
> >>
> >> Then if I remove this dictionary all together and do it like this:
> >>
> >> - (NSString*) getAVAudioSessionMode:(myAudioSessionMode)modeKey {
> >> return AVAudioSessionModeDefault;
> >> }
> >>
> >> Then I get a crash right in the main.mm:
> >>
> >> int retVal = UIApplicationMain(argc, argv, nil, @"MyDemoAppDelegate");
> >>
> >> backtrace:
> >>
> >> * thread #1: tid = 0x2403, 0x3c4df350
> >> libsystem_kernel.dylib`__pthread_kill + 8, queue = 'com.apple.main-thread',
> >> stop reason = signal SIGABRT
> >>frame #0: 0x3c4df350 libsystem_kernel.dylib`__pthread_kill + 8
> >>frame #1: 0x3c456122 libsystem_c.dylib`pthread_kill + 58
> >>frame #2: 0x3c492972 libsystem_c.dylib`abort + 94
> >>frame #3: 0x3ba30d4e libc++abi.dylib`abort_message + 74
> >>frame #4: 0x3ba2dff8 libc++abi.dylib`default_terminate() + 24
> >>frame #5: 0x3bfe1a
> 

___

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: Crash with ARC enabled on Xcode 6.1

2014-10-22 Thread Kevin Meaney
Your not creating a static C++ object anywhere are you? One that creates the 
dictionary before main gets called by any chance?

Kevin

Sent from my iPhone

> On 22 Oct 2014, at 22:45, Beinan Li  wrote:
> 
> Note, the initial crashing function is merely translating a C++ enum to the
> AVFoundation builtin constants.
> 
> Thanks,
> Beinan
> 
> 
>> On Wed, Oct 22, 2014 at 5:45 PM, Beinan Li  wrote:
>> 
>> It is quite unpredictable.
>> At first it crashes at a dictionary creation line in a .mm implementation
>> like this:
>> 
>> - (NSString*) getAVAudioSessionMode:(myAudioSessionMode)modeKey {
>> NSDictionary* modeDict = @{ // Here it crashes
>>   @(myAudioSessionModeDefault): AVAudioSessionModeDefault,
>>   @(myAudioSessionModeVoiceChat): AVAudioSessionModeVoiceChat,
>>   @(myAudioSessionModeGameChat): AVAudioSessionModeGameChat,
>>   @(myAudioSessionModeVideoRecording): AVAudioSessionModeVideoRecording,
>>   @(myAudioSessionModeMeasurement): AVAudioSessionModeMeasurement,
>>   @(myAudioSessionModeMoviePlayback): AVAudioSessionModeMoviePlayback,
>>   @(myAudioSessionModeVideoChat): AVAudioSessionModeVideoChat
>>   };
>> NSString* mode = [modeDict objectForKey:@
>> (mySettings.audioSession.eMode)];
>> return mode;
>> }
>> 
>> The backtrace gives me:
>> 
>> * thread #1: tid = 0x2403, 0x0013148c MyDemo`-[MyImp
>> getAVAudioSessionMode:](self=0x1e839a80, _cmd=0x002d3077,
>> modeKey=myAudioSessionModeDefault) + 676 at MyImp.mm:78, queue =
>> 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
>>  * frame #0:
>> 0x0013148c MyDemo -[MyImp getAVAudioSessionMode:](self=0x1e839a80,
>> _cmd=0x002d3077, modeKey=myAudioSessionModeDefault) + 676 at MyImp.mm:78
>> 
>> Then if I remove this dictionary all together and do it like this:
>> 
>> - (NSString*) getAVAudioSessionMode:(myAudioSessionMode)modeKey {
>> return AVAudioSessionModeDefault;
>> }
>> 
>> Then I get a crash right in the main.mm:
>> 
>> int retVal = UIApplicationMain(argc, argv, nil, @"MyDemoAppDelegate");
>> 
>> backtrace:
>> 
>> * thread #1: tid = 0x2403, 0x3c4df350
>> libsystem_kernel.dylib`__pthread_kill + 8, queue = 'com.apple.main-thread',
>> stop reason = signal SIGABRT
>>frame #0: 0x3c4df350 libsystem_kernel.dylib`__pthread_kill + 8
>>frame #1: 0x3c456122 libsystem_c.dylib`pthread_kill + 58
>>frame #2: 0x3c492972 libsystem_c.dylib`abort + 94
>>frame #3: 0x3ba30d4e libc++abi.dylib`abort_message + 74
>>frame #4: 0x3ba2dff8 libc++abi.dylib`default_terminate() + 24
>>frame #5: 0x3bfe1a

___

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: bundleForClass in Swift

2014-10-19 Thread Kevin Meaney
>> 
>> I think my other reply will make this a moot point, but since [NSBundle 
>> bundleForClass:] takes a Class, and you know what your class is, just pass 
>> it that, you don't have to reference self.
>> 
>> [NSBundle bundleForClass:[MyGroovySubclass class]];
> 
> Sorry, I was conflating Obj-C and Swift syntax. I'm trying to do this all in 
> swift, in which case it's:
> 
>   NSBundle(forClass: self.dynamicType)
> 
> But you can't call this in an initializer before calling super init.

Hi Rick,

In my test target to access resources needed by the tests I do:

let testBundle = NSBundle(forClass: MovingImagesFrameworkiOSSwift.self)

Where MovingImagesFrameworkiOSSwift is the Swift class.

Kevin


___

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: Passing a swift function to objective-c

2014-10-18 Thread Kevin Meaney
I've now found an acceptable solution.

Rather than a property I've added an optional method to the protocol which then 
in its implementation assigns using the property, pretty much to make sure that 
the function/block is copied. I declared the method like so:

-(void)applyMyCreateImageFunction:(CGImageRef (^)(NSDictionary 
*))createImageFunction

And when calling it from the swift code I call it like so:

imageProvider.applyMyCreateImageFunction?(makeImage)

The question mark was necessary to evaluate whether the optional protocol 
method had been implemented or not.

Kevin

On 18 Oct 2014, at 18:18, Kevin Meaney  wrote:

> Hi Roland,
> 
> Thanks for the followup. I've created a proper git rep on github rather than 
> just a gist. Most of my github reps seem to be this kind of mini 
> demonstration project and I was trying to avoid yet another one.
> 
> https://github.com/SheffieldKevin/swift-objectivec
> 
>> What version of Xcode are you using by the way, Swift is so flux-y at the 
>> moment it probably makes a difference. 
> 
> I'm now running release Yosemite and release Xcode 6.1. That appears to me to 
> make no difference.
> 
> I still can't assign to the optional property of my protocol.
> 
> You can ignore the ImageProvider2 class, I've just included it for 
> completeness. It doesn't have a protocol and just declares the property 
> itself.
> 
> So with my protocol I've done something similar to what you did if I've 
> interpreted your discussion correctly. I've got two properties, one that is 
> required and one that is optional.
> 
> Everything works fine for the required property. But I still can't get the 
> optional one to work.
> 
> In ImageProvider.m you'll see that the MakeImageProvider function assigns a 
> block to the optional property and in SupplyCreateImage.swift I've commented 
> out the assignment. I've provided the example this way so that it can be seen 
> that it works when done using objective-c. But if you comment out the 
> assignment to the optional property of the block, and uncomment the line in 
> the swift file you'll see that the command line tool no longer compiles.
> 
> Like you I've tried the use of the optional and playing around with casting 
> but I've not actually got the code to compile this way.
> 
> Kevin
> 
> 
> ___
> 
> 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/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.com


___

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: Passing a swift function to objective-c

2014-10-18 Thread Kevin Meaney
Hi Roland,

Thanks for the followup. I've created a proper git rep on github rather than 
just a gist. Most of my github reps seem to be this kind of mini demonstration 
project and I was trying to avoid yet another one.

https://github.com/SheffieldKevin/swift-objectivec

> What version of Xcode are you using by the way, Swift is so flux-y at the 
> moment it probably makes a difference. 

I'm now running release Yosemite and release Xcode 6.1. That appears to me to 
make no difference.

I still can't assign to the optional property of my protocol.

You can ignore the ImageProvider2 class, I've just included it for 
completeness. It doesn't have a protocol and just declares the property itself.

So with my protocol I've done something similar to what you did if I've 
interpreted your discussion correctly. I've got two properties, one that is 
required and one that is optional.

Everything works fine for the required property. But I still can't get the 
optional one to work.

In ImageProvider.m you'll see that the MakeImageProvider function assigns a 
block to the optional property and in SupplyCreateImage.swift I've commented 
out the assignment. I've provided the example this way so that it can be seen 
that it works when done using objective-c. But if you comment out the 
assignment to the optional property of the block, and uncomment the line in the 
swift file you'll see that the command line tool no longer compiles.

Like you I've tried the use of the optional and playing around with casting but 
I've not actually got the code to compile this way.

Kevin


___

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: Passing a swift function to objective-c

2014-10-17 Thread Kevin Meaney
Thanks Roland.

On 17 Oct 2014, at 00:20, Roland King  wrote:
> 
>> On 17 Oct 2014, at 6:13 am, Kevin Meaney  wrote:
>> 
>> Hi,
>> 
>> I'm beginning to feel this above my pay grade as I can't seem to work it out.
>> 
>> I have a framework in Objective-C. I've been writing some tests for it, and 
>> to make life fun I've been writing the tests in Swift.
>> 
>> I have a property of a class in the objective-c framework declared like so:
>> 
>> @property (nonatomic, copy) CGImageRef (^createImage)(NSDictionary *);
>> 
>> In my tests I'm trying to write a function that I can assign to the property.
>> 
>> In the most basic form the function looks like this, I'm ignoring the passed 
>> in dictionary for the purposes of asking this question:
>> 
>> func createCGImage2(dictionary: [NSObject:AnyObject]) -> CGImage {
>>let jpegURL = NSBundle.mainBundle().URLForResource("myimage", 
>> withExtension:"jpg")
>>let imageSource = CGImageSourceCreateWithURL(jpegURL, nil)!
>>let theImage = CGImageSourceCreateImageAtIndex(imageSource, 0, nil)
>>return theImage
>> }
>> 
>> When I try to set the property with the function I get:
>> 
>> error: cannot convert the expression's type '([NSObject : AnyObject]) -> 
>> Unmanaged!' to type '(([NSObject : AnyObject]!) -> 
>> Unmanaged!)!?'
>> 
>> Now, if I have a function declared like so:
>> 
>> func createCGImageFromDictionary(dictionary: [NSObject:AnyObject]!) -> 
>> Unmanaged!
>> 
>> error: cannot convert the expression's type '([NSObject : AnyObject]!) -> 
>> Unmanaged!' to type '(([NSObject : AnyObject]!) -> 
>> Unmanaged!)!?'
>> 
>> I'm still a long way off. There's an extra () in there and an extra !? at 
>> the end that I really don't know how to interpret. Also I don't know how to 
>> convert the result of CGImageSourceCreateImageAtIndex to a 
>> Unmanaged as a return value.
>> 
>> I've been through various bits of the documentation, but something isn't 
>> clicking so that I understand how this stuff works so that I can try and 
>> solve it.
>> 
>> Kevin
>> 
>> __
> 
> ok this simple test works for me .. I also don’t understand the extra parens 
> etc in your example. So where does your code differ from the below? Note I 
> set it both with a public function and a closure, just to see if it works.

A detail I should have included. The @property is declared in the optional 
section of a protocol. I know the object in question has implemented the 
property. But that explains the extra requirements for unwrapping.

I've put together a gist where I've attempted to play with this.

https://gist.github.com/SheffieldKevin/a06907e163885f249548

I got the assigning to a property working when that property was declared as 
part of the class, but not when it has been declared in the optional section of 
a protocol. So I was able to duplicate what you did Roland. But no matter what 
I try, documentation I read I can't make it work when the property is declared 
in the protocol.

I got myself distracted because the project I setup to try out stuff was an 
objective-c command line tool and I also had trouble calling swift code from 
Objective-c. I could not get a swift function that wasn't a class or instance 
method to be callable from Objective-c.

Kevin

___

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

Passing a swift function to objective-c

2014-10-16 Thread Kevin Meaney
Hi,

I'm beginning to feel this above my pay grade as I can't seem to work it out.

I have a framework in Objective-C. I've been writing some tests for it, and to 
make life fun I've been writing the tests in Swift.

I have a property of a class in the objective-c framework declared like so:

@property (nonatomic, copy) CGImageRef (^createImage)(NSDictionary *);

In my tests I'm trying to write a function that I can assign to the property.

In the most basic form the function looks like this, I'm ignoring the passed in 
dictionary for the purposes of asking this question:

func createCGImage2(dictionary: [NSObject:AnyObject]) -> CGImage {
let jpegURL = NSBundle.mainBundle().URLForResource("myimage", 
withExtension:"jpg")
let imageSource = CGImageSourceCreateWithURL(jpegURL, nil)!
let theImage = CGImageSourceCreateImageAtIndex(imageSource, 0, nil)
return theImage
}

When I try to set the property with the function I get:

error: cannot convert the expression's type '([NSObject : AnyObject]) -> 
Unmanaged!' to type '(([NSObject : AnyObject]!) -> 
Unmanaged!)!?'

Now, if I have a function declared like so:

func createCGImageFromDictionary(dictionary: [NSObject:AnyObject]!) -> 
Unmanaged!

error: cannot convert the expression's type '([NSObject : AnyObject]!) -> 
Unmanaged!' to type '(([NSObject : AnyObject]!) -> 
Unmanaged!)!?'

I'm still a long way off. There's an extra () in there and an extra !? at the 
end that I really don't know how to interpret. Also I don't know how to convert 
the result of CGImageSourceCreateImageAtIndex to a Unmanaged as a 
return value.

I've been through various bits of the documentation, but something isn't 
clicking so that I understand how this stuff works so that I can try and solve 
it.

Kevin

___

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: Proper way to retain member of AppDelegate?

2014-10-15 Thread Kevin Meaney
Hi Howard,

I tried to capture some of my interpretation of apple's documentation about ARC 
into a blog post which you might find useful. Note also the links to 2 other 
blog posts which I would recommend.

http://blog.yvs.eu.com/2013/04/learning-arc/

I did a followup blog post, but it is mostly a description of my experiments 
and their results to determining when objects end up in the autorelease pool so 
that they are kept alive when you think you have no more strong links to them.

http://blog.yvs.eu.com/2013/05/experimental-arc/

I hope you find these helpful.

Kevin

On 15 Oct 2014, at 23:21, Howard Moon  wrote:

> Oh, ok, thanks!  Yes, that works, simply removing the (assign) or (retain) 
> (leaving it as the default, strong).
> 
> It's hard to follow examples I find on the internet since so many are out of 
> date or don't use ARC, and there's no easy way to tell them apart.
> 
> Thanks!
>   -Howard
> 
> On Oct 15, 2014, at 2:30 PM, Jens Alfke  wrote:
> 
>> 
>>> On Oct 15, 2014, at 1:58 PM, Howard Moon  wrote:
>>> 
>>> I think I resolved it… my data object's members were all declared using 
>>> @property(assign).  I changed those all to @property(retain), and it works 
>>> now.
>> 
>> Don't use assign or retain in ARC, use weak and strong. (And generally you'd 
>> just omit strong since it's the default.)
>> 
>> —Jens
> 
> ___
> 
> 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/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.com


___

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: Concurrent tasks are getting hung up

2014-10-10 Thread Kevin Meaney
On 10 Oct 2014, at 17:40, Scott Ribe  wrote:

> On Oct 10, 2014, at 10:20 AM, Kevin Meaney  wrote:
> 
>> Now I've been optimizing to maximize throughput for processing image files...
> 
> Things depend VERY much on what exactly you're doing. I've optimized for 
> throughput of processing image files, and found that number of worker threads 
> equal to logical CPUs maximized throughput. (Except for 2 logical cores, 
> where 3 threads were fastest, go figure...)

Just redid my speed tests, which made me realize I'd remembered wrong. The 
shape drawing tests got max results with 4 worker threads but that for 
processing image files I get an extra 40% throughput with 8. (Scaling 4 
megapixel image files at high quality by 0.4 and exporting to jpeg, I get a 
throughput of 82 images a second compared to 55 with 4)

Faulty memory is faulty.

Kevin


___

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: Concurrent tasks are getting hung up

2014-10-10 Thread Kevin Meaney

On 10 Oct 2014, at 16:27, Jim Crate  wrote:

> On Oct 10, 2014, at 11:00 AM, Kyle Sluder  wrote:
> 
>>> On Oct 10, 2014, at 6:42 AM, Steve Mills  wrote:
>>> 
>>> I've only created one NSOperationQueue and added many NSInvocationOperation 
>>> to it.
>> 
>> NSOperationQueue works by dispatching your blocks to the global async GCD 
>> queue. If you send a thousand blocks to be async processed at once, GCD will 
>> keep spinning up threads to try to service them until it exhausts the thread 
>> limit and your process deadlocks.
>> 
>> It sucks, but you have to be judicious in the number of blocks you submit to 
>> the global queue. Set a max operation count on your NSOperationQueue.
> 
> I ran into the same problem in my first foray into using NSOperationQueue.  
> When adding several hundred block operations to the queue, it pretty much 
> choked trying to run all several hundred at once.  Now, when I create an 
> NSOperationQueue for what could be more than a few operations, I always use:
> 
> myQueue.maxConcurrentOperationCount = [[NSProcessInfo processInfo] 
> processorCount];
> 
> The processorCount is actually logical core count, so on my 4-core i7 it 
> returns 8. 

I prefer working with the actual number of cpus. As Jim shows the logical 
processor count returns 8 for a four core i7, which is also what I get, 
hyperthreading doubles the number of reported CPUS.

The reason I prefer physical is that my performance testing of throughput 
achieved the fastest results when the number of concurrent tasks was equal to 
the number of physical CPUs. Unfortunately NSProcessInfo doesn't return the 
number of physical CPUs.

The following code demonstrates various ways of calling sysctl to get system 
info:

int mib[4];
int numCPU;
size_t len = sizeof(numCPU);
printf("sizeof numCPU: %ld\n", len);
size_t mibSize = sizeof(mib);

printf("\nhw.physicalcpu\n");
sysctlnametomib("hw.physicalcpu", mib, &mibSize);
printf("mib[0] = %d, mib[1] = %d\n", mib[0], mib[1]);
printf("mibSize = %ld\n", mibSize);
sysctl(mib, 2, &numCPU, &len, NULL, 0);
printf("hw.physicalcpu = %d\n", numCPU);

printf("\nhw.logicalcpu\n");
sysctlnametomib("hw.logicalcpu", mib, &mibSize);
printf("mib[0] = %d, mib[1] = %d\n", mib[0], mib[1]);
sysctl(mib, 2, &numCPU, &len, NULL, 0);
printf("hw.logicalcpu = %d\n", numCPU);

sysctlbyname("hw.physicalcpu", &numCPU, &len, NULL, 0);
printf("\nsysctlbyname:hw.physicalcpu = %d\n", numCPU);

Now I've been optimizing to maximize throughput for processing image files, 
whereas most people should be optimizing to keep the system and their 
application responsive whilst getting stuff done with as little overhead as 
possible which implies fewer concurrent operations not more. Also you don't 
always know when a operation you spawn might start some task that then spawns 
more concurrent operations. I suppose what I'm saying is err on the side of 
generating fewer concurrent tasks than more.

And I've seen exactly the same thing as Jim in terms of completely locking up 
an application by flooding it with concurrent operations.

Kevin

___

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: iOS Category to match OS X category

2014-10-07 Thread Kevin Meaney
Thanks Jens,

I've just implemented a different solution as I since found that CIFilter 
instance on iOS has a name read only property which I hadn't noticed.

So instead I've replaced the array of filters in my filter chain object with an 
array of dictionaries. Each dictionary has a name and a filter attribute. This 
way I get the behaviour I need and it works for both iOS and OS X. Nothing 
clever about it but it's nice having a common solution for both.

Kevin

On 7 Oct 2014, at 16:00, Jens Alfke  wrote:

> 
>> On Oct 7, 2014, at 1:09 AM, Kevin Meaney  wrote:
>> 
>> This category is not in any of the iOS frameworks as far as I can tell. So 
>> it looks like the only way I can get the same behaviour on iOS is using 
>> associated objects/references.
> 
> That sounds reasonable.
> 
>> I'm not comfortable with this solution, it feels too much like a hack so I'm 
>> asking a couple of questions before going ahead.
> 
> I don't think so; if anything, associated objects are the solution for the 
> real hacks people used to use to do this :)
> 
>> Is there an alternative less hacky solution I've missed?
> 
> You can create a global weak-key NSMapTable that maps CIFilter objects to 
> NSStrings.
> 
> —Jens

___

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

iOS Category to match OS X category

2014-10-07 Thread Kevin Meaney
This is more of an objective-c question than Cocoa, but I'm getting no traction 
on the objective-c devforums discussion list.

I've got a OSX Framework that I'm updating to to also work on iOS.
 
In the Framework I take advantage of the name property added to the CIFilter 
class by the category CACIFilterAdditions which is added as part of QuartzCore 
and I've made things depend on it when setting up the filter chain.
 
This category is not in any of the iOS frameworks as far as I can tell. So it 
looks like the only way I can get the same behaviour on iOS is using associated 
objects/references. I'm not comfortable with this solution, it feels too much 
like a hack so I'm asking a couple of questions before going ahead.
 
Is there an alternative less hacky solution I've missed?
Am I being too cautious about this as a solution?
 
Thanks
Kevin
___

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: Class Introspection with class_copyMethodList and class methods.

2014-08-26 Thread Kevin Meaney
I think you might need objc_getMetaClass.

See https://github.com/nst/RuntimeBrowser/blob/master/model/ClassDisplay.m

For how it is used.

Kevin

On 26 Aug 2014, at 15:06, Alex Zavatone  wrote:

> I've been using the obj runtime to dump class methods, protocols, Ivars and 
> properties for documentation, but when using class_copyMethodList I noticed 
> that only class instance methods are returned, no class methods declared with 
> a + are returned at all. 
> 
> I scanned the runtime docs and can't see how to get the class methods to be 
> returned using the runtime.  
> 
> Any ideas on how to handle this?
> 
> Using 10.8.5 and iOS 7.1 in Xcode 5.1.1
> 
> Thanks in advance.
> ___
> 
> 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/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.com


___

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: How to make a LaunchAgent

2014-08-11 Thread Kevin Meaney

> You’re not supposed to start it - launchd/XPC services is supposed to start 
> it for you. You’re supposed to register it as a LaunchAgent/Daemon, creating 
> the launchd.plist file and when you need the service, it starts and when you 
> don’t, it’s stopped again. I keep reading this is all part of the security of 
> XPC, only the system can kick one off. 

All true, but the documentation is poor. So I blogged my experience, and 
created a minimal Xcode project (Xcode 4.6) for a launch agent. All you should 
need to update is your Team ID.

http://blog.yvs.eu.com/2013/07/launchagents-and-xpc/

and 

https://github.com/SheffieldKevin/LaunchAgent/

Kevin


___

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: Talking to other apps

2014-08-04 Thread Kevin Meaney

On 4 Aug 2014, at 22:49, Kyle Sluder  wrote:

> On Mon, Aug 4, 2014, at 04:17 PM, Uli Kusterer wrote:
>> Well, what other communication mechanisms are there for talking between
>> sandboxed apps ... ? I *did* call it a last-ditch thing.
> 
> XPC and Apple Events (as long as your sdef uses access groups).

There has been some discussion on the xpc forum in Core OS on devforums about 
inter application communication. I new I'd seen it somewhere.

https://devforums.apple.com/community/mac/coreos/xpc

The thread "Can I use NSXPCConnection between two desktop apps?" I think is 
most relevant as there is some discussion of different options.

Kevin



___

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: Talking to other apps

2014-08-04 Thread Kevin Meaney
When you say app-friend, what do you mean? Another application? An XPC service? 
Some other kind of service?

If your App is sandboxed and the service is not an xpc service embedded in your 
application then I think your pretty much out of luck.

Kevin

On 4 Aug 2014, at 07:54, Gerriet M. Denkmann  wrote:

> My app wants to talk to some app-friend. Like sending a string and getting 
> another string back. Or something slightly more complicated.
> 
> In the good old days I would have used Distributed Objects, but this seems to 
> be no longer the fashion. Xcode 6 does not provide any documentation about 
> this (or I can't find it).
> 
> So, what to do?
> NSPerformService (which also has the feel of not being well-loved), XPC, or 
> what else?
> 
> Gerriet.
> 
> 
> ___
> 
> 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/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.com


___

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: Taking screen shots

2014-06-18 Thread Kevin Meaney
Since the SonOfGrab application works for grabbing the contents of my window, 
even when it is partially offscreen at the time of taking the screen grab I had 
a look at what it was doing differently.

Basically SonOfGrab was passing in CGRectNull into CGWindowListCreateImage 
instead of a defined rectangle. I was defining a rectangle because I wanted the 
content region of the window not the whole window. So instead I passed in 
CGRectNull and then afterwards crop the generated CGImageRef down to exclude 
the window title bar.

This now works as it should and as it does for SonOfGrab.

So now I'm going to ask about why drawing to the windows graphics context 
directly is not ok.

I'm not dealing with any views, just a window created programmatically with its 
one content view. The window cannot be
resized. In this situation I believe the issues around lock focus and the 
calling of draw rect within a view hierarchy may not apply. Are there other 
issues that will hurt me when drawing directly?

Kevin

On 18 Jun 2014, at 17:47, Kyle Sluder  wrote:

> On Wed, Jun 18, 2014, at 09:01 AM, Kevin Meaney wrote:
>> Drawing happens when I receive an xpc message containing a drawing
>> command. To do the drawing I get the NSGraphicsContext from which I pull
>> the graphicsPort which is a special kind of CGContext. I then use
>> CoreGraphics commands to do the drawing.
> 
> You're still not being specific enough. Where is this code happening?
> Which context is it grabbing?
> 
> If you want to draw to the screen, you send -setNeedsDisplay: to a view
> and wait for the window to come around and ask you to draw. That is the
> ONLY* way to draw to the screen in OS X.
> 
> So this is OK:
> 
> // xpc listener
> - (void)handleIncomingDrawCommand:(id)drawCommand {
>  AppendDrawCommandToQueue(drawCommand);
>  [_myView setNeedsDisplay:YES];
> }
> 
> // view
> - (void)drawRect:(NSRect)dirtyRect {
>  CGContextRef cgContext = [[NSGraphicsContext currentContext]
>  graphicsPort];
>  ApplyDrawCommandsFromQueue(cgContext);
> }
> 
> This is NOT OK:
> 
> - (void)handleIncomingDrawCommand:(id)drawCommand {
>  CGContextRef cgContext = [[NSGraphicsContext currentContext]
>  graphicsPort];
>  ImmediatelyPerformDrawCommand(drawCommand, cgContext); // NO!
> }
> 
> Depending on your application, your listener may need to maintain a
> partial or complete history of draw commands it has received so that it
> can draw them all anew in -drawRect:. If it's too expensive to redraw
> all your commands every time you get sent -drawRect:, you can maintain
> _your own_ offscreen buffer and just blit it to the screen in
> -drawRect:.
> 
> // xpc listener
> NSBitmapImageRep *_offscreenBuffer;
> - (void)handleIncomingDrawCommand:(id)drawCommand {
>  AppendDrawCommandToQueue(drawCommand); // in case we need to resize
>  and redraw the _offscreenBuffer
>  PerformQueuedDrawCommands(_offscreenBuffer);
>  [_myView setNeedsDisplay:YES];
> }
> 
> // view
> - (void)setFrameSize:(NSSize)newSize {
>  ResizeBuffer(_offscreenBuffer, newSize);
>  PerformQueuedDrawCommands(_offscreenBuffer);
>  [super setFrameSize:newSize];
> }
> 
> - (void)drawRect:(NSRect)dirtyRect {
>  [_offscreenBuffer drawAtPoint:self.bounds.origin];
> }
> 
> You can build a CGContextRef around an NSBitmapImageRep by using
> +[NSGraphicsContext graphicsContextWithBitmapImageRep:] and getting the
> result's graphicsPort.
> 
> --Kyle Sluder
> 
> * not really the only way, but the only supported way that works in all
> cases.


___

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: Taking screen shots

2014-06-18 Thread Kevin Meaney
> This is NOT OK:
> 
> - (void)handleIncomingDrawCommand:(id)drawCommand {
>  CGContextRef cgContext = [[NSGraphicsContext currentContext]
>  graphicsPort];
>  ImmediatelyPerformDrawCommand(drawCommand, cgContext); // NO!
> }

Bugger, that is exactly what I'm doing.

Basically the tool is intended for drawing to an offscreen bitmap. But I got 
feedback that while testing out scripts people wanted to see what was going on, 
so I tried having a window associated with the offscreen bitmap that could be 
shown in a debug mode and blit the offscreen context into the window in the 
draw rect of the window's content view after setting set needs display. This 
slowed things down a lot for large bitmaps as I'm not keeping track of what 
region changed.

So I tried this approach, with a fixed size window and the performance is only 
slightly slower than working with an offscreen bitmap without a window. I've 
got a large collection of test scripts producing images and comparing the 
output to previously produced images and the generated images from the window 
context are within acceptable tolerances the same images.

The window is fixed size, but the problem occurred when the window was dragged 
offscreen and if drawing occurred whilst the window was offscreen. SonOfGrab 
gets the window content correctly.

Thanks for the feedback.

I'll have to think about another approach.

Kevin

> Depending on your application, your listener may need to maintain a
> partial or complete history of draw commands it has received so that it
> can draw them all anew in -drawRect:. If it's too expensive to redraw
> all your commands every time you get sent -drawRect:, you can maintain
> _your own_ offscreen buffer and just blit it to the screen in
> -drawRect:.
> 
> // xpc listener
> NSBitmapImageRep *_offscreenBuffer;
> - (void)handleIncomingDrawCommand:(id)drawCommand {
>  AppendDrawCommandToQueue(drawCommand); // in case we need to resize
>  and redraw the _offscreenBuffer
>  PerformQueuedDrawCommands(_offscreenBuffer);
>  [_myView setNeedsDisplay:YES];
> }
> 
> // view
> - (void)setFrameSize:(NSSize)newSize {
>  ResizeBuffer(_offscreenBuffer, newSize);
>  PerformQueuedDrawCommands(_offscreenBuffer);
>  [super setFrameSize:newSize];
> }
> 
> - (void)drawRect:(NSRect)dirtyRect {
>  [_offscreenBuffer drawAtPoint:self.bounds.origin];
> }
> 
> You can build a CGContextRef around an NSBitmapImageRep by using
> +[NSGraphicsContext graphicsContextWithBitmapImageRep:] and getting the
> result's graphicsPort.
> 
> --Kyle Sluder
> 
> * not really the only way, but the only supported way that works in all
> cases.


___

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: Taking screen shots

2014-06-18 Thread Kevin Meaney
SonOfGrab displays in the composited image window the correct image after 
following the same steps.

Kevin

On 18 Jun 2014, at 17:01, Kevin Meaney  wrote:

> On Jun 18, 2014, at 8:36 AM, Kevin Meaney  wrote:
>>> 
>>> The sequence of events are:
>>> 
>>> 1. Drag window so that it is partially offscreen.
>>> 2. Draw into the window where part of the drawing happens in the part of 
>>> the window that is offscreen.
>> 
>> Ok, what does this mean? In AppKit, you don’t draw into a window; the window 
>> asks you to draw. If you mean that you’re sending -drawRect: to the view 
>> yourself, that will never work.
> 
> Drawing happens when I receive an xpc message containing a drawing command. 
> To do the drawing I get the NSGraphicsContext from which I pull the 
> graphicsPort which is a special kind of CGContext. I then use CoreGraphics 
> commands to do the drawing.
> 
> I looked at SonOfGrab when I first implemented this, so I'm looking at it 
> again to see if it can provide some clues.
> 
> Kevin
> 
>> It’s also possible that CGWindowList doesn’t force a window to draw its 
>> entire area. Do you get the same results with the SonOfGrab sample project? 
>> <https://developer.apple.com/library/mac/samplecode/SonOfGrab/Listings/Controller_m.html#//apple_ref/doc/uid/DTS10004490-Controller_m-DontLinkElementID_4>
>> 
>> --Kyle Sluder
> 
> 
> ___
> 
> 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/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.com


___

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: Taking screen shots

2014-06-18 Thread Kevin Meaney
On Jun 18, 2014, at 8:36 AM, Kevin Meaney  wrote:
>> 
>> The sequence of events are:
>> 
>> 1. Drag window so that it is partially offscreen.
>> 2. Draw into the window where part of the drawing happens in the part of the 
>> window that is offscreen.
> 
> Ok, what does this mean? In AppKit, you don’t draw into a window; the window 
> asks you to draw. If you mean that you’re sending -drawRect: to the view 
> yourself, that will never work.

Drawing happens when I receive an xpc message containing a drawing command. To 
do the drawing I get the NSGraphicsContext from which I pull the graphicsPort 
which is a special kind of CGContext. I then use CoreGraphics commands to do 
the drawing.

I looked at SonOfGrab when I first implemented this, so I'm looking at it again 
to see if it can provide some clues.

Kevin

> It’s also possible that CGWindowList doesn’t force a window to draw its 
> entire area. Do you get the same results with the SonOfGrab sample project? 
> <https://developer.apple.com/library/mac/samplecode/SonOfGrab/Listings/Controller_m.html#//apple_ref/doc/uid/DTS10004490-Controller_m-DontLinkElementID_4>
> 
> --Kyle Sluder


___

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: Taking screen shots

2014-06-18 Thread Kevin Meaney
The sequence of events are:

1. Drag window so that it is partially offscreen.
2. Draw into the window where part of the drawing happens in the part of the 
window that is offscreen.
3. Drag the window so that it is fully on screen. Observe that the window shows 
all the drawing that was performed.
4. Take a snapshot of the window.
5. Save the snapshot to an image file.
6. Note that the snapshot is missing the part of the drawing that was drawn 
offscreen, but was visible after step 3.

Kevin


On 18 Jun 2014, at 16:30, Kyle Sluder  wrote:

>> On Jun 18, 2014, at 8:24 AM, Kevin Meaney  wrote:
>> 
>> [ snip ]
> 
> Thanks. But I’m still confused about the timing. What method does this code 
> live in, and when is that method executed relative to the window being 
> dragged completely back on to the screen?
> 
> --Kyle Sluder


___

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: Taking screen shots

2014-06-18 Thread Kevin Meaney
Apologies, 

The e-mail with the code went out before I was finished editing.

The code shown is that taking the screen capture. But what is captured is not 
what I see in the window.

Kevin

On 18 Jun 2014, at 16:24, Kevin Meaney  wrote:

>> Not really.
>> 
>> Can you show some code?
>> 
> 
>dictArray = CGWindowListCopyWindowInfo(kCGWindowListOptionIncludingWindow,
>(CGWindowID)[self._window 
> windowNumber]);
>if (dictArray && (CFArrayGetCount(dictArray) > 0))
>windowDict = CFArrayGetValueAtIndex(dictArray, 0);
> 
>if (windowDict && (CFDictionaryGetCount(windowDict) > 0))
>rectDict = CFDictionaryGetValue(windowDict, kCGWindowBounds);
> 
>if (rectDict)
>{
>if (CGRectMakeWithDictionaryRepresentation(rectDict, &winRect))
>gotRect = YES;
>}
>if (dictArray)
>CFRelease(dictArray);
> 
>NSRect screenRect;
>if (gotRect)
>{
>// screenRect = [self._window contentRectForFrameRect:winRect];
>screenRect = winRect;
>screenRect.origin.y += winRect.size.height - self._height;
>screenRect.size.height = self._height;
>}
>else
>{
>NSScreen *screen = self._window.screen;
>CGFloat screenHeight = screen.frame.size.height;
> 
>NSRect windowRect = self._window.frame;
>NSRect contentRect = [self._window contentRectForFrameRect:windowRect];
>screenRect = CGRectMake(
>   contentRect.origin.x,
>   screenHeight - (contentRect.origin.y + 
> contentRect.size.height),
>   contentRect.size.width,
>   contentRect.size.height);
>}
>MICGImage *newImage;
>CGImageRef cgImage;
>cgImage = CGWindowListCreateImage(screenRect,
>  kCGWindowListOptionIncludingWindow,
>  (CGWindowID)[self._window windowNumber],
>  kCGWindowImageBoundsIgnoreFraming);
> 
> 
> 
>> --Kyle Sluder
>> ___
>> 
>> 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/ktam%40yvs.eu.com
>> 
>> This email sent to k...@yvs.eu.com
> 
> ___
> 
> 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/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.com


___

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: Taking screen shots

2014-06-18 Thread Kevin Meaney
> Not really.
> 
> Can you show some code?
> 

dictArray = CGWindowListCopyWindowInfo(kCGWindowListOptionIncludingWindow,
(CGWindowID)[self._window 
windowNumber]);
if (dictArray && (CFArrayGetCount(dictArray) > 0))
windowDict = CFArrayGetValueAtIndex(dictArray, 0);

if (windowDict && (CFDictionaryGetCount(windowDict) > 0))
rectDict = CFDictionaryGetValue(windowDict, kCGWindowBounds);

if (rectDict)
{
if (CGRectMakeWithDictionaryRepresentation(rectDict, &winRect))
gotRect = YES;
}
if (dictArray)
CFRelease(dictArray);

NSRect screenRect;
if (gotRect)
{
// screenRect = [self._window contentRectForFrameRect:winRect];
screenRect = winRect;
screenRect.origin.y += winRect.size.height - self._height;
screenRect.size.height = self._height;
}
else
{
NSScreen *screen = self._window.screen;
CGFloat screenHeight = screen.frame.size.height;

NSRect windowRect = self._window.frame;
NSRect contentRect = [self._window contentRectForFrameRect:windowRect];
screenRect = CGRectMake(
   contentRect.origin.x,
   screenHeight - (contentRect.origin.y + 
contentRect.size.height),
   contentRect.size.width,
   contentRect.size.height);
}
MICGImage *newImage;
CGImageRef cgImage;
cgImage = CGWindowListCreateImage(screenRect,
  kCGWindowListOptionIncludingWindow,
  (CGWindowID)[self._window windowNumber],
  kCGWindowImageBoundsIgnoreFraming);



> --Kyle Sluder
> ___
> 
> 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/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.com

___

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

Taking screen shots

2014-06-18 Thread Kevin Meaney
Actually just window shots.

I feel like I've been fighting with the screen shot code, and that it shouldn't 
be this difficult. I get past one problem only to find another. My most recent 
seems intractable.

If drawing to the window happens when the window is not completely on screen 
and if you drag the window so that it is fully visible on screen so you can see 
that all the drawing you did is actually drawn and then take a snapshot using 
CGWindowListCreateImage of the fully visible window, the bit of the window that 
was offscreen when drawn to is missing the drawing that happened at that time. 
The size of the window shot is correct it is just as if the drawing didn't 
happen to that part of the window.

I hope I've described this well enough.

Is there something I'm missing that will cause CGWindowListCreateImage to 
capture all the drawing.

Kevin


___

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: Drag and drop onto BSD command line tool?

2014-05-17 Thread Kevin Meaney
I think an applescript droplet, using the "on open" call which then calls "do 
shell script" with the path to your command and the file that is dropped on it.

Kevin

On 18 May 2014, at 00:14, Bob Sabiston  wrote:

> Hello,
> 
>  I have a little console app written in C, one which takes a filename as an 
> argc/argv argument.  Is there any *easy* way to make this into a tool which I 
> can just drop files onto it in the finder?  
> 
> There used to be a program called DropScript which would do this, but it was 
> PPC based and there is no Intel version that I can find.  I’ve never used 
> Automator, would it do this?
> 
> Thanks
> Bob
> 
> 
> ___
> 
> 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/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.com


___

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: Problem with distributed objects in GUI cocoa apps

2014-04-30 Thread Kevin Meaney
Hi Costas,

I'd be interested in hearing the results of you following up NSXPCConnection.

When I read through the documentation about a year ago, it is focussed around 
providing a xpcservice which is a bundled executable within an application, and 
the application communicates with it using NSXPCConnection.

The NSXPCConnection can also be used for communicating with a LaunchAgent or a 
LaunchDaemon but I found the process of getting a LaunchAgent working as I 
found it difficult to separate what documentation was specific to an xpcservice 
and what was needed to be done differently for a LaunchAgent. I got there in 
the end, and I have the LaunchAgent side of things working and have a minimal 
project which demonstrates a working LaunchAgent. 
https://github.com/SheffieldKevin/LaunchAgent

The big BUT though is. I could never see how you could use NSXPCConnection to 
communicate between two applications. I would be interested to know how this 
can be done which is why I'd be interested in hearing the results of your 
examination of NSXPCConnection.

Kevin
 
On 30 Apr 2014, at 07:49, Costas Chatzinikolas  
wrote:

> Thank you very much.
> 
> I had already solved the problem before yor response.
> It had to do with disabling sandboxing at all.
> 
> However i will follow your advice and start reading about NSXPCConnection.
> 
> One quick question: DO API is not available on iOS. Do you know if
> NSXPCConnection is?
> 
> 
> 2014-04-24 8:32 GMT+03:00 Charles Srstka :
> 
>> On Mar 30, 2014, at 3:28 AM, Costas Chatzinikolas <
>> costas.chatziniko...@gmail.com> wrote:
>> 
>>> Hi everyone,
>>> 
>>> i recently made a set of 2 command lines apps in Cocoa, that use
>>> Distributed objects to communicate. In fact, the first app is the client
>>> that sends a message, the second app is the server the vends the object.
>>> Everything works ok!!!
>>> 
>>> Then i tried to make these 2 apps GUI based. I used the same code. The
>>> server vends the object, but the client is unable to get the connection.
>> It
>>> always gets a nil connection. In fact when i check the number of
>> available
>>> connections from the client using:
>>> 
>>> [NSConnection allConnections]
>>> 
>>> it always return zero connections. The only difference in my code is that
>>> in the GUI server app, i don't use:
>>> 
>>> [[NSRunLoop currentRunLoop] run]
>>> 
>>> since the GUI app has its own runLoop.
>>> 
>>> I also have enabled the sandbox networking capabilities for both GUI
>> apps.
>>> 
>>> Has anyone experience this behavior before me?
>>> 
>>> Thanks in advance...
>> 
>> Distributed Objects is pretty old and crusty at this point. You might want
>> to look into NSXPCConnection instead, which fixes a lot of problems that DO
>> had, and is likely to be better supported.
>> 
>> 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/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.com


___

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: ARC Retain Cycles

2014-04-21 Thread Kevin Meaney
On 21 Apr 2014, at 21:09, Andy Lee  wrote:
> 
> The solution is to use a weak reference for one of the properties in the 
> cycle.  In general, if one object conceptually "owns" the other, then the 
> "owning" object uses a weak reference and the "owned" object uses a strong 
> one.  For example, a parent has weak references to its children, and the 
> children have strong references back to the parent.  Similarly, a delegating 
> object has a weak reference to its delegate, which typically (though not 
> necessarily) has a strong reference back to the delegator.

Unless I'm being confused here by your wording. Your recommendation in relation 
to the parent child relationship is completely turned around from what Apple 
suggests:

https://developer.apple.com/library/ios/releasenotes/objectivec/rn-transitioningtoarc/introduction/introduction.html
See section: Use Lifetime Qualifiers to Avoid Strong Reference Cycles

If you are recommending an alternative to what Apple suggests I'd be quite 
interested into hearing the reasons. Do you implement an array of weak 
references to a list of children?

Kevin

> These examples should be familiar from manual memory management.  When 
> implementing the delegate pattern under retain/release, the recommended 
> practice is to have objects not retain their delegate, for the same reason of 
> avoiding retain cycles.



___

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: What the actual heck?

2014-04-16 Thread Kevin Meaney
I have received the same e-mail also with a IP starting with 17.

Kevin

On 16 Apr 2014, at 05:25, Kyle Sluder  wrote:

> On Tue, Apr 15, 2014, at 09:19 PM, Bryan Vines wrote:
>> Hi folks.
>> 
>> So I just got a “Mailing list removal confirmation notice” which said the
>> list had received a request from a 17.x.x.x address for the removal of my
>> email address from this list.
>> 
>> Anyone else getting something like this?
>> 
>> Plot twist: The 17.x.x.x netblock belongs to Apple. “The call is coming
>> from INSIDE THE HOUSE!”
>> 
>> Any idea why someone inside Apple wants to pull me off the list?
>> 
>> Very confusing.
> 
> If you post to the list without trimming the mailing list footer, the
> account management link that is specifically tailored to your account
> will get posted as well.
> 
> Someone might errantly click that link thinking it will take them to
> _their own_ unsubscribe page. Alternatively, a naive web crawler might
> reach your account management page and from there send an unsubscribe
> request.
> 
> I doubt someone at Apple is trying to boot you off the list. :)
> 
> --Kyle Sluder
> 
> ___
> 
> 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/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.com

___

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: Retain count in non ARC

2014-04-07 Thread Kevin Meaney
I thought the behaviour was different between iOS and MacOS. On iOS nonatomic 
was the default and atomic on OS X.

Kevin

Sent from my iPhone

On 7 Apr 2014, at 05:28, Graham Cox  wrote:

> 
> On 7 Apr 2014, at 1:58 pm, Ben Kennedy  wrote:
> 
>> t is for these two reasons that, from years of conditioning, I can watch my 
>> fingers type "(nonatomic " automatically and as if my magic as soon as I 
>> finish typing "@property " ...
> 
> Me too, though it's been more to do with the fact that I don't like hidden 
> contracts in my APIs. Discovering that 'atomic' is the default vindicates my 
> pedantry all this time ;)
> 
> --Graham
> 
> 
> 
> ___
> 
> 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/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.com

___

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: Preparation for doing a bug report for CIPageCurlTransition

2014-03-31 Thread Kevin Meaney
Your comments have been really helpful. I've done two things to get everything 
to work:

Firstly, I turned my triangle upside down, and I set alpha for black at 0.7 and 
for white 0.3.

Now it is clear that everything works as it should.

Many Thanks.

Kevin

On 31 Mar 2014, at 20:43, Bill Monk  wrote:

> CIPageCurlTransition's inputBacksideImage does work, but its scaling and/or 
> interaction with the shading image seems under-documented (to me anyway), and 
> as such, seems to behave oddly... 
> 
> But I can definitely get a visible backside image by tweaking your code a 
> little (using https://gist.github.com/SheffieldKevin/98734).
> 
> (No doubt the list will eat the screenshots I'm about to paste in...)
> 
> First, the shading image needs some transparency, else you get just get a 
> gray gradient on the back, regardless of the backside image.
> 
> I used:
> 
> CIColor *color0 = [CIColor colorWithRed:1.0 green:1.0 blue:1.0 
> alpha:0.5];
> [radialGradientFilter setValue:color0 forKey:@"inputColor0"];
> 
> CIColor *color1 = [CIColor colorWithRed:0.0 green:0.0 blue:0.0 
> alpha:0.5];
> [radialGradientFilter setValue:color1 forKey:@"inputColor1"];
> ---
> 
> Alone, that doesn't appear to do much; just a green gradient on the back 
> side. That's because
> 
> a) the back side image is getting scaled in weird way. All that's visible of 
> your triangle image its green background. The red triangle in the center is 
> "wrapped" so far back behind, it isn't visible at all (this will become 
> apparent...).
> 
> b) your back side image and target image both have extensive green areas, so 
> it's difficult to tell them apart where they meet.
> 
> 
> Different colors on the triangle backside image helps:
> 
> CGColorRef backColor = CGColorCreateGenericRGB(1.0, 0.5, 0.2, 1.0); 
> // magenta-ish
> CGColorRef triangleColor = CGColorCreateGenericRGB(0.7, 0.2, 0.5, 1.0); 
> // orange-y
> ---
> 
> But now the back side is just a magenta gradient. Where's the triangle? Maybe 
> it's wrapped too far around back to be visible...
> 
> Let's flip it to point upwards, with the point touching the top of the image 
> and the base the full width of the image:
> 
> ---
> CGPoint trianglePoint1 = CGPointMake( 0, 0 );
> CGPoint trianglePoint2 = CGPointMake( kBoundsRect.size.width, 0);
> CGPoint trianglePoint3 = CGPointMake( kBoundsRect.size.width / 2, 
> kBoundsRect.size.height  );
> 
> 
> ---
> 
> 
> 
> 
> 
> But hmm: when wrapped onto the backside, still only a magenta area is 
> visible...
> 
> Let's swap the backside image and the target image (the target is the one 
> revealed by the curl):
> 
> --
> CIImage *inputImage = [CIImage imageWithCGImage:sourceImage];
> [pageCurlFilter setValue:inputImage forKey:@"inputImage"];
> 
> #define SwapDestAndBack (1)
> #if SwapDestAndBack
> CGImageRef temp = destinationImage;
> destinationImage;
> destinationImage = temp;
> #endif
> 
> CIImage *inputTargetImage = [CIImage 
> imageWithCGImage:destinationImage];
> [pageCurlFilter setValue:inputTargetImage forKey:@"inputTargetImage"];
> 
> CIImage *inputBacksideImage = [CIImage 
> imageWithCGImage:backsideImage];
> [pageCurlFilter setValue:inputBacksideImage 
> forKey:@"inputBacksideImage"];
> -
> 
> 
> OK, now that looks like as expected:
> 
> 
> 
> The backside image is gradient red, and its green center visible, just-barely 
> "wrapped around". And the revealed target is magenta, with its centered 
> orange triangle. 
> 
> 
> 
> So, why doesn't the magenta image image work on the backside...
> 
> 
> Swapping the images back the way you had them originally with the macro
> 
> #define SwapDestAndBack (0)
> 
> and changing your DrawFillTriangleAndCreateImage() to return a backside image 
> 30% larger than the other two, things look a little more as expected:
> 
> 
> 
> 
> Now the revealed target image is red, with its green central rect. And the 
> backside image does show the orange triangle, and a bit of the magenta 
> background...
> 
> But the backside seems really scaled-up. Well, we scaled it up 30%... but 
> making it even a tiny bit larger or smaller results in very different 
> results, such that either only a magenta or orange area is visible at all. 
> 
> There seems to be *lots* of interaction with the inputRectangle of the crop 
> filter producing the shadingImage. That may be the key...
> 
> That was all I had time to tweak, but hopefully it'll help a bit.
> 
> 
> 

___

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

Re: Core animation layers work on 10.7 but not 10.8 or 10.9

2014-03-31 Thread Kevin Meaney
I think this problem might go beyond Core Animation, unless NSAnimation is 
using CoreAnimation under the hood.

Apple's sample code Image Transition and Cocoa Slides both crash when built 
using Xcode 5.1 and run on 10.9.2. But built apps that apple provides with the 
sample code still work on 10.9.2. When built using Xcode 5.1 these samples 
crash when you do something that causes a CoreImage filter to be rendered.

I hit this over the weekend and again today so I thought I'd add it to the mix.

Kevin


On 31 Mar 2014, at 15:52, Bill Cheeseman  wrote:

> I wrote an application a couple of years ago that still runs perfectly on Mac 
> OS X 10.7, 10.8 and 10.9. I built it with Xcode 3.x on 10.7. It uses core 
> animation and layer hosting views.
> 
> Now I have to update it for unrelated reasons. But when I build the same code 
> with Xcode 5.1 on OS X 10.9,  the layers don't fully appear and don't animate 
> when I run it on 10.8, and they don't appear at all when I run it on 10.9 -- 
> but it runs perfectly on 10.7! Apparently, something has changed in Xcode 5.x 
> or the 10.8 and 10.9 frameworks or runtime.
> 
> Is there any specific thing I should look at to fix this so the application 
> will run properly on 10.8 and 10.9? I hate to have to relearn core animation 
> layers from scratch because I don't use them all that much. I have Googled 
> this issue and read the 10.8 and 10.9 Apple release notes and tried to update 
> things as they suggest, but I'm getting nowhere.
> 
> -- 
> 
> Bill Cheeseman - b...@cheeseman.name
> 
> ___
> 
> 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/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.com


___

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: Preparation for doing a bug report for CIPageCurlTransition

2014-03-31 Thread Kevin Meaney
Thanks for your input again.

On 31 Mar 2014, at 05:38, Graham Cox  wrote:
> OK, I dug out the source code - it's a very old piece of work from when Core 
> Image filters were first available. I'm definitely using Curl without a 
> shadow.
> 
> But, digging into the code,here's the thing - the image I set for the 
> 'backside' is something called 'blank', which is a dark gray (almost black) 
> solid colour, and that's what I see, with the original image mirrored on top 
> of it. So my assumption has always been that that was working fine, but in an 
> attempt to replicate your issue, I changed the backside image to something 
> more obvious. And I see it - once. After the first transition, I reuse the 
> filter for subsequent ones, just changing the input images. On subsequent 
> transitions, I don't see my backside test image - in fact it looks exactly 
> the same as the 'blank' case, which is now suggesting to me that my code in 
> fact has never worked correctly, it just wasn't obvious because my backside 
> image was the same as what you get when there's no image. Duh.

> So... I tried setting the inputBacksideImage parameter each time I use the 
> filter again, and this time it works every time. So it looks as if once the 
> transition has run it discards some of its parameters. In this case it's the 
> only image parameter that wasn't being set afresh, because of course the 
> source and destination images change. The other params - inputAngle and 
> radius, I'm not touching again, but they seem OK.

In my main project I've used the transition filters starting with the input 
time set to 0, and incrementing it up to 1. So the display of the backside 
image would never happen as the first image is the front side not turned over 
at all. Subsequent increments of time where the target image is revealed would 
have the backside image scrubbed from the way you describe it so I could 
perhaps understand that this might be the problem. However the code I used in 
my bug report to Apple and I linked to in a previous message to cocoa-dev as a 
gist https://gist.github.com/SheffieldKevin/9873485 only grabs one image and 
uses an input time of 0.5. There is no display of the backside image.

I've only been trying out the CIPageCurlTransition filter with still images, 
the source and destination images remain unchanged from one time increment to 
the next. The only property that I update the filter with from one increment to 
the next is inputTime.

> This is all a bit of a quick test without really examining the code 
> thoroughly, but a quick scan indicates that I'm using the transitions pretty 
> much exactly as per the example code in the Core Image Programming Guide. I 
> create the filter using +filterWithName:keysAndValues:, and then I retain the 
> filters in a list that the user can select from to pick a transition effect. 
> Each time I make a transition, I create a timer and allow it to run, the code 
> is what you see in the guide. All I've changed is forcing inputBacksideImage 
> before I start the timer.

hmmm, I wonder if it is how I'm setting the filter up. My main project follows 
the same approach as the code on the gist.

1. Create the filter using filterWithName
2. Set the filter defaults.
3. Apply each property one at a time using setValue:forKey.

CIFilter *filter = [CIFilter filterWithName:@"CIPageCurlTransition"];
[filter setDefaults];
[filter setValue:image forKey:@"inputImage"];

etc.

I'm wondering if the CIPageCurlTransition requires that it is set up using 
filterWithName:keysAndValues?

I've not had problems like this with any other filter.

Kevin




___

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: Preparation for doing a bug report for CIPageCurlTransition

2014-03-30 Thread Kevin Meaney
Hi Graham,

Thanks for replying. I've just tried setting the backside image to be the same 
as the front image but it still doesn't work.

Are you sure you are not using CIPageCurlWidthShadowTransition in your project 
because that works for me without a problem?

Kevin

On 30 Mar 2014, at 23:34, Graham Cox  wrote:

> Hi Kevin,
> 
> I have an old project that uses this transition, and as far as I know it 
> works correctly. I haven't got the source to hand though I can dig it up, but 
> running the app here shows a correct curl effect - BUT the proviso would be 
> that I use the same image for the front and back images, so that the reverse 
> side of the curled page appears as a mirror image to the front side. This is 
> how I think the effect may be expected to normally work - so much so that 
> perhaps it is assumed and if the image is not the same image as the front it 
> won't work?
> 
> --Graham
> 
> 
> On 31 Mar 2014, at 1:54 am, Kevin Meaney  wrote:
> 
>> No matter how many different ways I look at my code I can't see what I'm 
>> doing wrong. So now I've distilled down to its essence the using of the 
>> CIPageCurlTransition CoreImage filter. The problem is that the 
>> inputBacksideImage value option for the CIPageCurlTransition filter doesn't 
>> appear to work.
>> 
>> I've written a command line tool that takes one parameter, a path to where 
>> you want to save the generated image file. All the input images are 
>> generated internally by the command line tool.
>> 
>> I've posted the code to a gist on github here: 
>> https://gist.github.com/SheffieldKevin/9873485
>> 
>> I'm now going to write my bug report, but for some reason that takes me an 
>> age to do, so in the meantime I'd welcome any pointers to what I might be 
>> doing wrong. I suppose the reason why I am still actually dubious that it is 
>> an Apple bug is that there is absolutely no mention of this problem on the 
>> interwebs. I'm surprised that I'm first to hit it. The only possibility is 
>> that people find it doesn't work and try the CIPageCurlWithShadowTransition 
>> filter where assigning the inputBacksideImage does behave as expected and 
>> just use that filter.
>> 
>> This is 10.9.2 using Xcode 5.1.
>> 
>> Kevin
>> 
> 


___

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

Preparation for doing a bug report for CIPageCurlTransition

2014-03-30 Thread Kevin Meaney
No matter how many different ways I look at my code I can't see what I'm doing 
wrong. So now I've distilled down to its essence the using of the 
CIPageCurlTransition CoreImage filter. The problem is that the 
inputBacksideImage value option for the CIPageCurlTransition filter doesn't 
appear to work.

I've written a command line tool that takes one parameter, a path to where you 
want to save the generated image file. All the input images are generated 
internally by the command line tool.

I've posted the code to a gist on github here: 
https://gist.github.com/SheffieldKevin/9873485

I'm now going to write my bug report, but for some reason that takes me an age 
to do, so in the meantime I'd welcome any pointers to what I might be doing 
wrong. I suppose the reason why I am still actually dubious that it is an Apple 
bug is that there is absolutely no mention of this problem on the interwebs. 
I'm surprised that I'm first to hit it. The only possibility is that people 
find it doesn't work and try the CIPageCurlWithShadowTransition filter where 
assigning the inputBacksideImage does behave as expected and just use that 
filter.

This is 10.9.2 using Xcode 5.1.

Kevin





___

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: Having problems with the CoreImage CIPageCurlTransition filter

2014-03-28 Thread Kevin Meaney
Apologies,

I've just tried this using the CIPageCurlWithShadowTransition filter and it 
works. It is just the non shadow one that doesn't work.

Kevin

On 28 Mar 2014, at 21:59, Kevin Meaney  wrote:

> Hi,
> 
> I've setup a project for working with the CoreImage transition filters and 
> I've been going through making sure they work, and apart from the last 2 they 
> work. I can't get the backside image to appear on the back of the page being 
> turned over for the (CIPageCurlTransition, CIPageCurlWithShadowTransition) 
> filters. In the debugger I can see that it is being assigned to the 
> CIPageCurlTranstion and if I click the eye symbol I can see the correct image 
> is being set to the filter and checking the key (inputBacksideImage) that is 
> used to assign the CIImage everything is as it should be. The other images 
> (inputImage, inputTargetImage, and inputShadingImage) are all being set 
> properly and from the output it is clear that the CIPageCurlTransition filter 
> is working as it should apart from there being an image on the backside of 
> the page being turned. When it comes to assigning the images, the same 
> mechanism is used in all cases.
> 
> I thought I'd have a look at some Apple sample code and run them to see if 
> there was something specific about the assigning of the backside image that 
> doesn't apply to the other image. The first two samples I've tried both crash 
> as soon as I select the CIPageCurlTransition filter. The sample code I've 
> looked at is ImageTransition and CocoaSlides. I notice that both these 
> examples use the same image for the inputShadingImage and the 
> inputBacksideImage so even if they didn't crash I would have had to modify 
> them to provide a distinctive backside image anyway.
> 
> Have others had success applying a backside image to CIPageCurlTransition? If 
> so is there a trick to it that I'm missing
> 
> Kevin
> 
> 
> 
> 
> 
> 
> 
> 
> ___
> 
> 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/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.com


___

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

Having problems with the CoreImage CIPageCurlTransition filter

2014-03-28 Thread Kevin Meaney
Hi,

I've setup a project for working with the CoreImage transition filters and I've 
been going through making sure they work, and apart from the last 2 they work. 
I can't get the backside image to appear on the back of the page being turned 
over for the (CIPageCurlTransition, CIPageCurlWithShadowTransition) filters. In 
the debugger I can see that it is being assigned to the CIPageCurlTranstion and 
if I click the eye symbol I can see the correct image is being set to the 
filter and checking the key (inputBacksideImage) that is used to assign the 
CIImage everything is as it should be. The other images (inputImage, 
inputTargetImage, and inputShadingImage) are all being set properly and from 
the output it is clear that the CIPageCurlTransition filter is working as it 
should apart from there being an image on the backside of the page being 
turned. When it comes to assigning the images, the same mechanism is used in 
all cases.

I thought I'd have a look at some Apple sample code and run them to see if 
there was something specific about the assigning of the backside image that 
doesn't apply to the other image. The first two samples I've tried both crash 
as soon as I select the CIPageCurlTransition filter. The sample code I've 
looked at is ImageTransition and CocoaSlides. I notice that both these examples 
use the same image for the inputShadingImage and the inputBacksideImage so even 
if they didn't crash I would have had to modify them to provide a distinctive 
backside image anyway.

Have others had success applying a backside image to CIPageCurlTransition? If 
so is there a trick to it that I'm missing

Kevin








___

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: GIF frame duration

2014-03-25 Thread Kevin Meaney
If AppKit is using CoreGraphics for reading/writing GIF files then you might 
have hit the same issue I did.

http://blog.yvs.eu.com/2013/10/creating-gif-animations-using-coreimagequartz/

Kevin

On 25 Mar 2014, at 16:10, Andreas Mayer  wrote:

> 
> Am 25.03.2014 um 16:58 schrieb Andreas Mayer :
> 
>> Now what I'm seeing is AppKit reporting a frame delay of 0.1 s for any value 
>> below 0.6 s.
> 
> That's supposed to read 0.06 s, of course.
> 
>> Safari and Quicklook seem to use a threshold setting of 0.2 s.
> 
> And 0.02 s.
> 
> 
> Andreas
> ___
> 
> 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/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.com


___

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: Image without profile gets an sRGB profile on Mavericks

2014-03-23 Thread Kevin Meaney
I read somewhere that this change was part of Mavericks. I can't track that 
reference down right now, but I don't think Apple would consider it an error.

Kevin

On 23 Mar 2014, at 18:14, Leonardo  wrote:

> I create a jpg RGB image with Photoshop "without" any icc profile.
> I import it in my app.
> 
> NSBitmapImageRep*srcRep = [NSBitmapImageRep imageRepWithData:imageData];
> NSLog(@"profileName %@", srcRep.colorSpace.localizedName);
> 
> On OS X 10.8.5 I properly get "Device RGB".
> On Mavericks 10.9.2 I wrongly get "sRGB IEC61966-2.1".
> 
> Therefore I can't understand whether the image:
> 1. has no profile then I have to assign a profile chosen by my user.
> 2. has its own profile then I do not touch it.
> 
> I even tried CGColorSpaceCopyName. Same result.
> Did Apple changed its mind on Mavericks giving a profile to all the orphans,
> or am I missing some step?
> 
> 
> Regards
> -- Leonardo
> 
> 
> ___
> 
> 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/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.com


___

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: Best way to composite/tile multiple CGImages to one image

2014-03-23 Thread Kevin Meaney
I've experimented with trying to get the best performance I can with various 
different approaches by building a command line tool that creates a cover sheet 
of frame grabs from a movie file. I've blogged about my attempts here:

http://blog.yvs.eu.com/2014/03/ssd-versus-hdd-movie-frame-grabs-and-the-importance-of-profiling/

The approach with best results is on the link below (a github rep with multiple 
branches, the branch linked to here is the approach with best results). I'm 
happy with the results though I don't think performance is any better than Jim 
described below. It was an interesting path to follow to see what helped and 
didn't.
https://github.com/SheffieldKevin/makecoversheet/tree/nsoperationlimited

Kevin

On 12 Mar 2014, at 17:47, Jim Crate  wrote:

> 
> On Mar 8, 2014, at 9:17 AM, Trygve Inda  wrote:
> 
>>> On 08 Mar 2014, at 04:38, Trygve Inda  wrote:
 I need to composite/tile about 20 images in a 4x5 grid to one image.
>>> 
>>> What for? Knowing that might help finding a way to speed it up. I.e. why are
>>> the images separate, where are they supposed to go in the end? Display on
>>> screen? Writing to a standard image file format? Something else?
>> 
>> The images are coming from a video file at periodic intervals and are
>> destined for a jpg file consisting of multiple thumbnails stitched together.
>> 
>> The CGImages come from an AVAssetImageGenerator.
>> 
>> Instruments says the time spent in
>> 
>> [imageGenerator copyCGImageAtTime:targetTime actualTime:&actualTime
>> error:&error];
>> 
>> Is small, but the time in CGContextDrawImage is quite large. However, if I
>> comment out the CGContextDrawImage line, then the time spent in
>> copyCGImageAtTime it rather more significant.
>> 
>> I imagine when I get the CGImageRef from copyCGImageAtTime, I am not
>> actually getting any pixel data until it tries to draw in
>> CGContextDrawImage.
> 
> I have an app that does some transformations on images and writes them back 
> to jpegs, and it processes 25 images (1288×1936 pixels) per second on my 2011 
> MBP (2.2 i7), maxing all 8 cores.  Almost 50% of the time is spent in 
> CGContextDrawImage.  I played with the code a bit to use CoreImage instead, 
> and while it performed at roughly the same rate of 25 images per second, most 
> of the CPU time was now spent reading and encoding the jpegs, and CPU time 
> was cut in half.  In my case, the spinning platter hard disk is likely the 
> bottleneck, and the process is fast enough either way.  Since you are writing 
> 1 jpeg for every 20 images, using CoreImage will likely give you a noticeable 
> performance boost.
> 
> Jim Crate
> 
> 
> ___
> 
> 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/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.com


___

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: Getting a serial queue when asking for a concurrent one

2014-03-20 Thread Kevin Meaney
I forgot to mention I'm building against the 10.9 SDK and targeting 10.9 as a 
minimum.

Kevin

On 20 Mar 2014, at 20:05, Kevin Meaney  wrote:

> I'm doing:
> 
> myQueue = dispatch_queue_create("myque", DISPATCH_QUEUE_CONCURRENT);
> dispatch_set_target_queue(myQueue, 
> dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0));
> 
> When I hit a breakpoint in the debugger in when running in myQue I'm informed 
> that the queue "myque" is a serial queue. If I just do:
> 
> myQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
> 
> Then when I hit the breakpoint I'm informed that the queue is a concurrent 
> queue.
> 
> Now the Concurrency Programming Guide documentation says that to get a 
> concurrent queue you use the dispatch_get_global_queue. What I suppose 
> confuses me, is that in the header "queue.h" the notes for 
> dispatch_queue_create for the attr param specify DISPATCH_QUEUE_CONCURRENT 
> and DISPATCH_QUEUE_SERIAL as options.
> 
> If I option click on the dispatch_queue_create symbol it informs me that 
> prior to 10.7 the only option for the attr param is DISPATCH_QUEUE_SERIAL.
> 
> Kevin
> 
> 
> ___
> 
> 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/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.com


___

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

Getting a serial queue when asking for a concurrent one

2014-03-20 Thread Kevin Meaney
I'm doing:

myQueue = dispatch_queue_create("myque", DISPATCH_QUEUE_CONCURRENT);
dispatch_set_target_queue(myQueue, 
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0));

When I hit a breakpoint in the debugger in when running in myQue I'm informed 
that the queue "myque" is a serial queue. If I just do:

myQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);

Then when I hit the breakpoint I'm informed that the queue is a concurrent 
queue.

Now the Concurrency Programming Guide documentation says that to get a 
concurrent queue you use the dispatch_get_global_queue. What I suppose confuses 
me, is that in the header "queue.h" the notes for dispatch_queue_create for the 
attr param specify DISPATCH_QUEUE_CONCURRENT and DISPATCH_QUEUE_SERIAL as 
options.

If I option click on the dispatch_queue_create symbol it informs me that prior 
to 10.7 the only option for the attr param is DISPATCH_QUEUE_SERIAL.

Kevin


___

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: Best way to composite/tile multiple CGImages to one image

2014-03-19 Thread Kevin Meaney
On 18 Mar 2014, at 14:22, Jim Crate  wrote:
> 
> I would start with something like this:
> 
> CIImage *img = [CIImage emptyImage];
> for … {
>   // calculate tile position from index, create NSAffineTransform for 
> scaling/translating
>   CGImageRef tileRef = // get image from AV framework
>   CIImage *tile = [CIImage imageWithCGImage:tileRef];
>   
>   CIFilter *f = [CIFilter filterWithName:@"CIAffineTransform"];
>   [f setValue:transform   forKey:kCIInputTransformKey];
>   [f setValue:tileforKey:kCIInputImageKey];
>   tile = [f valueForKey:kCIOutputImageKey];
>   
>   CIFilter *f = [CIFilter filterWithName:@"CISourceOverCompositing"];
>   [f setValue:img forKey:kCIInputBackgroundImageKey];
>   [f setValue:tileforKey:kCIInputImageKey];
>   img = [f valueForKey:kCIOutputImageKey];
> 
>   // you’ll need to figure out whether it is safe to CGImageRelease your 
> grabbed CGImageRef here 
>   // or if you need to keep track of them and release them at the end of 
> the process
> }
> 
> // you’ll have to figure out your colorspace and bitmap info
> CGColorSpaceRef colorSpace = CGImageGetColorSpace(imgRef);
> CGBitmapInfo bitmapInfo = CGImageGetAlphaInfo(imgRef);
> CGContextRef cgContext = CGBitmapContextCreate(NULL, destRect.size.width, 
> destRect.size.height, 8, 0, colorSpace, bitmapInfo);
> 
> CIContext *ciContext = [CIContext contextWithCGContext:cgContext options:nil];
> CGImageRef tiledImageRef = [ciContext createCGImage:img fromRect:[img 
> extent]];
> 
> // save the image using ImageIO
> CGImageDestinationRef destRef = CGImageDestinationCreateWithURL((__bridge 
> CFURLRef)destURL, (__bridge CFStringRef)imageType, 1, NULL);
> CGImageDestinationSetProperties(destRef, (__bridge CFDictionaryRef)propsDict);
> CGImageDestinationAddImage(destRef, tiledImageRef, (__bridge 
> CFDictionaryRef)propsDict);
> CGImageDestinationFinalize(destRef);
> 
> CGImageRelease(imageRef);
> CFRelease(destRef);
> 
> 
> If you wanted better thumbnail image quality, you could use the Lanczos 
> filter first, then just use the NSAffineTransform to translate the picture to 
> the proper tile position.  Also, I see there is an imageByApplyingTransform 
> method that takes a CGAffineTransform, so it may be even simpler if you’d 
> rather use that.  

I felt the need to give this a go and I've produced a little command line tool 
that tests this out. I've also provided some performance results for a few 
options. I've gone for the CILanczosTransform filter, I don't know if that 
slows things down, a quick look at the profile results didn't appear to show 
that any one area dominated overly so I've not done anything to try and 
optimize but at the same time I'm not that impressed with the speed.

I was also going to try and include an option for the command line to select 
creating the coversheets using coregraphics and gcd to achieve concurrency but 
the more I thought about the harder it seemed to integrate the two different 
approaches into 1 tool. I'm going to try write a new tool to do that. Perhaps 
once I've finished it I'll better be able to see how both approaches can be 
integrated.

The information including code etc. you can view at the git hub repository 
where I've saved stuff.

https://github.com/SheffieldKevin/makecoversheet

Kevin





___

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

generateCGImagesAsynchronouslyForTimes:completionHandler

2014-03-18 Thread Kevin Meaney
The discussion for this AVAssetImageGenerator method mentions that this method 
uses an efficient "batch mode" to get image in time order.

What I don't see any info on, is whether the completion handler is called on 
the same queue as the one from which 
generateCGImagesAsynchronouslyForTimes:completionHandler was called or not?

Does anyone know?

Kevin


___

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: Best way to composite/tile multiple CGImages to one image

2014-03-08 Thread Kevin Meaney
On 8 Mar 2014, at 06:55, Trygve Inda  wrote:
>> 
>> On 8 Mar 2014, at 5:02 pm, Trygve Inda  wrote:
>> 
>>> This is slower by about 15%.   :(
> 
> Interestingly if I call:
> 
> CGContextSetInterpolationQuality ([context graphicsPort],
> kCGInterpolationNone);
> 
> It results in 10% slower processing. The antialiasing setting does not
> affect speed at all.
> 
> Doing multiple threads will require quite a bit of work - I may give that a
> try too. The destination is both screen and a file so I don't think Core
> Animation will work.
> 
> I might be near the limits of what I can do speed-wise here.  :(

I think Graham's point about using multiple threads, or better yet multiple 
queues is a good one and depending on the computer (how many cores) will likely 
get you significant speed improvements and a more responsive main thread.

You can move all downscaling and creation of new downscaled CGImage's using 
dispatch_apply. Then do a dispatch_async to the main queue for the  reply block 
to draw the newly downscaled images to your cgcontext.

I was thinking that CoreImage and CIFilters might help but I'm not so sure, as 
with the large images, you have to push all the data into GPU memory which I 
think will take any speed benefit. But rather than applying that assumption it 
would be better to get the different approaches profiled.

The WWDC session from 2011 Blocks and Grand Central Dispatch in Practice 308 
talks about the use of dispatch_apply. I've written notes about that session 
here: 
http://blog.yvs.eu.com/2013/07/blocks-and-grand-central-dispatch-in-practice/

The 2012 WWDC session 712: Asynchronous design patterns with blocks, gcd and 
xpc is also worth looking at. 
http://blog.yvs.eu.com/2013/07/asynchronous-design-patterns-with-blocks-gcd-and-xpc/

Kevin

___

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: Draw image within a NSBezierPath with no border

2014-03-06 Thread Kevin Meaney
I'd try clipping before drawing the fill, rather than after.

Kevin

On 6 Mar 2014, at 16:34, Leonardo  wrote:

> Hi, I have an oval NSBezierPath path. I fill it with a blue color,
> then I draw an image within the same path. And I can still see a blue tiny
> border around the image. I would expect the color be never visible since the
> image covers the whole area. That's my code:
> 
> fillPath = [NSBezierPath bezierPathWithOvalInRect:fillBounds];
> [aBlueColor set];
> [fillPath fill];
> [fillPath addClip];
> [image drawInRect:fillBounds fromRect:NSZeroRect
> operation:NSCompositeSourceOver fraction:1.0];
> 
> Even if I draw the image in a bigger rect, the blue border is still there.
> What do I miss?
> 
> 
> Regards
> -- Leonardo
> 
> 
> ___
> 
> 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/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.com


___

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: Issues with CIFilters and CALayers

2014-02-27 Thread Kevin Meaney
I don't know. I'm not actually trying to integrate CIFilters and Core Animation 
in the way that you are doing. I remembered that you had mentioned the name 
property of the CIFilter because that property is actually useful to me, 
because I need a way to refer to filters which are earlier in the filter chain 
and the name seems like a useful way to find a filter that I want.

Kevin

On 27 Feb 2014, at 17:38, Gordon Apple  wrote:

> Thank you.   I would have never found that. But what does “enabled” do?  Or, 
> more precisely, what does “not enabled” do? If a filter is not enabled, does 
> that mean it is transparent and simply passes input to output?  I can’t 
> believe something so simple in concept as a freeze filter is so difficult to 
> implement.  CIFilters are black magic. They just don’t seem to follow the 
> usual expectations of software constructs.
> 
> I did get my highlighting filter to work, using color blend and/or a 
> GaussianBlur embedded filter for the background, with controllable 
> parameters. The user can even live-draw and edit the clear areas of the 
> filter (used as a transient layer in a presentation layer stack).  It 
> provides a very nice effect for drawing attention to specific areas.
> 
> 
> On 2/27/14 9:42 AM, "Kevin Meaney"  wrote:
> 
>> First a note. The name property is declared as a CACIFilterAdditions in 
>> CACIFilterAdditions.h.
>> 
>> I think you will need to draw the CIImage to your CIContext and then 
>> generate a CGImage to capture its state for future reference and then 
>> generate a new CIImage from the CGImage. I believe the CIImage that is the 
>> output of a filter is more a recipe about how to generate an image and not a 
>> bitmap representation of the image which I think is where your problem lies.
>> 
>> Kevin
>> 
>> Sent from my iPhone
>> 
>> On 24 Feb 2014, at 17:28, Gordon Apple  wrote:
>> 
>> > Apparently, my comment about not understanding this construct for
>> > setValueForKeyPath was correct.  It actually works. I finally got the
>> > highlighting filter to work and update properly. Now I¹m trying to do
>> > something much simpler, i.e., construct a freezeFilter.  Nothing I¹ve tried
>> > so far works.  Apparently, a CIFilter is expected to be stateless function
>> > such as outputImage = f(inputImage, parameters). Not accepting this 
>> > premiss,
>> > I decided to try caching the first output image ( from the outputImage
>> > method), then return the cashed image thereafter, an ultra simple concept,
>> > except that it does not work. Any reason, besides what I postulated, why
>> > this shouldn¹t work?
>> > 
>> > 

___

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: Issues with CIFilters and CALayers

2014-02-27 Thread Kevin Meaney
First a note. The name property is declared as a CACIFilterAdditions in 
CACIFilterAdditions.h.

I think you will need to draw the CIImage to your CIContext and then generate a 
CGImage to capture its state for future reference and then generate a new 
CIImage from the CGImage. I believe the CIImage that is the output of a filter 
is more a recipe about how to generate an image and not a bitmap representation 
of the image which I think is where your problem lies.

Kevin

Sent from my iPhone

On 24 Feb 2014, at 17:28, Gordon Apple  wrote:

> Apparently, my comment about not understanding this construct for
> setValueForKeyPath was correct.  It actually works. I finally got the
> highlighting filter to work and update properly. Now I¹m trying to do
> something much simpler, i.e., construct a freezeFilter.  Nothing I¹ve tried
> so far works.  Apparently, a CIFilter is expected to be stateless function
> such as outputImage = f(inputImage, parameters). Not accepting this premiss,
> I decided to try caching the first output image ( from the outputImage
> method), then return the cashed image thereafter, an ultra simple concept,
> except that it does not work. Any reason, besides what I postulated, why
> this shouldn¹t work?
> 
> 
> On 2/23/14 3:06 PM, "Gordon Apple"  wrote:
> 
>> We have run into a number is issues trying to use CIFilters with CALayers:
>> 
>> 1. When a layer is hidden, its filters, especially background filters, should
>> be temporarily removed, or at least bypassed.  Hiding the layer should make 
>> if
>> effectively non-existent in the displayed layer stack.
>> 
>> 2. The docs should tell you that in a CIFilter you cannot auto-synthesize
>> filter input parameters. This simply does not work, especially for 
>> inputImage.
>> 
>> 3. The docs for CALayer filters and background filters say you should name
>> your filters for use in changing parameters. I.e., filter.name = @²myFilter².
>> Amazingly, this works, in spite of the fact that there is no public property
>> called ³name² for a CIFilter.
>> 
>> 4. The example keyPath makes no sense whatsoever, unless we just don¹t
>> understand keyPaths:
>> 
>> [layer setValue:XXX forKeyPath:@²backgroundFilters.myFilter.filterParam²];
>> 
>> backgroundFilters is an array of filters. myFilter is a property value of 
>> some
>> element of the array. (huh?)
>> 
>> 5. We need some decent documentation of what in GL Shading Language is
>> actually relevant to writing ciKernels, besides the one page addendum
>> provided.
>> 
>> 6. And, of course, the problem we have already mentioned in a previous post
>> about getting a CALayer to update when a filter parameter is changed.
> 
> 
> ___
> 
> 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/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.com

___

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: CIAreaMaximum filter not working

2014-02-26 Thread Kevin Meaney
Well I've worked something out.

If the CGContext supplied buffer that the CIContext draws the results of the 
CIAreaMaximum filter to uses float components it doesn't work. Providing a 
context which is 8 bit ints per component with 4 components RGBA works.

Not the result I wanted, but at least I have something that works even thoug I 
lose some dynamic range.

Kevin

On 26 Feb 2014, at 12:50, Kevin Meaney  wrote:

> I've written a command line routine that compares two image files, in the 
> hope of determining if the two files are different. Basically the tool only 
> compares whether the dimensions are different or whether the pixel values are 
> sufficiently different. So the routine has a distance option which is a 
> threshold value over which any color component of any pixel needs to be over 
> to decide if the images are different.
> 
> The full single file source code for this is available here:
> https://gist.github.com/SheffieldKevin/9228574
> 
> To implement this I've used two CIFilters, first the CIDifferenceBlendMode 
> filter followed by the CIAreaMaximum.
> 
> I've checked that the CIDifferenceBlendMode is working by grabbing the 
> outputImage CIImage from the filter and saving it in a file on the desktop 
> called deleteme.png. If you look at the code you'll see that the code for 
> saving the intermediate image is still in there. If you compile and run you 
> can setup the command line args similar to:
> 
> compareimages -file1 "~/Pictures/DSCN1003.JPG" -file2 
> "~/Pictures/DSCN1004.JPG"
> 
> The color distance option has a default value so is not required.
> 
> The intermediate image looks as expected so I'm assuming that the problem has 
> to be with how I'm using the CIAreaMaximum filter. 
> 
> Can anyone point me in the direction as to what it is I'm doing wrong?
> 
> Kevin
> 
> 
> ___
> 
> 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/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.com

___

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: exporting image files to disk using CGImageDestination

2014-02-26 Thread Kevin Meaney
This has fixed itself. I don't know how or why. But after installing 10.9.2 and 
rebooting the tiff files with varying alpha values look the same as png files. 
I don't think it was the update to 10.9.2 but I've got no proof, but instead I 
think it is related to the fact that I've occasionally had problems with 
graphics after the automatic switching of using the discrete and integrated 
graphic cards has occurred. This happens when I'm switching between using my 
laptop plugged into an external monitor, or when using the laptop without the 
external display but switching  between running the laptop plugged into the 
power supply and not.

Whatever the reason I can no longer investigate because it currently works.

Kevin
___

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

CIAreaMaximum filter not working

2014-02-26 Thread Kevin Meaney
I've written a command line routine that compares two image files, in the hope 
of determining if the two files are different. Basically the tool only compares 
whether the dimensions are different or whether the pixel values are 
sufficiently different. So the routine has a distance option which is a 
threshold value over which any color component of any pixel needs to be over to 
decide if the images are different.

The full single file source code for this is available here:
https://gist.github.com/SheffieldKevin/9228574

To implement this I've used two CIFilters, first the CIDifferenceBlendMode 
filter followed by the CIAreaMaximum.

I've checked that the CIDifferenceBlendMode is working by grabbing the 
outputImage CIImage from the filter and saving it in a file on the desktop 
called deleteme.png. If you look at the code you'll see that the code for 
saving the intermediate image is still in there. If you compile and run you can 
setup the command line args similar to:

compareimages -file1 "~/Pictures/DSCN1003.JPG" -file2 "~/Pictures/DSCN1004.JPG"

The color distance option has a default value so is not required.

The intermediate image looks as expected so I'm assuming that the problem has 
to be with how I'm using the CIAreaMaximum filter. 

Can anyone point me in the direction as to what it is I'm doing wrong?

Kevin


___

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: exporting image files to disk using CGImageDestination

2014-02-25 Thread Kevin Meaney
On 24 Feb 2014, at 18:59, Kevin Meaney  wrote:
> On 24 Feb 2014, at 18:40, David Duncan  wrote:
>> 
>> How are you generating these images? Specifically, the CGImageRef you pass 
>> to CGImageDestination and the pixels backing it.
>> 
>> PNG does not store premultiplied image data, so the pixels will be 
>> un-multiplied for storage if necessary. TIFF does not seem to have a 
>> position on which form the data takes, but decoders may expect 
>> pre-multiplied since thats what Photoshop writes.
>> 
>> If your starting image is not pre-multiplied alpha, then the TIFF may be 
>> written the same way but decoded with a pre-multiplied assumption, which 
>> would make the image look horrible.
> 
> The image is created from a CGContext RGBA, 8 bits per component. sRGB 
> profile with a bitmap info option of kCGImageAlphaPremultipliedLast. As far 
> as I can tell you can't create a CGContext with an alpha channel that isn't 
> pre-multiplied. I tried creating as few different types with no success.
> 
> In my coreimage filter, I unpremultiply the color values before calculating 
> the new alpha values which will then be multiplied against the old alpha and 
> then I pre-multiply again before the coreimage kernel filter returns.

I've looked for alternatives with this a little more. I was hoping I might be 
able to create a CIContext from a vImage buffer so that I could provide a 
buffer that didn't hint it was pre-multiplied. But there is no option to do 
that.

I took the generated tiff file and saved it as a png file. The rendering of the 
png file was considerably better than that for the tiff file where alpha was 
neither 0.0 or 1.0. Rendering was better but it was also clear that something 
had gone wrong with the (pre)multiply calculations going via the generation of 
the tiff file. Since the areas of the image where alpha was somewhere between 0 
and 1, but not at either end the image which had been created from the tiff 
file was brighter in those areas.

It is almost like when creating the tiff file there is a unpremul step (which 
from what's been implied on this thread is correct), but when coming to render 
the image from the tiff file it is assumed the image has been pre-multiplied. 
I'm only using Preview to view the images, and I'm wondering if I need another 
app to view the images in. But at the same time I'd like images I generate to 
look good in Preview.

Kevin


___

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: exporting image files to disk using CGImageDestination

2014-02-24 Thread Kevin Meaney
On 24 Feb 2014, at 18:40, David Duncan  wrote:
> On Feb 24, 2014, at 10:25 AM, Kevin Meaney  wrote:
>> I'd already done that, but doing it again made me realize that the problem 
>> is 100% associated with the alpha channel. Where the pixels are fully opaque 
>> everything is fine. Where pixels are semi-transparent is where the problem 
>> occurs. Fully transparent is also fine. I wonder if the problem is to do 
>> with premultiply. Does TIFF deal with an image generated from a 
>> premultiplied bitmap properly?
> 
> How are you generating these images? Specifically, the CGImageRef you pass to 
> CGImageDestination and the pixels backing it.
> 
> PNG does not store premultiplied image data, so the pixels will be 
> un-multiplied for storage if necessary. TIFF does not seem to have a position 
> on which form the data takes, but decoders may expect pre-multiplied since 
> thats what Photoshop writes.
> 
> If your starting image is not pre-multiplied alpha, then the TIFF may be 
> written the same way but decoded with a pre-multiplied assumption, which 
> would make the image look horrible.

The image is created from a CGContext RGBA, 8 bits per component. sRGB profile 
with a bitmap info option of kCGImageAlphaPremultipliedLast. As far as I can 
tell you can't create a CGContext with an alpha channel that isn't 
pre-multiplied. I tried creating as few different types with no success.

In my coreimage filter, I unpremultiply the color values before calculating the 
new alpha values which will then be multiplied against the old alpha and then I 
pre-multiply again before the coreimage kernel filter returns.

Kevin

___

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: exporting image files to disk using CGImageDestination

2014-02-24 Thread Kevin Meaney

On 24 Feb 2014, at 18:04, Bill Dudney  wrote:
> 
> Make sure that what you are looking at is what you think you are looking at. 
> When you look at it in Preview is it being scaled? If so then the default 
> scaling algorithm in Preview for TIFF might be 'fast but ugly’ (I don’t know, 
> just guessing). With a PNG it might be choosing a ‘nice but slower’ algorithm.
> 
> My recommendation would be to ensure you are looking at the image unscaled as 
> both PNG and TIFF. In Preview I think the menu item is ‘Show Full Size’ or 
> something like that.

I'd already done that, but doing it again made me realize that the problem is 
100% associated with the alpha channel. Where the pixels are fully opaque 
everything is fine. Where pixels are semi-transparent is where the problem 
occurs. Fully transparent is also fine. I wonder if the problem is to do with 
premultiply. Does TIFF deal with an image generated from a premultiplied bitmap 
properly?

> If the docs are vague it would help to file a bug 
> (http://bugreporter.apple.com) to make sure the people in charge of those 
> docs get your input.

I wrote a bug report ages ago relating to the ImageIO documentation when I had 
the same problem understanding the settings when creating gif animations using 
CGImageDestination. I've not had any response to that bug report.

Thanks for the help.
Kevin



___

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: exporting image files to disk using CGImageDestination

2014-02-24 Thread Kevin Meaney
On 24 Feb 2014, at 18:08, Sandy McGuffog  wrote:

> You should not be seeing worse image quality for TIFF unless very different 
> options are being used in each case. Can you tell what about the image 
> quality is worse?

That was my assumption which is why I was confused. As per my reply to Bill 
Dudney I've noted that the problem is only there for semi-transparent pixels in 
a tiff image file. I'm wondering if in that case the problem is related to 
pre-multiplied images?

Kevin


___

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: exporting image files to disk using CGImageDestination

2014-02-24 Thread Kevin Meaney
On 24 Feb 2014, at 17:21, Mike Abdullah  wrote:

> On 24 Feb 2014, at 17:00, Kevin Meaney  wrote:
>> I've written a command line tool that takes an image file (when testing I'm 
>> using JPEG files) and applies a custom CIFilter (a naive chroma key filter 
>> I've written) and saves a file to disk. Sampling the command line tool when 
>> processing files shows it is spending 90% of its time writing the png file 
>> of which most of this time is spent in a function called deflate in libz. 
>> The final file quality is good. I'm using CGImageDestination to export the 
>> file with default settings.
> I’m a little unclear here. Are you saying the process appears to much slower 
> than you can reasonably expect? Or simply that you’d like to find a way to 
> make it go faster? (something which may well not be very possible)
> 

I'd like one of two things, either getting the same quality exporting as TIFF 
as I do with PNG since exporting as tiff is more than 5 times faster, or that 
saving as PNG is faster. I suppose I don't understand when TIFF saving as 
uncompressed is meant to be lossless why is the image quality so much worse 
than saving as PNG.

The ImageIO documentation relating to the dictionary properties when setting 
values to the CGImageDestination object, or when adding an image to the 
destination object are not really clear as to where to set which is 
appropriate. Secondly the description of the keys for the dictionary are not 
particularly helpful. Trying to work out what settings my work to achieve my 
goal is confusing and perhaps it is impossible. Both the speed difference 
between TIFF and PNG, and the quality difference surprised me.

Kevin
___

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

exporting image files to disk using CGImageDestination

2014-02-24 Thread Kevin Meaney
I've written a command line tool that takes an image file (when testing I'm 
using JPEG files) and applies a custom CIFilter (a naive chroma key filter I've 
written) and saves a file to disk. Sampling the command line tool when 
processing files shows it is spending 90% of its time writing the png file of 
which most of this time is spent in a function called deflate in libz. The 
final file quality is good. I'm using CGImageDestination to export the file 
with default settings. I thought I'd try exporting the image file as tiff 
instead using CGImageDestination with default settings. The command line tool 
is about 5 times faster but the display of the tiff file in Preview is much 
worse than the display of the png file.

The tiff files are about twice the size of the png files. I've now tried 
setting kCGImageDestinationLossyCompressionQuality to 1.0 when adding an image 
to be exported to the CGImageDestination object when exporting as tiff without 
any improvement in the tiff image quality.

Trying to see what the problem with tiff file image is, it is almost like there 
is only a 1 bit alpha channel. But checking the tiff image file using tiffinfo 
gives:

  Image Width: 2272 Image Length: 1704
  Bits/Sample: 8
  Sample Format: unsigned integer
  Compression Scheme: none
  Photometric Interpretation: RGB color
  Alpha: Present
  Orientation: row 0 top, col 0 lhs
  Samples/Pixel: 4
  Rows/Strip: 14
  Number of Strips: 122
  Planar Configuration: Not planar
  Profile Name: sRGB IEC61966-2.1

I don't particularly care whether I am exporting as tiff or png, and not too 
fussed about the file size. But I'd like the quality I'm getting with the png 
file but I would like saving to be faster. Does anyone have suggestions? Is 
there a known issue(s)?

I've just tried exporting as png with the 
kCGImageDestinationLossyCompressionQuality set to 1.0 but this doesn't change 
things.

I hadn't really expected kCGImageDestinationLossyCompressionQuality to make a 
difference as it seems really designed for saving jpeg files. The only thing 
I've not tried but like setting kCGImageDestinationLossyCompressionQuality it 
seems pointless. I could try LZW compression when saving the tiff file. But 
since both uncompressed and LZW are meant to be lossless I can't see how this 
could make a difference. The PNG file reports the same colorspace, profile and 
bits per channel as the tiff file and contains an alpha channel.

Kevin


___

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

Writing a custom core image filter part 2

2014-02-23 Thread Kevin Meaney
In the CoreImage Programming guide on the discussion about writing a custom 
filter one of the steps described it to write a custom attributes method called 
"customAttributes". I used as a template of what I needed to do the 
customAttributes method implemented in Apple's sample code for 
AVGreenScreenPlayer and so I have implemented my customAttributes method as 
follows:

- (NSDictionary *)customAttributes
{
   NSDictionary *inputColorProps;
   inputColorProps = @{ kCIAttributeClass : [CIColor class],
  kCIAttributeDefault : YVSChromaKeyFilterDefaultInputColor,
 kCIAttributeType : kCIAttributeTypeOpaqueColor };

   NSDictionary *inputDistanceProps;
   inputDistanceProps = @{
kCIAttributeClass : [NSNumber class],
  kCIAttributeDefault : YVSChromaKeyFilterDefaultInputDistance,
 kCIAttributeType : kCIAttributeTypeDistance };

   NSDictionary *inputSlopeWidthProps = @{
   kCIAttributeClass : [NSNumber class],
 kCIAttributeDefault : YVSChromaKeyFilterDefaultInputSlopeWidth,
kCIAttributeType : kCIAttributeTypeDistance };

   return @{ kCIInputColorKey : inputColor,
 @"inputDistance" : inputDistanceProps,
   @"inputSlopeWidth" : inputSlopeWidthProps };
}

Nothing else is described as being needed in relation to attributes in the 
CoreImage Programming guide. But when I call where filter is a 
YVSChromaKeyFilter object:

NSDictionary *attribs = [filter attributes];

I get an exception thrown:

2014-02-23 16:19:00.623 chromakey[19946:303] *** Terminating app due to 
uncaught exception 'NSInvalidArgumentException', reason: '*** 
-[NSMutableDictionary addEntriesFromDictionary:]: dictionary argument is not an 
NSDictionary'
*** First throw call stack:
(
0   CoreFoundation  0x7fff8608e41c 
__exceptionPreprocess + 172
1   libobjc.A.dylib 0x7fff808d1e75 
objc_exception_throw + 43
2   CoreFoundation  0x7fff85faabfc 
-[NSMutableDictionary addEntriesFromDictionary:] + 492
3   CoreImage   0x7fff8492d4a9 -[CIFilter 
attributes] + 458
4   chromakey   0x0001365d 
-[YVSChromaKeyImageProcessor run] + 1517
5   chromakey   0x00014115 main + 149
6   libdyld.dylib   0x7fff839af5fd start + 1
7   ??? 0x000f 0x0 + 15
)
libc++abi.dylib: terminating with uncaught exception of type NSException

So once again, I feel like I'm missing something. Is there something else I 
need to be doing?

Kevin

___

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

Writing a core image custom filter

2014-02-23 Thread Kevin Meaney
Apologies for the cross posting from quartz-dev. But it seems these days that 
it is hard to work out which forum, lists/devforum and then which of the 
discussions to then post.

I've been playing with creating a core image filter for OS X. I've got simple 
chroma key filter working as I would like, except for two issues. The first 
issue is a compile warning which if I ignore doesn't stop the filter from 
working. But I'd still like it resolved even if it is only for me to understand 
what is going on, or perhaps that it highlights something that I'm doing wrong 
but non-critical.

The filter is defined like so in the header:

@interface YVSChromaKeyFilter : CIFilter

Because I'm currently using the filter in a simple stand alone command line 
tool and I want to keep this option as a use for the filter I'm not packaging 
the filter up into a image unit as the recommended way to distribute image 
filters by apple so I'm using the alternate method which uses the 
registerFilterName method called from the filter's class initialize method:

@implementation YVSChromaKeyFilter

+(void)initialize
{
   if (self == [YVSChromaKeyFilter class])
   {
   NSArray *kernels = [CIKernel kernelsWithString:YVSChromaKeyFilterString];
   chromaKeyKernel = kernels[0];
   [CIFilter registerFilterName:@"YVSChromaKeyFilter"
constructor:(id)self
classAttributes:@{
   kCIAttributeFilterDisplayName : @"Simple Chroma Key.",
kCIAttributeFilterCategories : @[
  kCICategoryColorAdjustment, kCICategoryVideo,
  kCICategoryStillImage, kCICategoryInterlaced,
  kCICategoryNonSquarePixels]
}
];
   }
}

+(CIFilter *)filterWithName:(NSString *)name
{
   CIFilter  *filter;
   filter = [[YVSChromaKeyFilter alloc] init];
   return filter;
}

Note the cast in the constructor: option of the registerFilterName method, this 
was done to remove the compiler warning but really should not be there. I tried 
adding the protocol to the YVSChromaKeyFilter interface but that made no 
difference. My filter gets created correctly when I set things up as above and 
do:

CIFilter *filter =  [CIFilter filterWithName:@"YVSChromaKeyFilter"];

Now the protocol CIFilterConstructor interface is as follows:

@protocol CIFilterConstructor
- (CIFilter *)filterWithName:(NSString *)name;
@end

Which confuses me since I have to implement a class method filterWithName not 
an object method.

As I said, the filter works and does what I want but I'm missing something here 
that I'd like clarified and hopefully resolve things in a way that the ugly 
cast can be removed.

I'll put the second issue into a new e-mail as I think putting it here now will 
just add confusion.

Kevin

___

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: 6.1.6 for iPhones?

2014-02-23 Thread Kevin Meaney
From the comments I've seen iOS 7 is slower than iOS 6 which on my iPhone 4 is 
already sluggish. I'm not sure I'm happy with the state of affairs Apple has 
left me in.

Kevin

On 23 Feb 2014, at 19:27, Clark Smith Cox III  wrote:

> 
> On Feb 22, 2014, at 6:58 PM, Rick Mann  wrote:
> 
>> There's an update to iOS 6.1 for iPod Touch 4th gen and iPhone 3GS, but none 
>> for other devices?
> 
>   iOS 6.1.6 doesn’t exist for any other devices. Those two are the only 
> devices for which iOS 6.1.6 is the latest available version, all other 
> devices are either limited to 5.1.x (or earlier) or can be upgraded to 7.0.6. 
> 
> -- 
> Clark Smith Cox III
> clark@apple.com
> 
> ___
> 
> 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/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.com


___

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: ARC and autorelease pools

2014-02-17 Thread Kevin Meaney
Thanks to Marcel, John McCall, and Clark Smith Cox III for addressing the 
question I was trying to ask, apologies to others that the question was unclear.

So it seems that because ARC provides compatibility between ARC and non-ARC 
code unlike how garbage collection worked with duplicated frameworks is part of 
or even the main reason we can't get rid of autorelease.

My response to Roland's first reply to this thread was incorrect. I had 
forgotten the reason why I new that class methods like stringWithFormat return 
an autoreleased object. When I first learnt ARC in May last year I wrote a blog 
post covering my experiments of when an object stays alive and when it doesn't. 
I hadn't just assumed, I'd forgotten why I new.

In terms of crossing boundaries I find the result of TestArc9() interesting 
when passing a weak pointer into a function.

The last line of output from each test routine is at the end of the blog post 
if you want to test your understanding.

http://blog.yvs.eu.com/2013/05/experimental-arc/

Kevin

On 17 Feb 2014, at 08:08, Marcel Weiher  wrote:

> 
> On Feb 17, 2014, at 2:08 , Clark Smith Cox III  wrote:
> 
>>> I didn't say take them out. I said why do they need to return an 
>>> autoreleased object.
>> 
>> Because they always have, and their semantics cannot be changed without 
>> breaking decades worth of non-ARC code.
> 
> Sort of like the way GC did, where you had to have 2 versions of every 
> framework, the GC version and the non-GC version.  If you had 2 versions of 
> every framework and the compiler enforced a no autorelease rule, then you 
> could have what you want.
> 
> However, one of the big points of ARC was to not require 2 versions of every 
> framework, but instead provide compatibility between ARC and non-ARC code.  
> Therefore all the old requirements for autorelease, which have been explained 
> so well by various posters, apply.
> 
> Cheers,
> 
> Marcel
> 

___

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: ARC and autorelease pools

2014-02-16 Thread Kevin Meaney

On 16 Feb 2014, at 17:06, Jens Alfke  wrote:

> On Feb 16, 2014, at 5:27 AM, Kevin Meaney  wrote:
> 
>> Is the only reason for interoperability with manual retain-release code?
> 
> For backward compatibility. Nearly every piece of existing Cocoa code uses 
> these methods, so there's no way they could take them out.

I didn't say take them out. I said why do they need to return an autoreleased 
object. Why can't they just return an object like alloc init... does. I think 
Roland's main point is to ask do they return an autoreleased object. I 
foolishly assumed they did because a modified version of autorelease was kept 
with the transition to ARC and my most common experience of dealing with 
autoreleased objects was via the behaviour of the class methods that create 
objects. So yes a foolish assumption on my behalf.

>> It seems that it creates an unnecessary complication when thinking about 
>> memory management. Now I'm assuming that any method like:
>> NSString *expandedPath = [myPath stringByExpandingTildeInPath];
>> returns an autoreleased string so I need to know this if I'm doing this with 
>> lots of strings and that I need to put my own autorelease pool in place, 
>> something I wouldn't have to think about if it wasn't an autoreleased object.
> 
> You don't just need to consider whether methods you call return autoreleased 
> objects (and as Roland pointed out, it's not always clear whether a returned 
> object really has been autoreleased or not.) You also need to consider 
> whether the method you called caused objects to be autoreleased as part of 
> the work it did.

You're missing the question I was trying to ask. Why is autorelease needed at 
all? If we don't have autorelease then it is precisely clear whether a returned 
object is autoreleased or not. Something we don't even have to consider. We 
don't have to worry about whether further down the stack autoreleased objects 
have been created or not and that in certain situations up the stack we need to 
add in a autorelease pool.

I've read through some of the clang documentation Roland referred to, much of 
it over my head. I did note that there was some discussion over making sure 
that objects remain alive over the return boundary and in some cases 
autorelease was used for this purpose. But I'm still failing to grasp why, if 
autorelease is being used in some cases for making sure an object remains alive 
over a return boundary that means there are other ways of dealing with making 
sure an object remains alive over the return boundary, do we need autorelease? 
I just feel like I'm missing something. The people at Apple or Clang have 
decided that keeping autorelease is necessary and I'm struggling to understand 
why when it seems to me it adds unnecessary complexity. Not major but just 
another thing that can go wrong if you dont think about it, and so you have to 
think about it and that takes mental resources away from the job at hand.

Kevin
___

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

ARC and autorelease pools

2014-02-16 Thread Kevin Meaney
I've realized that my understanding of ARC is not as good as I thought it was. 
So I'll be asking couple of questions.

With ARC I don't understand why autorelease pools are needed anymore except for 
with objects passed by reference. What I mean by that is that class methods 
like:

NSString *myString = [NSString stringWithFormat:@"%@", @"my string"];

Why do these methods need to return an autoreleased object, why can't they 
behave the same as:

NSString *myString = [[NSString alloc] initWithFormat:@"%@", @"my String];

Is the only reason for interoperability with manual retain-release code?

It seems that it creates an unnecessary complication when thinking about memory 
management. Now I'm assuming that any method like:

NSString *expandedPath = [myPath stringByExpandingTildeInPath];

returns an autoreleased string so I need to know this if I'm doing this with 
lots of strings and that I need to put my own autorelease pool in place, 
something I wouldn't have to think about if it wasn't an autoreleased object. 
Documentation doesn't provide any information as to which methods return an 
autoreleased object or not.

But since I can't call autorelease myself in ARC code if I have a method like. 

KMImage *bigImage = [image kmImageByDoublingSize];

I'm not returning an autoreleased object so there is a difference in behaviour 
between the behaviour of methods in apple frameworks and the ones outside of 
those frameworks.

I've read a couple of posts on stackoverflow in relation to ARC and 
autorelease, but the justification given in the answers as to why autorelease 
is needed is because there are methods that return autoreleased objects so we 
need to have a mechanism to put auto release pools in place, which I feel is a 
little circular.

Is there something more fundamental that I'm missing beyond interoperability 
that means we still need autorelease pools or is it just that?

Kevin


___

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

  1   2   >