Operations Beachball

2012-12-04 Thread Gerriet M. Denkmann
My app creates lots of MyOperations (subclass of NSOperation) and puts them 
into an NSOperationQueue.

I would expect that the app thus remains responsive, but sometimes it is not.

A sure way to beach-ball my app is: start it with a few hundred operations 
(which will take about 20 seconds to finish). 
Make some other app active. 
Try to make my app active again - it's panel stays grey and after a few seconds 
the cursor will turn into a beach-ball.

These MyOperations interact with their controller in two ways:

1. they do once at start:  [ controller dataStringFor: row ];

The controller has:

- (NSString *) dataStringFor: (NSUInteger)row
{
@synchronized(self) 
{
if ( self.stringArray == nil ) { create it - takes some time, 
but happens only once};
}
return self.stringArray[row];
}


2. When MyOperations have finished their work they call: [ controller  done: 
row  result: someNumber ];

The controller has:

- (void) done: (NSUInteger) row  result: (NSUInteger) someNumber
{   
@synchronized(self)
{
[ self.rowsToDo removeIndex: row ]; //  
NSMutableIndexSet
};

//  sometimes do some logging, update user interface - but only 
every few seconds
}

So, why the beach-ball? What am I doing wrong? How to debug this? Why does the 
app-switch make the beach-ball appear?

Gerriet.

10.8.2, Arc



___

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: Operations Beachball

2012-12-04 Thread Mike Abdullah
You have a performance problem. Thus you should use Instruments to see what is 
going on, rather than hope we can tell you from vague snippets of code.

On 4 Dec 2012, at 10:29, "Gerriet M. Denkmann"  wrote:

> My app creates lots of MyOperations (subclass of NSOperation) and puts them 
> into an NSOperationQueue.
> 
> I would expect that the app thus remains responsive, but sometimes it is not.
> 
> A sure way to beach-ball my app is: start it with a few hundred operations 
> (which will take about 20 seconds to finish). 
> Make some other app active. 
> Try to make my app active again - it's panel stays grey and after a few 
> seconds the cursor will turn into a beach-ball.
> 
> These MyOperations interact with their controller in two ways:
> 
> 1. they do once at start:  [ controller dataStringFor: row ];
> 
> The controller has:
> 
> - (NSString *) dataStringFor: (NSUInteger)row
> {
>   @synchronized(self) 
>   {
>   if ( self.stringArray == nil ) { create it - takes some time, 
> but happens only once};
>   }
>   return self.stringArray[row];
> }
> 
> 
> 2. When MyOperations have finished their work they call: [ controller  done: 
> row  result: someNumber ];
> 
> The controller has:
> 
> - (void) done: (NSUInteger) row  result: (NSUInteger) someNumber
> { 
>@synchronized(self)
>   {
>   [ self.rowsToDo removeIndex: row ]; //  
> NSMutableIndexSet
>   };
> 
>   //  sometimes do some logging, update user interface - but only 
> every few seconds
> }
> 
> So, why the beach-ball? What am I doing wrong? How to debug this? Why does 
> the app-switch make the beach-ball appear?
> 
> Gerriet.
> 
> 10.8.2, Arc
> 
> 
> 
> ___
> 
> 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/cocoadev%40mikeabdullah.net
> 
> This email sent to cocoa...@mikeabdullah.net


___

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: Operations Beachball

2012-12-04 Thread Gerriet M. Denkmann

On 4 Dec 2012, at 17:49, Mike Abdullah  wrote:

> You have a performance problem. Thus you should use Instruments to see what 
> is going on, rather than hope we can tell you from vague snippets of code.

Maybe I should use Instruments, problem is: I cannot.

I start Instruments, select some template (e.g. Leaks), attach to a 
(user-)process, click "Record", and now a panel comes up (which I have never 
seen before): "Instruments wants permission to analyse other processes. Type an 
admin...".
Annoying, but maybe necessary.

But now nothing happens, i.e no recording takes place.
What magic do I have to perform to make Instruments (4.5) work?
(I asked this on the Xcode list already, but got no answer).

> 
> On 4 Dec 2012, at 10:29, "Gerriet M. Denkmann"  wrote:
> 
>> My app creates lots of MyOperations (subclass of NSOperation) and puts them 
>> into an NSOperationQueue.
>> 
>> I would expect that the app thus remains responsive, but sometimes it is not.
>> 
>> A sure way to beach-ball my app is: start it with a few hundred operations 
>> (which will take about 20 seconds to finish). 
>> Make some other app active. 
>> Try to make my app active again - it's panel stays grey and after a few 
>> seconds the cursor will turn into a beach-ball.
>> 
>> These MyOperations interact with their controller in two ways:
>> 
>> 1. they do once at start:  [ controller dataStringFor: row ];
>> 
>> The controller has:
>> 
>> - (NSString *) dataStringFor: (NSUInteger)row
>> {
>>  @synchronized(self) 
>>  {
>>  if ( self.stringArray == nil ) { create it - takes some time, 
>> but happens only once};
>>  }
>>  return self.stringArray[row];
>> }
>> 
>> 
>> 2. When MyOperations have finished their work they call: [ controller  done: 
>> row  result: someNumber ];
>> 
>> The controller has:
>> 
>> - (void) done: (NSUInteger) row  result: (NSUInteger) someNumber
>> {
>>   @synchronized(self)
>>  {
>>  [ self.rowsToDo removeIndex: row ]; //  
>> NSMutableIndexSet
>>  };
>> 
>>  //  sometimes do some logging, update user interface - but only 
>> every few seconds
>> }
>> 
>> So, why the beach-ball? What am I doing wrong? How to debug this? Why does 
>> the app-switch make the beach-ball appear?
>> 
>> Gerriet.
>> 
>> 10.8.2, Arc
>> 
>> 
>> 
>> ___
>> 
>> 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/cocoadev%40mikeabdullah.net
>> 
>> This email sent to cocoa...@mikeabdullah.net
> 


___

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: Operations Beachball

2012-12-04 Thread Roland King
Can you not run Instruments from the 'Profile' button on Xcode? It should start 
the process and attach to it and go from there. 

On 4 Dec, 2012, at 7:02 PM, "Gerriet M. Denkmann"  wrote:

> 
> On 4 Dec 2012, at 17:49, Mike Abdullah  wrote:
> 
>> You have a performance problem. Thus you should use Instruments to see what 
>> is going on, rather than hope we can tell you from vague snippets of code.
> 
> Maybe I should use Instruments, problem is: I cannot.
> 
> I start Instruments, select some template (e.g. Leaks), attach to a 
> (user-)process, click "Record", and now a panel comes up (which I have never 
> seen before): "Instruments wants permission to analyse other processes. Type 
> an admin...".
> Annoying, but maybe necessary.
> 
> But now nothing happens, i.e no recording takes place.
> What magic do I have to perform to make Instruments (4.5) work?
> (I asked this on the Xcode list already, but got no answer).
> 
>> 
>> On 4 Dec 2012, at 10:29, "Gerriet M. Denkmann"  wrote:
>> 
>>> My app creates lots of MyOperations (subclass of NSOperation) and puts them 
>>> into an NSOperationQueue.
>>> 
>>> I would expect that the app thus remains responsive, but sometimes it is 
>>> not.
>>> 
>>> A sure way to beach-ball my app is: start it with a few hundred operations 
>>> (which will take about 20 seconds to finish). 
>>> Make some other app active. 
>>> Try to make my app active again - it's panel stays grey and after a few 
>>> seconds the cursor will turn into a beach-ball.
>>> 
>>> These MyOperations interact with their controller in two ways:
>>> 
>>> 1. they do once at start:  [ controller dataStringFor: row ];
>>> 
>>> The controller has:
>>> 
>>> - (NSString *) dataStringFor: (NSUInteger)row
>>> {
>>> @synchronized(self) 
>>> {
>>> if ( self.stringArray == nil ) { create it - takes some time, 
>>> but happens only once};
>>> }
>>> return self.stringArray[row];
>>> }
>>> 
>>> 
>>> 2. When MyOperations have finished their work they call: [ controller  
>>> done: row  result: someNumber ];
>>> 
>>> The controller has:
>>> 
>>> - (void) done: (NSUInteger) row  result: (NSUInteger) someNumber
>>> {   
>>>  @synchronized(self)
>>> {
>>> [ self.rowsToDo removeIndex: row ]; //  
>>> NSMutableIndexSet
>>> };
>>> 
>>> //  sometimes do some logging, update user interface - but only 
>>> every few seconds
>>> }
>>> 
>>> So, why the beach-ball? What am I doing wrong? How to debug this? Why does 
>>> the app-switch make the beach-ball appear?
>>> 
>>> Gerriet.
>>> 
>>> 10.8.2, Arc
>>> 
>>> 
>>> 
>>> ___
>>> 
>>> 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/cocoadev%40mikeabdullah.net
>>> 
>>> This email sent to cocoa...@mikeabdullah.net
>> 
> 
> 
> ___
> 
> 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/rols%40rols.org
> 
> This email sent to r...@rols.org

___

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: Operations Beachball

2012-12-04 Thread jonat...@mugginsoft.com

On 4 Dec 2012, at 10:29, Gerriet M. Denkmann  wrote:

> My app creates lots of MyOperations (subclass of NSOperation) and puts them 
> into an NSOperationQueue.
> 
> I would expect that the app thus remains responsive, but sometimes it is not.
> 
> A sure way to beach-ball my app is: start it with a few hundred operations 
> (which will take about 20 seconds to finish). 
> Make some other app active. 
> Try to make my app active again - it's panel stays grey and after a few 
> seconds the cursor will turn into a beach-ball.
> 
> These MyOperations interact with their controller in two ways:
> 
> 1. they do once at start:  [ controller dataStringFor: row ];
> 
> The controller has:
> 
> - (NSString *) dataStringFor: (NSUInteger)row
> {
>   @synchronized(self) 
>   {
>   if ( self.stringArray == nil ) { create it - takes some time, 
> but happens only once};
>   }
>   return self.stringArray[row];
> }
> 
Does the app also access the controller object?
You are locking the controller so the main app's performance may also be 
affected if the controller is shared with the main thread.

In the absence of Instruments I would at least experiment with no oping the 
@synchronized methods and try and exclude them as a problem source.

Jonathan
___

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: Operations Beachball

2012-12-04 Thread Gerriet M. Denkmann

On 4 Dec 2012, at 18:10, Roland King  wrote:

> Can you not run Instruments from the 'Profile' button on Xcode? It should 
> start the process and attach to it and go from there. 

I got the Leaks Instrument to work this way (no Leaks) But all other 
Instruments just prompted repeatedly for an admin password but did not do 
anything at all.

Activity Monitor gave me a Sample. Here is the main thread:

Call graph:
1343 Thread_3102216   DispatchQueue_1: com.apple.main-thread  (serial)
+ 1343 start  (in libdyld.dylib) + 1  [0x7fff983887e1]
+   1343 NSApplicationMain  (in AppKit) + 869  [0x7fff96809cb6]
+ 1343 -[NSApplication run]  (in AppKit) + 517  [0x7fff96865283]
+   1343 -[NSApplication 
nextEventMatchingMask:untilDate:inMode:dequeue:]  (in AppKit) + 128  
[0x7fff9686ded2]
+ 1343 _DPSNextEvent  (in AppKit) + 685  [0x7fff9686e613]
+   1343 BlockUntilNextEventMatchingListInMode  (in HIToolbox) + 62 
 [0x7fff90ec2cd3]
+ 1343 ReceiveNextEventCommon  (in HIToolbox) + 217  
[0x7fff90ec2db7]
+   1343 AcquireEventFromQueue  (in HIToolbox) + 561  
[0x7fff90eccf8f]
+ 1343 _NotifyEventLoopObservers  (in HIToolbox) + 155  
[0x7fff90e9b6e0]
+   1343 HIApplication::EventObserver(unsigned int, 
OpaqueEventRef*, void*)  (in HIToolbox) + 193  [0x7fff90ecd407]
+ 1343 HIApplication::HandleActivated(OpaqueEventRef*, 
unsigned char, OpaqueWindowPtr*)  (in HIToolbox) + 177  [0x7fff90ecfe0f]
+   1343 SetMenuBarObscured  (in HIToolbox) + 221  
[0x7fff90ed0144]
+ 1343 MenuBarInstance::Show(MenuBarAnimationStyle, 
unsigned char, unsigned char, unsigned char)  (in HIToolbox) + 625  
[0x7fff90ea5063]
+   1343 BroadcastToolboxMessage  (in HIToolbox) + 
294  [0x7fff90e6e12a]
+ 1343 
HIS_XPC_CFNotificationCenterPostNotification  (in HIServices) + 532  
[0x7fff8e57f174]
+   1343 CFNotificationCenterPostNotification  
(in CoreFoundation) + 115  [0x7fff95edbbf3]
+ 1343 _CFXNotificationPost  (in 
CoreFoundation) + 1109  [0x7fff95ecced5]
+   1343 -[_NSDNXPCConnection 
sendMessage:waitForAck:]  (in CoreFoundation) + 347  [0x7fff95fec12b]
+ 1343 _dispatch_semaphore_wait_slow  
(in libdispatch.dylib) + 241  [0x7fff97ed0486]
+   1343 semaphore_wait_trap  (in 
libsystem_kernel.dylib) + 10  [0x7fff95ac86c2]


I have no idea, what this means.
Maybe someone can enlighten me.

Gerriet.


> 
> On 4 Dec, 2012, at 7:02 PM, "Gerriet M. Denkmann"  
> wrote:
> 
>> 
>> On 4 Dec 2012, at 17:49, Mike Abdullah  wrote:
>> 
>>> You have a performance problem. Thus you should use Instruments to see what 
>>> is going on, rather than hope we can tell you from vague snippets of code.
>> 
>> Maybe I should use Instruments, problem is: I cannot.
>> 
>> I start Instruments, select some template (e.g. Leaks), attach to a 
>> (user-)process, click "Record", and now a panel comes up (which I have never 
>> seen before): "Instruments wants permission to analyse other processes. Type 
>> an admin...".
>> Annoying, but maybe necessary.
>> 
>> But now nothing happens, i.e no recording takes place.
>> What magic do I have to perform to make Instruments (4.5) work?
>> (I asked this on the Xcode list already, but got no answer).
>> 
>>> 
>>> On 4 Dec 2012, at 10:29, "Gerriet M. Denkmann"  wrote:
>>> 
 My app creates lots of MyOperations (subclass of NSOperation) and puts 
 them into an NSOperationQueue.
 
 I would expect that the app thus remains responsive, but sometimes it is 
 not.
 
 A sure way to beach-ball my app is: start it with a few hundred operations 
 (which will take about 20 seconds to finish). 
 Make some other app active. 
 Try to make my app active again - it's panel stays grey and after a few 
 seconds the cursor will turn into a beach-ball.
 
 These MyOperations interact with their controller in two ways:
 
 1. they do once at start:  [ controller dataStringFor: row ];
 
 The controller has:
 
 - (NSString *) dataStringFor: (NSUInteger)row
 {
@synchronized(self) 
{
if ( self.stringArray == nil ) { create it - takes some time, 
 but happens only once};
}
return self.stringArray[row];
 }
 
 
 2. When MyOperations have finished their work they call: [ controller  
 done: row  result: someNumber ];
 
 The controller has:
 
 - (void) done: (NSUInteger) row  result: (NSUInteger) someNumber
 {  
  @synchronized(self)
{
[ self.rowsToDo removeIndex: row ]; //  
 NSMutableIndexSet
};
 
//  so

Re: Operations Beachball

2012-12-04 Thread Gerriet M. Denkmann

On 4 Dec 2012, at 18:31, "jonat...@mugginsoft.com"  
wrote:

>  
> 
> On 4 Dec 2012, at 10:29, Gerriet M. Denkmann  wrote:
> 
>> My app creates lots of MyOperations (subclass of NSOperation) and puts them 
>> into an NSOperationQueue.
>> 
>> I would expect that the app thus remains responsive, but sometimes it is not.
>> 
>> A sure way to beach-ball my app is: start it with a few hundred operations 
>> (which will take about 20 seconds to finish). 
>> Make some other app active. 
>> Try to make my app active again - it's panel stays grey and after a few 
>> seconds the cursor will turn into a beach-ball.
>> 
>> These MyOperations interact with their controller in two ways:
>> 
>> 1. they do once at start:  [ controller dataStringFor: row ];
>> 
>> The controller has:
>> 
>> - (NSString *) dataStringFor: (NSUInteger)row
>> {
>>  @synchronized(self) 
>>  {
>>  if ( self.stringArray == nil ) { create it - takes some time, 
>> but happens only once};   
>>  }
>>  return self.stringArray[row];
>> }
>> 
> Does the app also access the controller object?
The controller is also the app delegate.

> You are locking the controller so the main app's performance may also be 
> affected if the controller is shared with the main thread.
The code inside @synchronized is absolute minimal. I will be used every 50 
milli-seconds. Cannot believe this blocks the controller.
> 
> 
> In the absence of Instruments I would at least experiment with no oping the 
> @synchronized methods and try and exclude them as a problem source.
Did comment out both @synchronized lines - same problem - no change at all.

Kind regards,

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/archive%40mail-archive.com

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


Re: Get the current displayed NSAlert

2012-12-04 Thread Brad O'Hearne
In general -- any alert that requires user attention (especially ones with 
multiple button alternatives) can be left on the screen indefinitely by a user. 
If you are monitoring environmental conditions (such as network, server, or 
Internet reachability) that arise, it is always possible that such an event 
that would necessarily need to supersede the displayed alert, as the global 
event (environmental condition) might prevent the normal course of action which 
the first alert would provide. For example: 

1) Alert one displays:
"This condition took place, would you like to proceed with option X or option 
Y". (Assume both X and Y require Internet connectivity). 

2) The app detects a loss of Internet connectivity. Neither X nor Y are now 
appropriate until the Internet reachability issue is resolved. So what we need 
to do is redirect the user's attention to resolving the more important problem 
at hand, fixing the network issue, a second alert condition. 

The thing compounding the issue is that 1) and 2) occur in somewhat unrelated 
parts of the app which necessarily do not know what each other is doing (other 
than existing). That is actually a very good thing -- and we want to somewhat 
keep it that way. They do have a relationship, however, in that the managing 
entity in 2 actually controls the entity in 1 (though agnostic to its 
function). So the problem was resolved by having the managing entity in 2 issue 
a lifecycle message to the entity in 1, so that it could behave accordingly.

Its working, but in any such architecture (an OS is a good example) there is 
the constant tension between managing resources globally vs. separating and 
hiding concerns within components.  

Thanks for the replies everyone, they are greatly appreciated. 

Cheers, 

Brad

On Dec 4, 2012, at 12:54 AM, "jonat...@mugginsoft.com" 
 wrote:

> 
> On 4 Dec 2012, at 06:26, Kyle Sluder  wrote:
> 
>> I think you're thinking about the problem too generally.
>> 
>> The workflow manager is probably going to need to understand that the
>> plugins it's running can have encounter exceptional conditions.
>> Therefore, there should be a mechanism by which your processing plugins
>> can inform the workflow manager of these exceptional conditions.
> 
> I would implement an alert controller that would accept prioritised alert 
> requests either from the app or a plug-in.
> 
> I would also ask myself whether a simple alert sheet is the way to go.
> Alerts are asking for the user to attend. 
> If a plugin alert is displayed and then inexplicably replaced by another it 
> looks as if the software is conflicted.
> 
> Perhaps the alert controller displays a single dismissible window that 
> contains a scrollable prioritised list of active alerts.
> 
> Jonathan
> ___
> 
> 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/brado%40bighillsoftware.com
> 
> This email sent to br...@bighillsoftware.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: Get the current displayed NSAlert

2012-12-04 Thread Kyle Sluder
On Dec 4, 2012, at 7:49 AM, Brad O'Hearne  wrote:

> In general -- any alert that requires user attention (especially ones with 
> multiple button alternatives) can be left on the screen indefinitely by a 
> user. If you are monitoring environmental conditions (such as network, 
> server, or Internet reachability) that arise, it is always possible that such 
> an event that would necessarily need to supersede the displayed alert, as the 
> global event (environmental condition) might prevent the normal course of 
> action which the first alert would provide. For example: 
> 
> 1) Alert one displays:
> "This condition took place, would you like to proceed with option X or option 
> Y". (Assume both X and Y require Internet connectivity). 
> 
> 2) The app detects a loss of Internet connectivity. Neither X nor Y are now 
> appropriate until the Internet reachability issue is resolved. So what we 
> need to do is redirect the user's attention to resolving the more important 
> problem at hand, fixing the network issue, a second alert condition. 
> 
> The thing compounding the issue is that 1) and 2) occur in somewhat unrelated 
> parts of the app which necessarily do not know what each other is doing 
> (other than existing). That is actually a very good thing -- and we want to 
> somewhat keep it that way. They do have a relationship, however, in that the 
> managing entity in 2 actually controls the entity in 1 (though agnostic to 
> its function). So the problem was resolved by having the managing entity in 2 
> issue a lifecycle message to the entity in 1, so that it could behave 
> accordingly.
> 
> Its working, but in any such architecture (an OS is a good example) there is 
> the constant tension between managing resources globally vs. separating and 
> hiding concerns within components.  

Yeah, you're walking that fine line between “framework” and “application” that 
requires such attention to balance.

We use a lot of frameworks in our products. I constantly have to remind myself 
that the framework is not my product; the app is, and that might mean severely 
reining in the scope and generality of the supporting framework.

--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: Layers in NSCollectionView

2012-12-04 Thread Gordon Apple
Sorry for the delay.  I¹ve been inaccessible for reasons I won¹t get into.
I have tried it without setting any layers in IB.  I think you may be
correct about the copies.  Another thing I don¹t know is if each cell simply
uses the prototype to draw in the correct location, or it it does actually
make copies for each cell.  I¹m hoping for the latter, because what I really
want is an AVPlayerLayer. The view I¹ve been referring to is intended to by
my own version of an AVPlayerView (which I wish they would provide in
AVFoundation, similar to the bindable QTMovieView.  I have filed an
enhancement request.)   If the copy does not handle the layer-hosted view in
the prototype correctly, then I¹m screwed.  I have also tried just adding
the layer to the backing layer, without success.  I think I¹ve about
exhausted the options.

This collection  is a bank of AVPlayer controls for all movies which
currently appear in the presentation window, on a different screen, and I
want a (hopefully) playing thumbnail by the controls for easy
identification.  I may have to settle for a starting image, which isn¹t very
useful is the movies fade in from black.  Another thing AVFoundation lacks
is access to something like a poster frame.

I may file a bug report and see what happens.  I¹ve been filing bug reports
right an left lately.   Unfortunately, haven¹t been getting much response.


On 12/2/12 8:32 PM, "Kyle Sluder"  wrote:

> Well, it's probably not a good idea to turn on layer-backing for a view in nib
> and then try to transform it into a layer-hosting view by assigning to its
> layer property and then calling -setWantsLayer:YES. There's a chance that
> NSView will say, "oh, my wantsLayer property is already yes; I'll just keep on
> doing my thing" even though your intent was to remove AppKit's ownership of
> your layer.
> 
> To be honest, the difference between layer-backed and layer-hosting views is
> still murky, though the situation has gotten slightly better with the 10.8
> AppKit release notes. I just want one document that explicitly describes
> *precisely* what AppKit does and does not control in each case. :-/
> 
> I did just remember something, though: NSCollectionView copies its collection
> items around in some sort of crazy way that was subtly changed with the
> introduction of NSViewController. Is it possible that the views in your
> collection view are *NOT* the same instances that were unarchived from nib,
> but rather *copies* of those views created by sending -encodeWithCoder: to the
> collection item's view?
> 
> --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: Operations Beachball

2012-12-04 Thread jonathan

On 4 Dec 2012, at 11:48, Gerriet M. Denkmann  wrote:

> 
> On 4 Dec 2012, at 18:10, Roland King  wrote:
> 
>> Can you not run Instruments from the 'Profile' button on Xcode? It should 
>> start the process and attach to it and go from there. 
> 
> I got the Leaks Instrument to work this way (no Leaks) But all other 
> Instruments just prompted repeatedly for an admin password but did not do 
> anything at all.
> 
> Activity Monitor gave me a Sample. Here is the main thread:
> 
> Call graph:
>   1343 Thread_3102216   DispatchQueue_1: com.apple.main-thread  (serial)
>   + 1343 start  (in libdyld.dylib) + 1  [0x7fff983887e1]
>   +   1343 NSApplicationMain  (in AppKit) + 869  [0x7fff96809cb6]
>   + 1343 -[NSApplication run]  (in AppKit) + 517  [0x7fff96865283]
>   +   1343 -[NSApplication 
> nextEventMatchingMask:untilDate:inMode:dequeue:]  (in AppKit) + 128  
> [0x7fff9686ded2]
>   + 1343 _DPSNextEvent  (in AppKit) + 685  [0x7fff9686e613]
>   +   1343 BlockUntilNextEventMatchingListInMode  (in HIToolbox) + 62 
>  [0x7fff90ec2cd3]
>   + 1343 ReceiveNextEventCommon  (in HIToolbox) + 217  
> [0x7fff90ec2db7]
>   +   1343 AcquireEventFromQueue  (in HIToolbox) + 561  
> [0x7fff90eccf8f]
>   + 1343 _NotifyEventLoopObservers  (in HIToolbox) + 155  
> [0x7fff90e9b6e0]
>   +   1343 HIApplication::EventObserver(unsigned int, 
> OpaqueEventRef*, void*)  (in HIToolbox) + 193  [0x7fff90ecd407]
>   + 1343 HIApplication::HandleActivated(OpaqueEventRef*, 
> unsigned char, OpaqueWindowPtr*)  (in HIToolbox) + 177  [0x7fff90ecfe0f]
>   +   1343 SetMenuBarObscured  (in HIToolbox) + 221  
> [0x7fff90ed0144]
>   + 1343 MenuBarInstance::Show(MenuBarAnimationStyle, 
> unsigned char, unsigned char, unsigned char)  (in HIToolbox) + 625  
> [0x7fff90ea5063]
>   +   1343 BroadcastToolboxMessage  (in HIToolbox) + 
> 294  [0x7fff90e6e12a]
>   + 1343 
> HIS_XPC_CFNotificationCenterPostNotification  (in HIServices) + 532  
> [0x7fff8e57f174]
>   +   1343 CFNotificationCenterPostNotification  
> (in CoreFoundation) + 115  [0x7fff95edbbf3]
>   + 1343 _CFXNotificationPost  (in 
> CoreFoundation) + 1109  [0x7fff95ecced5]
>   +   1343 -[_NSDNXPCConnection 
> sendMessage:waitForAck:]  (in CoreFoundation) + 347  [0x7fff95fec12b]
>   + 1343 _dispatch_semaphore_wait_slow  
> (in libdispatch.dylib) + 241  [0x7fff97ed0486]
>   +   1343 semaphore_wait_trap  (in 
> libsystem_kernel.dylib) + 10  [0x7fff95ac86c2]
> 
> 
> I have no idea, what this means.
> Maybe someone can enlighten me.
> 
> Gerriet.
> 
Your app is blocking waiting for a semaphore.
The extract below is from 
http://developer.apple.com/library/mac/#documentation/Darwin/Conceptual/KernelProgramming/synchronization/synchronization.html

A semaphore is much like a lock, except that a finite number of threads can 
hold it simultaneously. Semaphores can be thought of as being much like piles 
of tokens. Multiple threads can take these tokens, but when there are none 
left, a thread must wait until another thread returns one. It is important to 
note that semaphores can be implemented in many different ways, so Mach 
semaphores may not behave in the same way as semaphores on other platforms.

It looks as if part of the menu system needs a particular semaphore which is 
currently blocked as a result of other operations.

I don't have a solution but the following is related.
http://stackoverflow.com/questions/13148684/deadlock-using-dispatch-semaphore-t-in-a-concurrent-queue

Jonathan
___

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


Beachballing 2

2012-12-04 Thread Gerriet M. Denkmann
My app creates lots of MyOperations (subclass of NSOperation) and puts them 
into an NSOperationQueue.
These operations do not do any I/O - they just use the Cpu.

When I make some other app active and then try again to make my app active, my 
app beach-balls. When all my operations have finished, the app becomes 
responsive again.

This seems to be a known problem:  


I used to do:
[ self.operationQueue setMaxConcurrentOperationCount: 
NSOperationQueueDefaultMaxConcurrentOperationCount ];

because I wanted "the receiver to choose an appropriate value based on the 
number of available processors and other relevant factors."

But, the receiver obviously chooses a value, which is NOT appropriate at all.

When I change this to:
[ self.operationQueue setMaxConcurrentOperationCount: 7 ];
my app runs 3% slower (not 14% slower as I expected) and the beach-ball problem 
disappears.

The problem: 7 is the right magic number on my machine with my number of 
processor cores etc.
But certainly on other machines the number will be different.

So: How do I choose an appropriate number?
And is this a bug (NSOperationQueue choosing an inappropriate number) or not?

Gerriet.

P.S. Big thanks to Jonathan for his very valuable help off-list.


___

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


NSOperation Efficiency

2012-12-04 Thread Gerriet M. Denkmann
I have an app which uses NSOperations inside an NSOperationQueue. These 
operations do not do any I/O - just Cpu. No swapping is taking place.

When I set [ self.operationQueue setMaxConcurrentOperationCount: 1 ] each 
operation takes on average 200 msec., measured by NSDate.

With 2 concurrent operations, it takes not 100 msec but 110 - an extra 10%. Ok 
- some overhead is to be expected.

With 4 ops it takes 70 instead of 50 - overhead 40% - rather a lot.
With 8 ops it takes 60 instead of 25 - overhead 140%. or: 40% of the cpu is 
used by my operations, 60% is used by whom? And for what?

Is this to be expected? Or does my app has some hidden flaws? If so, where 
should I start looking?

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/archive%40mail-archive.com

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


Re: Beachballing 2

2012-12-04 Thread Alex Zavatone
WAG - the # of cores - 1?

On Dec 4, 2012, at 12:54 PM, Gerriet M. Denkmann wrote:

> My app creates lots of MyOperations (subclass of NSOperation) and puts them 
> into an NSOperationQueue.
> These operations do not do any I/O - they just use the Cpu.
> 
> When I make some other app active and then try again to make my app active, 
> my app beach-balls. When all my operations have finished, the app becomes 
> responsive again.
> 
> This seems to be a known problem:  
> 
> 
> I used to do:
> [ self.operationQueue setMaxConcurrentOperationCount: 
> NSOperationQueueDefaultMaxConcurrentOperationCount ];
> 
> because I wanted "the receiver to choose an appropriate value based on the 
> number of available processors and other relevant factors."
> 
> But, the receiver obviously chooses a value, which is NOT appropriate at all.
> 
> When I change this to:
> [ self.operationQueue setMaxConcurrentOperationCount: 7 ];
> my app runs 3% slower (not 14% slower as I expected) and the beach-ball 
> problem disappears.
> 
> The problem: 7 is the right magic number on my machine with my number of 
> processor cores etc.
> But certainly on other machines the number will be different.
> 
> So: How do I choose an appropriate number?
> And is this a bug (NSOperationQueue choosing an inappropriate number) or not?
> 
> Gerriet.
> 
> P.S. Big thanks to Jonathan for his very valuable help off-list.
> 
> 
> ___
> 
> 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/zav%40mac.com
> 
> This email sent to z...@mac.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: Operations Beachball

2012-12-04 Thread Jens Alfke

On Dec 4, 2012, at 3:48 AM, Gerriet M. Denkmann  wrote:

> My app creates lots of MyOperations (subclass of NSOperation) and puts them 
> into an NSOperationQueue.
> I would expect that the app thus remains responsive, but sometimes it is not.

Welcome to the joys of multithreaded programming. :-P You have to be pretty 
careful about how you do things, or all sorts of unintuitive and flaky 
behaviors can result.

>+ 1343 
> MenuBarInstance::Show(MenuBarAnimationStyle, unsigned char, unsigned char, 
> unsigned char)  (in HIToolbox) + 625 [0x7fff90ea5063]
>+   1343 BroadcastToolboxMessage  (in HIToolbox) + 
> 294  [0x7fff90e6e12a]
>+ 1343 
> HIS_XPC_CFNotificationCenterPostNotification  (in HIServices) + 532  
> [0x7fff8e57f174]
>+   1343 CFNotificationCenterPostNotification  
> (in CoreFoundation) + 115  [0x7fff95edbbf3]
>+ 1343 _CFXNotificationPost  (in 
> CoreFoundation) + 1109  [0x7fff95ecced5]
>+   1343 -[_NSDNXPCConnection 
> sendMessage:waitForAck:]  (in CoreFoundation) + 347  [0x7fff95fec12b]
>+ 1343 _dispatch_semaphore_wait_slow  
> (in libdispatch.dylib) + 241  [0x7fff97ed0486]
>+   1343 semaphore_wait_trap  (in 
> libsystem_kernel.dylib) + 10  [0x7fff95ac86c2]
> 
> 
> I have no idea, what this means.
> Maybe someone can enlighten me.

The main thread is sending a cross-process (XPC) message and waiting for a 
reply. Presumably this has something to do with arbitration of the menu bar 
state since the menu bar is a shared resource between apps? But it doesn’t seem 
related to anything you’re doing.

You didn’t post the rest of the sample output. My guess is that some other 
thread is running code that, for some reason, is holding whatever lock XPC 
needs. Are you calling AppKit from your background operations? (That’s almost 
certainly a bad idea!)

From this comment it sounds like the answer is yes:

>   //  sometimes do some logging, update user interface - but only 
> every few seconds

DO NOT do anything UI-related from a background thread unless you _really_ know 
what you’re doing, or you can find yourself in exactly this sort of trouble.

—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

Re: NSOperation Efficiency

2012-12-04 Thread Jens Alfke

On Dec 4, 2012, at 10:15 AM, Gerriet M. Denkmann  wrote:

> Is this to be expected? Or does my app has some hidden flaws? If so, where 
> should I start looking?

Instruments. This is exactly what CPU profiling is for. If you can’t get 
Instruments to work for you, that’s a separate issue, and you should ask about 
it on the xcode-users mailing list.

—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

Re: Beachballing 2

2012-12-04 Thread Jens Alfke

On Dec 4, 2012, at 9:54 AM, Gerriet M. Denkmann  wrote:

> My app creates lots of MyOperations (subclass of NSOperation) and puts them 
> into an NSOperationQueue.
> These operations do not do any I/O - they just use the Cpu.

But in your earlier thread you showed a code snippet that included a comment 
implying that the operation code updates the UI. Does it? (Maybe it doesn’t do 
it directly, but does it make a synchronous method call to other code that 
does?)

—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

Re: Operations Beachball

2012-12-04 Thread Charles Srstka
On Dec 4, 2012, at 4:29 AM, Gerriet M. Denkmann  wrote:

> My app creates lots of MyOperations (subclass of NSOperation) and puts them 
> into an NSOperationQueue.
> 
> I would expect that the app thus remains responsive, but sometimes it is not.
> 
> A sure way to beach-ball my app is: start it with a few hundred operations 
> (which will take about 20 seconds to finish). 
> Make some other app active. 
> Try to make my app active again - it's panel stays grey and after a few 
> seconds the cursor will turn into a beach-ball.
> 
> These MyOperations interact with their controller in two ways:
> 
> 1. they do once at start:  [ controller dataStringFor: row ];
> 
> The controller has:
> 
> - (NSString *) dataStringFor: (NSUInteger)row
> {
>   @synchronized(self) 
>   {
>   if ( self.stringArray == nil ) { create it - takes some time, 
> but happens only once};
>   }
>   return self.stringArray[row];
> }
> 
> 
> 2. When MyOperations have finished their work they call: [ controller  done: 
> row  result: someNumber ];
> 
> The controller has:
> 
> - (void) done: (NSUInteger) row  result: (NSUInteger) someNumber
> { 
>@synchronized(self)
>   {
>   [ self.rowsToDo removeIndex: row ]; //  
> NSMutableIndexSet
>   };
> 
>   //  sometimes do some logging, update user interface - but only 
> every few seconds
> }
> 
> So, why the beach-ball? What am I doing wrong? How to debug this? Why does 
> the app-switch make the beach-ball appear?

I don't know that this will make a big difference, but since you're dealing 
with a performance issue, @synchronized is known to be much slower than other 
methods of synchronization. You could try replacing this with dispatch_sync on 
a serial queue, a spin lock, or a mutex and see if it helps at all.

Charles


___

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

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

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

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


Re: NSOperation Efficiency

2012-12-04 Thread Mike Abdullah
If your operations are purely CPU-bound, the whole point of GCD is to manage 
this for you. With the default number of concurrent operations, 
NSOperationQueue does exactly that. Have you tried with that setting?

On 4 Dec 2012, at 18:15, "Gerriet M. Denkmann"  wrote:

> I have an app which uses NSOperations inside an NSOperationQueue. These 
> operations do not do any I/O - just Cpu. No swapping is taking place.
> 
> When I set [ self.operationQueue setMaxConcurrentOperationCount: 1 ] each 
> operation takes on average 200 msec., measured by NSDate.
> 
> With 2 concurrent operations, it takes not 100 msec but 110 - an extra 10%. 
> Ok - some overhead is to be expected.
> 
> With 4 ops it takes 70 instead of 50 - overhead 40% - rather a lot.
> With 8 ops it takes 60 instead of 25 - overhead 140%. or: 40% of the cpu is 
> used by my operations, 60% is used by whom? And for what?
> 
> Is this to be expected? Or does my app has some hidden flaws? If so, where 
> should I start looking?
> 
> 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/cocoadev%40mikeabdullah.net
> 
> This email sent to cocoa...@mikeabdullah.net


___

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: Beachballing 2

2012-12-04 Thread Gerriet M. Denkmann

On 5 Dec 2012, at 01:33, Jens Alfke  wrote:

> 
> On Dec 4, 2012, at 9:54 AM, Gerriet M. Denkmann  wrote:
> 
>> My app creates lots of MyOperations (subclass of NSOperation) and puts them 
>> into an NSOperationQueue.
>> These operations do not do any I/O - they just use the Cpu.
> 
> But in your earlier thread you showed a code snippet that included a comment 
> implying that the operation code updates the UI. Does it? (Maybe it doesn’t 
> do it directly, but does it make a synchronous method call to other code that 
> does?)

When an operation has finished, it sends a message to the app delegate. Every 
20th time, the app delegate then does:  self.aValue = ...some number ...
@property (assign) NSUInteger aValue; // aValue is bound to some NSTextField.

But when I comment this out there is no impact on speed at all.

Kind regards,

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/archive%40mail-archive.com

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

Re: Beachballing 2

2012-12-04 Thread Jens Alfke

On Dec 4, 2012, at 10:58 AM, "Gerriet M. Denkmann"  wrote:

> When an operation has finished, it sends a message to the app delegate. Every 
> 20th time, the app delegate then does:  self.aValue = ...some number ...
> @property (assign) NSUInteger aValue; // aValue is bound to some NSTextField.
> 
> But when I comment this out there is no impact on speed at all.

My guess there’s probably some other indirect call to AppKit like this, where 
it goes through KVO or bindings and you’re not realizing it.

Use the ‘sample’ tool if you can’t get Instruments to work. Look at all the 
threads and see where they’re spending their time, especially the ones 
servicing your dispatch queue. Are they mostly doing work, or blocked on 
something, and if so what?

—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

Re: Beachballing 2

2012-12-04 Thread Chris Hanson
Please don't create lots of different message threads for a single 
issue/discussion.

Sticking to a single thread makes it much easier to follow by keeping all of 
the context together.

Thanks.

  -- Chris
  -- cocoa-dev's other moderator

___

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: NSOperation Efficiency

2012-12-04 Thread Gerriet M. Denkmann

On 5 Dec 2012, at 01:55, Mike Abdullah  wrote:

> If your operations are purely CPU-bound, the whole point of GCD is to manage 
> this for you. With the default number of concurrent operations, 
> NSOperationQueue does exactly that. Have you tried with that setting?

I have, and it makes my app unresponsive (i.e unusable) until all operations 
have finished.
Triggered by making other app, active, then again my app.

> 
> On 4 Dec 2012, at 18:15, "Gerriet M. Denkmann"  wrote:
> 
>> I have an app which uses NSOperations inside an NSOperationQueue. These 
>> operations do not do any I/O - just Cpu. No swapping is taking place.
>> 
>> When I set [ self.operationQueue setMaxConcurrentOperationCount: 1 ] each 
>> operation takes on average 200 msec., measured by NSDate.
>> 
>> With 2 concurrent operations, it takes not 100 msec but 110 - an extra 10%. 
>> Ok - some overhead is to be expected.
>> 
>> With 4 ops it takes 70 instead of 50 - overhead 40% - rather a lot.
>> With 8 ops it takes 60 instead of 25 - overhead 140%. or: 40% of the cpu is 
>> used by my operations, 60% is used by whom? And for what?
>> 
>> Is this to be expected? Or does my app has some hidden flaws? If so, where 
>> should I start looking?
>> 
>> 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/archive%40mail-archive.com

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


Re: NSOperation Efficiency

2012-12-04 Thread Kyle Sluder
On Tue, Dec 4, 2012, at 10:15 AM, Gerriet M. Denkmann wrote:
> I have an app which uses NSOperations inside an NSOperationQueue. These
> operations do not do any I/O - just Cpu. No swapping is taking place.
> 
> When I set [ self.operationQueue setMaxConcurrentOperationCount: 1 ] each
> operation takes on average 200 msec., measured by NSDate.
> 
> With 2 concurrent operations, it takes not 100 msec but 110 - an extra
> 10%. Ok - some overhead is to be expected.
> 
> With 4 ops it takes 70 instead of 50 - overhead 40% - rather a lot.
> With 8 ops it takes 60 instead of 25 - overhead 140%. or: 40% of the cpu
> is used by my operations, 60% is used by whom? And for what?
> 
> Is this to be expected? Or does my app has some hidden flaws? If so,
> where should I start looking?

How many operations are you creating? We've found that with more than a
few hundred operations, NSOperationQueue is unusable.

--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: NSOperation Efficiency

2012-12-04 Thread Sean McBride
On Wed, 5 Dec 2012 01:15:11 +0700, Gerriet M. Denkmann said:

>I have an app which uses NSOperations inside an NSOperationQueue. These
>operations do not do any I/O - just Cpu. No swapping is taking place.

Do your operations use a lot of memory?  Even though you're not swapping, maybe 
you're blowing a cache and causing a slowdown when many operations are executed 
at once?

Cheers,

-- 

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com 
Mac Software Developer  Montréal, Québec, Canada



___

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: "Dangling reference to an invalid object"

2012-12-04 Thread Mike Abdullah

On 3 Dec 2012, at 18:13, Nick Zitzmann  wrote:

> 
> On Dec 1, 2012, at 10:33 AM, Mike Abdullah  wrote:
> 
>> I've been trying to hunt down a problem where Core Data will occasionally 
>> refuse to save with the error "
>> Dangling reference to an invalid object". I wrote up the details here: 
>> http://www.mikeabdullah.net/dangling-ref-to-an-invalid-object.html
>> 
>> Can anyone shed some light on how this might happen?
> 
> This exception happens if you:
> 
> 1. Create a new object
> 2. Create a relationship between the new object and an existing object
> 3. Turn the new object into a fault before it is officially inserted
> 4. Save changes
> 
> So if you're getting this exception, you need to be more careful about using 
> the -refreshObject:mergeChanges: method, because the code is most likely 
> misusing it. One way to fix this is to never refresh an object that has a 
> temporary object ID.

Hmmm, we're never calling -refreshObject:… ourselves. Possibly some bit of the 
frameworks might be, but you'd hope they're not doing anything wrong like that.

Also, I neglected to mention in the blog post, that the TextBoxBody object is 
created as a consequence of creating and inserting a TextBox object. So I still 
suspect that the TextBox is being deleted from the context, but somehow failing 
to take the Body with it.

From my code it seems impossible that inserting the TextBox could somehow fail, 
but still succeed at inserting the corresponding Body. Thanks for giving me an 
extra idea of what to check though!
___

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

Plug-In failure on OS X 10.8.2 after updating to Oracle Java SE7

2012-12-04 Thread Hariharan Muthu
Hi,

 I have developed sample ***COCOA-64 bit*** application using
Webkit Framework with all plug In settings enabled (setJavaEnabled:YES &
setPlugInsEnable:YES). I have tried to load Juniper SSL webvpn url which in
turn uses Java applet plug-In to launch VPN connection in the webview. This
completely works fine in Java SE 6 (the previous version of Java) in 10.8.2
.

But the Juniper Java applet has been failed to load after updating
OS X 10.8.2 to latest Java SE 7 from Oracle (version* 1.7.0_09*). I dont
know the reason why plugin is fails in my sample always. Every thing works
fine with Safari.


Thanks in advance.Any help would be appreciated.

 *Note:* Test java applet url (
http://www.java.com/en/download/testjava.jsp) to check the Java version
always shows "*plug-in Failure*"msg in my sample application.


Regards,
Hari
___

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


Objective C blogs?

2012-12-04 Thread tshanno
Hi, 

I'm relatively new to objective C and Cocoa but not to C and not to 
object-orented programming.  I've found with other languages that browsing 
blogs which address different aspects of the language with some occasional code 
can be useful in terms of learning the ins and outs of the language and what's 
available.  I'm particularly interested in mathematical data manipulation and 
modeling and in Scripting and Scripting Bridge but my interests are not limited 
to these.

I've done an Internet search but most of the blogs I've found are out of date 
and/or don't have regular postings.  Anyone have any suggestions for some blogs 
I might check out?

Thanks,
Tom S.
___

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


How to capture a video stream

2012-12-04 Thread gary . gardner
I have been digging for a couple of weeks now and I have progressed to the
point where I have the AVCaptureDevice and the session.

Here's what I need help/guidance/assistance on:

I want to capture the video images from which ever camera device I select
and using those images, real time, take the image and pass the bytes to a
java program.

What I can't seem to figure out is how to get the images real time, like
preview does.  I am trying to emulate how the QuickTime API worked using
AVFoundation to capture the images and pass them to my java program.

The JNI portion I already have figured out.

I have initialized the AVCaptureSession.  I have the list of
AVCaptureDevices.  I can select one of the Capture Devices.  I can start
the AVCaptureSession using [session startRunning];.  I can't figure out
the next portion to get the images from the device.

Can anyone tell me what the next steps are?  Any snippets of code that I
can look at?  I'm sure I'm not the first to try to do this.

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/archive%40mail-archive.com

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


NSImage issue in 10.6

2012-12-04 Thread Amy Gibbs
I have the following code that generates images. It works perfectly in  
10.5 but doesn't in 10.6. in 10.6 the images are laid on in the right  
place,


- (IBAction)generateKitImages:(id)sender;
{
NSObject *kit;
kit = [[kits selectedObjects] objectAtIndex:0];

	NSString* fileName = [[kit valueForKey:@"kitAbbr"]  
stringByAppendingString:@".jpg"];
	NSString* thumbnail = [[kit valueForKey:@"kitAbbr"]  
stringByAppendingString:@"TN.jpg"];
	NSString* kitimagePath = self applicationSupportFolder]  
stringByAppendingPathComponent:@"images"]  
stringByAppendingPathComponent:@"kit"]  
stringByAppendingPathComponent:fileName];	
	NSString* desktopPath = NSHomeDirectory()  
stringByAppendingPathComponent:@"Desktop"]  
stringByAppendingPathComponent:@"Xcart Upload"]  
stringByAppendingPathComponent 
:@"images"]stringByAppendingPathComponent:fileName];



	NSString* kitThumbnailPath = self applicationSupportFolder]  
stringByAppendingPathComponent:@"images"]  
stringByAppendingPathComponent:@"kit"]  
stringByAppendingPathComponent:thumbnail];	
	NSString* desktopThumbnailPath = NSHomeDirectory()  
stringByAppendingPathComponent:@"Desktop"]  
stringByAppendingPathComponent:@"Xcart Upload"]  
stringByAppendingPathComponent 
:@"images"]stringByAppendingPathComponent:thumbnail];



NSLog(@"Desktop path is: %@",desktopPath);

//select all images for kit
	NSArray* kitImages = [kit  
valueForKeyPath:@"kitItems.kitItemProduct.productImage"];


int ki = [kitImages count];
NSLog(@"Number of images: %i",ki);
//NSLog(@"Kit Image Path: %@", kitimagePath);
//create new image 300px square
NSImage *targetImage;
NSSize targetSize = NSMakeSize (600, 600);
targetImage = [[NSImage alloc] initWithSize:targetSize];

//set coordinates to x,y -> 0,0 to start
float x = 0;
float y = 0;

