• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSDocument's Open File Panel unresponsive when opening large file from disc
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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: Gilles Celli <email@hidden>
  • Date: Mon, 28 Jan 2013 17:46:54 +0100

Please don't be scared ;-)
Well I'm little bit in a hurry … will look more closely tonight, but:

What I've done til now is inside readFromURL:ofType:error:
1. Open the file and store it NSString currentFileContents
2. Process currentFileContents  in a new object myDataFile (withc class DataFileParser) by extracting the data values etc. with NSScanner, this takes most time
3. return YES if everything is OK in readFromURL

So I thought that then makeWindowControllers comes in action ?!...
In makeWindowControllers:
1. Pass myDataFile if it's not nil > create a new MainWindowController and pass myDataFile to it like
mainWindowController = [[DataViewerWindowController alloc] initWithDataFile:myDataFile];
  [self addWindowController:mainWindowController];

Hope this clarifies a little bit what I'm doing…well doing something wrong …..






On 28 Jan 2013, at 17:13, Mike Abdullah wrote:

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


  • Follow-Ups:
    • Re: NSDocument's Open File Panel unresponsive when opening large file from disc
      • From: Mike Abdullah <email@hidden>
References: 
 >NSDocument's Open File Panel unresponsive when opening large file from disc (From: Gilles Celli <email@hidden>)
 >Re: NSDocument's Open File Panel unresponsive when opening large file from disc (From: Mike Abdullah <email@hidden>)
 >Re: NSDocument's Open File Panel unresponsive when opening large file from disc (From: Gilles Celli <email@hidden>)
 >Re: NSDocument's Open File Panel unresponsive when opening large file from disc (From: Mike Abdullah <email@hidden>)

  • Prev by Date: Re: NSDocument's Open File Panel unresponsive when opening large file from disc
  • Next by Date: Re: NSDocument's Open File Panel unresponsive when opening large file from disc
  • Previous by thread: Re: NSDocument's Open File Panel unresponsive when opening large file from disc
  • Next by thread: Re: NSDocument's Open File Panel unresponsive when opening large file from disc
  • Index(es):
    • Date
    • Thread