• 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: Crashing when updating the User Interface from a detached NSThread
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Crashing when updating the User Interface from a detached NSThread


  • Subject: Re: Crashing when updating the User Interface from a detached NSThread
  • From: Simone Manganelli <email@hidden>
  • Date: Fri, 3 Feb 2006 04:41:46 -0800

I was looking for something like that. However, it doesn't seem to help my problem. I have this code in the method that is performed in a new, detached thread:

if ([previewWindow isVisible]) {
[previewView performSelectorOnMainThread:@selector(setImage:) withObject:gridImage waitUntilDone:YES];
}


If the previewWindow is visible, I can go through at max a few frames of the movie before my app locks up (it doesn't seem to be a genuine crash, though, because no crash report comes up). Sometimes it's only one frame, and sometimes it's a few frames. However, nothing actually ever shows up in the preview window, even if I send a "display" message on the main thread to the previewView. Also, setting the "waitUntilDone" argument to NO has no discernable effect on the behavior of the crash.

If I close the previewWindow, everything proceeds as I expect it to. (Well, it still crashes every once in a while, but that seems unrelated, because it usually happens near the end of the process, not just a few frames in.)

Any ideas?

-- Simone


Il giorno 2006-02-02, alle ore 05:09, Glen Simmons ha scritto:


On Feb 2, 2006, at 3:43 AM, Simone Manganelli wrote:

I'm having a particular problem with using NSThreads. I'm detaching a method that runs in a separate thread, but in the process of this method, it needs to update the user interface a bit. (I'm multithreading the app because this method takes a particularly long time to execute and I want the user interface to be responsive.) Whenever this detached thread tries to update the user interface, it seems to crash a lot.

To give a specific reason why it's necessary to update the user interface inside this method, consider this scenario: I'm trying to create an image from a movie by laying out each of the frames next to each other in an image. But I want the user to know how far the process has progressed, so I want the movie view that I'm using to step forward and display the current frame that it's processing. I also want to update an NSImageView to show the current assembled image in a preview window.

Are there ways to export drawing commands back to the main application thread so that the application doesn't crash? I tried using an NSNotification, but that doesn't seem to work.

UI updates must be done on the main thread. There's a method that makes this easy: performSelectorOnMainThread:withObject:waitUntilDone:.


Glen


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Crashing when updating the User Interface from a detached NSThread
      • From: Glen Simmons <email@hidden>
References: 
 >Crashing when updating the User Interface from a detached NSThread (From: Simone Manganelli <email@hidden>)
 >Re: Crashing when updating the User Interface from a detached NSThread (From: Glen Simmons <email@hidden>)

  • Prev by Date: Property name clashes with a method implemented by NSManagesObject or NSObject
  • Next by Date: Re: Converting error codes to readable strings?
  • Previous by thread: Re: Crashing when updating the User Interface from a detached NSThread
  • Next by thread: Re: Crashing when updating the User Interface from a detached NSThread
  • Index(es):
    • Date
    • Thread