//change view depending on image count
if (ki>9){
//greater than 8 images

//background images to fill space
float xb = 600;
float yb = 600;
//for each image
NSEnumerator *imageLoop = [kitImages objectEnumerator];
NSString *imgPath;

while ((imgPath = [imageLoop nextObject])) {
NSImage *img = [[NSImage 
alloc]initWithContentsOfFile:imgPath];
//apply image to view
[targetImage lockFocus];
			[img drawInRect:NSMakeRect(x,y,xb,yb) fromRect:NSMakeRect(0,0,0,0)  
operation:NSCompositeCopy fraction:1];

xb = 151;
yb = 151;
//set new coordinates
x = x+150;
			//if coordinates are too wide, start new row - if x>300, reset x to  
0 and add 100 to y

if( x > (float)599 ){
x = x-600;
y = y+150;
//NSLog(@"x is greater than 300");
}
}
}
else if (ki>6) {
NSLog(@"7-10 images");
//background images to fill space
float xb = 600;
float yb = 600;
//for each image
NSEnumerator *imageLoop = [kitImages objectEnumerator];
NSString *imgPath;

while ((imgPath = [imageLoop nextObject])) {
NSImage *img = [[NSImage 
alloc]initWithContentsOfFile:imgPath];
//apply image to view
[targetImage lockFocus];
			[img drawInRect:NSMakeRect(x,y,xb,yb) fromRect:NSMakeRect(0,0,0,0)  
operation:NSCompositeCopy fraction:1];

xb = 201;
yb = 151;
//set new coordinates
x = x+200;
			//if coordinates are too wide, start new row - if x>300, reset x to  
0 and add 100 to y

if( x > (float)599 ){
x = x-600;
y = y+150;
//NSLog(@"x is greater than 300");
}
}
}
else {
NSLog(@"up to 6 images");
//background images to fill space
float xb = 600;
float yb = 600;
//for each image
NSEnumerator *imageLoop = [kitImages objectEnumerator];
NSString *imgPath;
while ((imgPath = [imageLoop nextObject])) {
NSImage *img = [[NSImage 
alloc]initWithContentsOfFile:imgPath];
//apply image to view
[targetImage lockFocus];
			[img drawInRect:NSMakeRect(x

Re: Objective C blogs?

2012-12-04 Thread Jens Alfke

On Nov 29, 2012, at 3:09 AM, tshanno  wrote:

> I've done an Internet search but most of the blogs I've found are out of date 
> and/or don't have regular postings.  Anyone have any suggestions for some 
> blogs I might check out?

NSBlog: http://www.mikeash.com/pyblog/
NSHipster: http://nshipster.com
Rentzch’s blog: http://rentzsch.tumblr.com/

—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

Re: Objective C blogs?

2012-12-04 Thread Geoffrey Goutallier
Hello,

I know about 2 that are great and updated regularly :

http://www.mikeash.com/pyblog/

http://nshipster.com

Not oriented towards your interests tho, but very great !

Hope they will please you,

++GG

On Nov 29, 2012, at 12:09, tshanno  wrote:

> Hi, 
> 
> I'm relatively new to objective C and Cocoa but not to C and not to 
> object-orented programming.  I've found with other languages that browsing 
> blogs which address different aspects of the language with some occasional 
> code can be useful in terms of learning the ins and outs of the language and 
> what's available.  I'm particularly interested in mathematical data 
> manipulation and modeling and in Scripting and Scripting Bridge but my 
> interests are not limited to these.
> 
> I've done an Internet search but most of the blogs I've found are out of date 
> and/or don't have regular postings.  Anyone have any suggestions for some 
> blogs I might check out?
> 
> Thanks,
> Tom S.
> ___
> 
> 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/coding%40farfadet.net
> 
> This email sent to cod...@farfadet.net


___

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 capture a video stream

2012-12-04 Thread jonat...@mugginsoft.com


On 3 Dec 2012, at 06:02, gary.gard...@brokensoftware.com wrote:

> I have been digging for a couple of weeks now and I have progressed to the
> point where I have the AVCaptureDevice and the session.
> 
> Here's what I need help/guidance/assistance on:
> 
> I want to capture the video images from which ever camera device I select
> and using those images, real time, take the image and pass the bytes to a
> java program.
> 
> What I can't seem to figure out is how to get the images real time, like
> preview does.  I am trying to emulate how the QuickTime API worked using
> AVFoundation to capture the images and pass them to my java program.
It is relatively easy to move from QTKit to AVFoundation.

> 
> The JNI portion I already have figured out.
> 
> I have initialized the AVCaptureSession.  I have the list of
> AVCaptureDevices.  I can select one of the Capture Devices.  I can start
> the AVCaptureSession using [session startRunning];.  I can't figure out
> the next portion to get the images from the device.
> 
> Can anyone tell me what the next steps are?  Any snippets of code that I
> can look at?  I'm sure I'm not the first to try to do this.

Look at the Apple supplied AVRecorder sample.
You need to define inputs and outputs for the session.
Then you need to configure the assigned AVCaptureOutput subclass delegate in 
order receive delegate callbacks such as those defined by 
AVCaptureFileOutputRecordingDelegate

 movieFileOutput = [[AVCaptureMovieFileOutput alloc] init];
[movieFileOutput setDelegate:self];
[session addOutput:movieFileOutput];

You might want to check out the AVCaptureVideoDataOutput AVCaptureOutput 
subclass and AVCaptureVideoDataOutputSampleBufferDelegate.

Jonathan
___

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 capture a video stream

2012-12-04 Thread Quincey Morris
On Dec 2, 2012, at 22:02 , gary.gard...@brokensoftware.com wrote:

> Can anyone tell me what the next steps are?  Any snippets of code that I
> can look at?  I'm sure I'm not the first to try to do this.

Have you looked here?


https://developer.apple.com/library/mac/#documentation/AudioVideo/Conceptual/AVFoundationPG/Articles/04_MediaCapture.html

It seems pretty explicit about how to get video frames, and there are code 
fragments you can use.


___

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 capture a video stream

2012-12-04 Thread gary . gardner
>
>
> On 3 Dec 2012, at 06:02, gary.gard...@brokensoftware.com wrote:
>
>> I have been digging for a couple of weeks now and I have progressed to
>> the
>> point where I have the AVCaptureDevice and the session.
>>
>> Here's what I need help/guidance/assistance on:
>>
>> I want to capture the video images from which ever camera device I
>> select
>> and using those images, real time, take the image and pass the bytes to
>> a
>> java program.
>>
>> What I can't seem to figure out is how to get the images real time, like
>> preview does.  I am trying to emulate how the QuickTime API worked using
>> AVFoundation to capture the images and pass them to my java program.
> It is relatively easy to move from QTKit to AVFoundation.
>
>>
>> The JNI portion I already have figured out.
>>
>> I have initialized the AVCaptureSession.  I have the list of
>> AVCaptureDevices.  I can select one of the Capture Devices.  I can start
>> the AVCaptureSession using [session startRunning];.  I can't figure out
>> the next portion to get the images from the device.
>>
>> Can anyone tell me what the next steps are?  Any snippets of code that I
>> can look at?  I'm sure I'm not the first to try to do this.
>
> Look at the Apple supplied AVRecorder sample.
> You need to define inputs and outputs for the session.
> Then you need to configure the assigned AVCaptureOutput subclass delegate
> in order receive delegate callbacks such as those defined by
> AVCaptureFileOutputRecordingDelegate
>
>  movieFileOutput = [[AVCaptureMovieFileOutput alloc] init];
> [movieFileOutput setDelegate:self];
> [session addOutput:movieFileOutput];
>
> You might want to check out the AVCaptureVideoDataOutput AVCaptureOutput
> subclass and AVCaptureVideoDataOutputSampleBufferDelegate.
>
> Jonathan
> ___
>
> 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/gary.gardner%40brokensoftware.com
>
> This email sent to gary.gard...@brokensoftware.com
>
Jonathan,

I was looking through a few things and had stumbled across something to
that effect.  Apparently, WWDC 2010 had a AVCam Sample which does it as
well.  I was looking through the AVRecorder sample .  I will look again.

I was initially missing the AVCaptureVideoDataOutput.  I don't want to
output to a Movie File.  I just want to capture the video stream. So
AVRecorder is close, but not quite.

If anyone has the AVCam sample or can find it on the Apple Dev site and
point me to the link, that would be great.

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: How to capture a video stream

2012-12-04 Thread gary . gardner
> On Dec 2, 2012, at 22:02 , gary.gard...@brokensoftware.com wrote:
>
>> Can anyone tell me what the next steps are?  Any snippets of code that I
>> can look at?  I'm sure I'm not the first to try to do this.
>
> Have you looked here?
>
>   
> https://developer.apple.com/library/mac/#documentation/AudioVideo/Conceptual/AVFoundationPG/Articles/04_MediaCapture.html
>
> It seems pretty explicit about how to get video frames, and there are code
> fragments you can use.
>
>
>

Quincey,

That's what I have been reading for the past few days and I'm waiting on
the light to dawn.  I think I am missing some small bit as I am getting an
error.

I will keep digging. I'm sure I'll figure out this last 5% somehow.

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


Document Types, imported and exported uti's

2012-12-04 Thread Koko
The iOS programming guide says to use the items in the subject line to tell iOS 
the docs your app can open. I haven done this and installed my app in an iPad.  
I have DropBox on the iPad and expected to have DropBox recognize my app for 
opening a file in the box of my type. But it does not recognize my app.

I must have something confused. 

Please point me in the right direction.

BTW, I do implement application:handleOpenURL

-kokon
___

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: NSOperation Efficiency

2012-12-04 Thread Mike Abdullah

On 4 Dec 2012, at 19:01, "Gerriet M. Denkmann"  wrote:

> 
> On 5 Dec 2012, at 01:55, Mike Abdullah  wrote:
> 
>> If your operations are purely CPU-bound, the whole point of GCD is to manage 
>> this for you. With the default number of concurrent operations, 
>> NSOperationQueue does exactly that. Have you tried with that setting?
> 
> I have, and it makes my app unresponsive (i.e unusable) until all operations 
> have finished.
> Triggered by making other app, active, then again my app.

That suggests your operations aren't purely CPU-bound then. They're getting 
stuck waiting on something else. When that happens, GCD sees it as wasted CPU 
time so starts off the next bit of work anyway.


___

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 capture a video stream

2012-12-04 Thread Quincey Morris
On Dec 4, 2012, at 16:50 , gary.gard...@brokensoftware.com wrote:

> The setSampleBufferDelegate:self queue:queue gives a warning in XCode that
> says Sending '' to parameter of incompatible type
> 'id''

You need to declare the class of 'self' as conforming to the 
AVCaptureVideoDataOutputSampleBufferDelegate protocol. So, for example, if 
'self' is your app delegate, of class MyAppDelegate, then in the header file 
instead of this:

@interface MyAppDelegate : NSObject

you'd put this:

@interface MyAppDelegate : NSObject 



___

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 capture a video stream

2012-12-04 Thread gary . gardner
>> On Dec 2, 2012, at 22:02 , gary.gard...@brokensoftware.com wrote:
>>
>>> Can anyone tell me what the next steps are?  Any snippets of code that
>>> I
>>> can look at?  I'm sure I'm not the first to try to do this.
>>
>> Have you looked here?
>>
>>  
>> https://developer.apple.com/library/mac/#documentation/AudioVideo/Conceptual/AVFoundationPG/Articles/04_MediaCapture.html
>>
>> It seems pretty explicit about how to get video frames, and there are
>> code
>> fragments you can use.
>>
>>
>>
>
> Quincey,
>
> That's what I have been reading for the past few days and I'm waiting on
> the light to dawn.  I think I am missing some small bit as I am getting an
> error.
>
> I will keep digging. I'm sure I'll figure out this last 5% somehow.
>
> Thanks
>

Quincey,

I also found this example -->
https://developer.apple.com/library/ios/#qa/qa1702/_index.html

Of course there are some issues with it as it's from IOS, but I assume
this is the pattern that is supposed to be used.  Using this pattern, I
get a little further.  Below is a snippet of my code.  Ignore that fact
that I have a few things out of order:


- (void)setSelectedVideoDevice:(AVCaptureDevice *)selectedVideoDevice
{
[[self session] beginConfiguration];

if ([self videoDeviceInput]) {
// Remove the old device input from the session
[session removeInput:[self videoDeviceInput]];
[self setVideoDeviceInput:nil];
}

if (selectedVideoDevice) {
NSError *error = nil;

// Create a device input for the device and add it to the 
session
AVCaptureDeviceInput *newVideoDeviceInput = 
[AVCaptureDeviceInput
deviceInputWithDevice:selectedVideoDevice error:&error];
if (newVideoDeviceInput == nil) {
dispatch_async(dispatch_get_main_queue(), ^(void) {
[self presentError:error];
});
} else {
if (![selectedVideoDevice 
supportsAVCaptureSessionPreset:[session
sessionPreset]])
[[self session] 
setSessionPreset:AVCaptureSessionPresetHigh];

[[self session] addInput:newVideoDeviceInput];
[self setVideoDeviceInput:newVideoDeviceInput];


AVCaptureVideoDataOutput *output = [[AVCaptureVideoDataOutput
alloc] init];
[session addOutput:output];

// Configure your output.
dispatch_queue_t queue = dispatch_queue_create("myQueue", NULL);
[output setSampleBufferDelegate:self queue:queue];
dispatch_release(queue);

}

}

[[self session] commitConfiguration];
}

The setSampleBufferDelegate:self queue:queue gives a warning in XCode that
says Sending '' to parameter of incompatible type
'id''

I am not sure how to fix this.  Any thoughts would be helpful.  And yes I
am a newbie when it comes to Objective-C and Mac development.  So not
everything is totally clear to me on using this framework.
___

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: NSOperation Efficiency

2012-12-04 Thread Gerriet M. Denkmann

On 5 Dec 2012, at 02:58, Kyle Sluder  wrote:

> On Tue, Dec 4, 2012, at 10:15 AM, Gerriet M. Denkmann wrote:
>> I have an app which uses NSOperations inside an NSOperationQueue. These
>> operations do not do any I/O - just Cpu. No swapping is taking place.
>> 
>> When I set [ self.operationQueue setMaxConcurrentOperationCount: 1 ] each
>> operation takes on average 200 msec., measured by NSDate.
>> 
>> With 2 concurrent operations, it takes not 100 msec but 110 - an extra
>> 10%. Ok - some overhead is to be expected.
>> 
>> With 4 ops it takes 70 instead of 50 - overhead 40% - rather a lot.
>> With 8 ops it takes 60 instead of 25 - overhead 140%. or: 40% of the cpu
>> is used by my operations, 60% is used by whom? And for what?
>> 
>> Is this to be expected? Or does my app has some hidden flaws? If so,
>> where should I start looking?
> 
> How many operations are you creating? We've found that with more than a
> few hundred operations, NSOperationQueue is unusable.

In this test I was using 444 operations. Otherwise there might be many 
thousands.
Just tried again with 44 operations, but did not see any change in average 
execution time.

Kind regards,

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/archive%40mail-archive.com

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


Re: NSOperation Efficiency

2012-12-04 Thread Kyle Sluder
On Tue, Dec 4, 2012, at 05:02 PM, Gerriet M. Denkmann wrote:
> 
> On 5 Dec 2012, at 02:58, Kyle Sluder  wrote:
> 
> > On Tue, Dec 4, 2012, at 10:15 AM, Gerriet M. Denkmann wrote:
> >> I have an app which uses NSOperations inside an NSOperationQueue. These
> >> operations do not do any I/O - just Cpu. No swapping is taking place.
> >> 
> >> When I set [ self.operationQueue setMaxConcurrentOperationCount: 1 ] each
> >> operation takes on average 200 msec., measured by NSDate.
> >> 
> >> With 2 concurrent operations, it takes not 100 msec but 110 - an extra
> >> 10%. Ok - some overhead is to be expected.
> >> 
> >> With 4 ops it takes 70 instead of 50 - overhead 40% - rather a lot.
> >> With 8 ops it takes 60 instead of 25 - overhead 140%. or: 40% of the cpu
> >> is used by my operations, 60% is used by whom? And for what?
> >> 
> >> Is this to be expected? Or does my app has some hidden flaws? If so,
> >> where should I start looking?
> > 
> > How many operations are you creating? We've found that with more than a
> > few hundred operations, NSOperationQueue is unusable.
> 
> In this test I was using 444 operations. Otherwise there might be many
> thousands.
> Just tried again with 44 operations, but did not see any change in
> average execution time.

Yeah, it sounds like you're saturating the thread pool due to
non-CPU-bound operations. NSOpQ is going to spend its entire time
spawning and switching to threads while you append more and more
operations to the queue.

--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: NSOperation Efficiency

2012-12-04 Thread Jens Alfke

On Dec 4, 2012, at 7:33 PM, Kyle Sluder  wrote:

> Yeah, it sounds like you're saturating the thread pool due to
> non-CPU-bound operations. NSOpQ is going to spend its entire time
> spawning and switching to threads while you append more and more
> operations to the queue.

Apologies, but I have trouble believing that. Isn’t NSOperationQueue just a 
thin veneer around GCD? A few thousand tasks shouldn’t cause a performance 
problem. What’s your evidence that it does?

—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

Re: NSOperation Efficiency

2012-12-04 Thread Kyle Sluder


On Dec 4, 2012, at 8:00 PM, Jens Alfke <[1]j...@mooseyard.com> wrote:


On Dec 4, 2012, at 7:33 PM, Kyle Sluder <[2]k...@ksluder.com> wrote:

  Yeah, it sounds like you're saturating the thread pool due to
  non-CPU-bound operations. NSOpQ is going to spend its entire time
  spawning and switching to threads while you append more and more
  operations to the queue.


Apologies, but I have trouble believing that. Isn’t NSOperationQueue
just a thin veneer around GCD? A few thousand tasks shouldn’t cause a
performance problem. What’s your evidence that it does?


NSOperationQueue uses KVO for dependency tracking and queue width
management. In 10.7, the implementation was apparently changed to thunk
all KVO ops onto the main thread; I'm guessing this fixed a bug by
serializing all state changes. It also slowed down enqueueing
operations onto our NSOperationQueue from a background thread by a
factor of ten or more. I have samples to prove it.

Also, if a worker thread gets blocked, GCD is happy to spin up another
one. It has no concept of queue width; NSOpQ builds this atop GCD. If a
worker thread blocks executing a task from a concurrent queue, GCD will
happily spin up another thread, potentially exhausting your thread pool
and leading to deadlock or other resource contention. Doug Russell from
Black Pixel has written a proof-of-concept implementation of queue
widths for GCD that addresses this
issue: [3]https://github.com/rustle/QueueWithWidth

For an example of how GCD will happily exhaust your thread pool if you
feed it an avalanche of non-CPU-bound tasks, check out Mike Ash's
invaluable
blog: [4]http://www.mikeash.com/pyblog/friday-qa-2009-09-25-gcd-practic
um.html

--Kyle Sluder

References

1. mailto:j...@mooseyard.com
2. mailto:k...@ksluder.com
3. https://github.com/rustle/QueueWithWidth
4. http://www.mikeash.com/pyblog/friday-qa-2009-09-25-gcd-practicum.html
___

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 **

2012-12-04 Thread Gerriet M. Denkmann
I have (using Arc) a method which works fine:
NSString *explanation;
[ self doSomeThingAndExplain: &explanation ];

Now I decided that sometimes I don't need this explanation. So I changed it to:

NSString **explanatioP = urgent ? NULL : &explanation; // <-- "no explicit 
ownership...
[ self doSomeThingAndExplain: explanatioP]; //  passing address of 
non-local object...

But now the compiler gets really upset (errors written as comments above).

What Arc-magic is needed to get this to compile?

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/archive%40mail-archive.com

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


Re: Arc and **

2012-12-04 Thread Roland King
NSString *explanation;
[ self doSomeThingAndExplain:( urgent ? NULL : &explanation ) ];

I tried some REALLY ugly casts putting __autoreleasing and __strong here and 
there around the *s in the explainP but got nowhere, so that's the best I can 
come up with apart from writing doSomethingAndDontExplain which calls the other 
one with NULL. 


On 5 Dec, 2012, at 12:56 PM, "Gerriet M. Denkmann"  wrote:

> I have (using Arc) a method which works fine:
> NSString *explanation;
> [ self doSomeThingAndExplain: &explanation ];
> 
> Now I decided that sometimes I don't need this explanation. So I changed it 
> to:
> 
> NSString **explanatioP = urgent ? NULL : &explanation; // <-- "no explicit 
> ownership...
> [ self doSomeThingAndExplain: explanatioP];   //  passing address of 
> non-local object...
> 
> But now the compiler gets really upset (errors written as comments above).
> 
> What Arc-magic is needed to get this to compile?
> 
> 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/rols%40rols.org
> 
> This email sent to r...@rols.org


___

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 **

2012-12-04 Thread Greg Parker
On Dec 4, 2012, at 8:56 PM, Gerriet M. Denkmann  wrote:
> I have (using Arc) a method which works fine:
> NSString *explanation;
> [ self doSomeThingAndExplain: &explanation ];
> 
> Now I decided that sometimes I don't need this explanation. So I changed it 
> to:
> 
> NSString **explanatioP = urgent ? NULL : &explanation; // <-- "no explicit 
> ownership...
> [ self doSomeThingAndExplain: explanatioP];   //  passing address of 
> non-local object...
> 
> But now the compiler gets really upset (errors written as comments above).
> 
> What Arc-magic is needed to get this to compile?

You need to add explicit ownership to your ** declarations. ARC needs to know 
whether explanationP points to to a strong variable or a weak variable or an 
autoreleasing variable.

This is one way:
-(void) doSomethingAndExplain:(__strong NSString **)explanationP;

__strong NSString **explanationP = urgent ? NULL : &explanation;
[self doSomethingAndExplain:explanationP];

This is another way:
-(void) doSomethingAndExplain:(NSString **)explanationP;
// NSString** parameter is implicitly __autoreleasing NSString **

__autoreleasing NSString **explanationP = urgent ? NULL : &explanation;
[self doSomethingAndExplain:explanationP];

The first version may have better performance because it avoids the autorelease 
pool.


-- 
Greg Parker gpar...@apple.com Runtime Wrangler



___

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 **

2012-12-04 Thread Gerriet M. Denkmann

On 5 Dec 2012, at 12:59, Greg Parker  wrote:

> On Dec 4, 2012, at 8:56 PM, Gerriet M. Denkmann  wrote:
>> I have (using Arc) a method which works fine:
>> NSString *explanation;
>> [ self doSomeThingAndExplain: &explanation ];
>> 
>> Now I decided that sometimes I don't need this explanation. So I changed it 
>> to:
>> 
>> NSString **explanatioP = urgent ? NULL : &explanation; // <-- "no explicit 
>> ownership...
>> [ self doSomeThingAndExplain: explanatioP];  //  passing address of 
>> non-local object...
>> 
>> But now the compiler gets really upset (errors written as comments above).
>> 
>> What Arc-magic is needed to get this to compile?
> 
> You need to add explicit ownership to your ** declarations. ARC needs to know 
> whether explanationP points to to a strong variable or a weak variable or an 
> autoreleasing variable.
> 
> This is one way:
>-(void) doSomethingAndExplain:(__strong NSString **)explanationP;
> 
>__strong NSString **explanationP = urgent ? NULL : &explanation;
>[self doSomethingAndExplain:explanationP];
> 
> This is another way:
>-(void) doSomethingAndExplain:(NSString **)explanationP;
>// NSString** parameter is implicitly __autoreleasing NSString **
> 
>__autoreleasing NSString **explanationP = urgent ? NULL : &explanation;
>[self doSomethingAndExplain:explanationP];
> 
> The first version may have better performance because it avoids the 
> autorelease pool.

Another way (I don't know how efficient it is though) is:  
[self doSomethingAndExplain: urgent ? NULL : &explanation ];

Does this use  autorelease pool ?

Kind regards,

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/archive%40mail-archive.com

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


Re: NSOperation Efficiency

2012-12-04 Thread Gerriet M. Denkmann

On 5 Dec 2012, at 11:41, Kyle Sluder  wrote:

>  
> On Dec 4, 2012, at 8:00 PM, Jens Alfke  wrote:
>  
>>  
>> On Dec 4, 2012, at 7:33 PM, Kyle Sluder  wrote:
>>  
>>> Yeah, it sounds like you're saturating the thread pool due to
>>> non-CPU-bound operations. NSOpQ is going to spend its entire time
>>> spawning and switching to threads while you append more and more
>>> operations to the queue.

I made a test project with this Operation:

@implementation GmdOperationBasis
- (void)main
{
if ( [ self isCancelled ] ) return;
double sum = 8;
for( NSUInteger i = 0; i < 1338; i++ )  //  takes about 100 
msec.
{
if ( [ self isCancelled ] ) return;
double j = (double)i;
sum += sqrt(j);
};  
}
@end

And got almost the same overhead (tested three times with 99 operations);
clock time per operationexpected time   overhead factor
//  8 ops   29.9, 30.1, 29.712.52.4
//  7 ops   29.2, 30.0, 29.714.32.1
//  6 ops   28.8, 28.5, 29.016.71.7
//  5 ops   28.6, 28.4, 28.920  
1.4
//  4 ops   29.4, 31.9, 30.825  
1.2
//  3 ops   35.7, 35.4, 35.233  
1.06
//  2 ops   51.7, 51.5, 51.250  
1.03
//  1 ops   100

Looks like NSOperationQueue has some problems, or?

Kind regards,

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/archive%40mail-archive.com

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


Re: Operations Beachball

2012-12-04 Thread Gerriet M. Denkmann

On 5 Dec 2012, at 01:29, Jens Alfke  wrote:

> 
> On Dec 4, 2012, at 3:48 AM, Gerriet M. Denkmann  wrote:
> 
>> My app creates lots of MyOperations (subclass of NSOperation) and puts them 
>> into an NSOperationQueue.
>> I would expect that the app thus remains responsive, but sometimes it is not.


I made a test project with this Operation:

@implementation GmdOperationBasis
- (void)main
{
if ( [ self isCancelled ] ) return;
double sum = 8;
for( NSUInteger i = 0; i < 13383; i++ ) 
{
if ( [ self isCancelled ] ) return;
double j = (double)i;
sum += sqrt(j);
};  
}
@end

When I add less than 8 operations to the queue, all is fine.

When I add 8 or more operations to NSOperationQueue (using 
NSOperationQueueDefaultMaxConcurrentOperationCount concurrent ops) ,
- then switch to some other app, 
- then try to make my app active again, I get a beach-ball.

My app becomes responsive again, when all operations have finished.

processorCount = 8 (as reported by NSProcessInfo).

10.8.2. Xcode 4.5.2.


Kind regards,

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/archive%40mail-archive.com

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