Re: NSDocument's Open File Panel unresponsive when opening large file from disc
Re: NSDocument's Open File Panel unresponsive when opening large file from disc
- Subject: Re: NSDocument's Open File Panel unresponsive when opening large file from disc
- From: Mike Abdullah <email@hidden>
- Date: Mon, 28 Jan 2013 16:13:45 +0000
On 28 Jan 2013, at 15:25, Gilles Celli <email@hidden> wrote:
> Thanks Mike,
>
> I just looked with Instruments and well yes to process the data my app uses NSScanner a lot to extract date/time with its corresponding data values,
> so this takes about 99,6% Running-Time (gasp! )…
>
> One error (I think) was that I processed the data inside the readFromURL:ofType:error: after it was read into the NSString….but:
>
> Now I pass the NSString fileContent from NSDocument makeWindowControllers to a new object WindowController:
> It doesn't change anything however, the corresponding WindowController which processes now the data is also taking a lot of CPU-time…
>
> Should I put the data processing in a dispatch_sync queue in the WindowController or in NSDocument's makeWindowController ?
This is starting to scare me :)
-readFromURL:… gets called on a worker thread by the document system. This should be an appropriate point to do any intensive processing of the incoming data.
But at absolutely no point in this method should you be communicating with window controllers.
1. The window controllers shouldn't even exist at this point; it's up to the doc system whether to create window controllers *after* reading
2. Any communication with window controllers should be done purely on the main thread, which it sounds is at cross purposes with what you're trying to achieve.
Perhaps you can give us a few stack traces that show what's happening?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden