NSImage thread safety

  • I'm trying to sort out a crash in our application. Having turned lots
    of things off, I'm currently suspicious that it's down to two threads
    concurrently querying the same NSImage (specificially, asking for its
    bounds). Can this cause a problem?

    Thanks for any pointers,
    Cheers,
      Benjohn
  • -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    You may try [image  setCachedSeparately:YES].

    Supposedly that fixes some threading issues with the image cache.
    Though I'm not sure how exactly.

    HTH.

    On Jan 31, 2005, at 12:47 PM, Benjohn wrote:

    >
    > I'm trying to sort out a crash in our application. Having turned lots
    > of things off, I'm currently suspicious that it's down to two threads
    > concurrently querying the same NSImage (specificially, asking for its
    > bounds). Can this cause a problem?
    >
    > Thanks for any pointers,
    > Cheers,
    > Benjohn
    >
    Brian Bergstrand <http://www.bergstrand.org/brian/>, AIM: triryche206
    PGP Key: <http://www.bergstrand.org/brian/misc/public_key.txt>
    After all is said and done, a lot more will be said than done. - Unknown
    As of 01:01:16 PM, iTunes is playing "Prophecy" from "Queensrÿche" by
    "Queensrÿche"

    -----BEGIN PGP SIGNATURE-----
    Version: PGP 8.1

    iQA/AwUBQf5zD3nR2Fu2x7aiEQIqOACg9sexvX0bsButPmVpuuxQspRVEdEAnj4C
    fnjNTXyT8070al4FQcNk2wTl
    =RuAR
    -----END PGP SIGNATURE-----
  • On 2005-01-31, at 19.47, Benjohn wrote:

    > I'm trying to sort out a crash in our application. Having turned lots
    > of things off, I'm currently suspicious that it's down to two threads
    > concurrently querying the same NSImage (specificially, asking for its
    > bounds). Can this cause a problem?

    "bounds" is not a property of NSImage...

    Have you read the available documentation for thread safety concerns
    with Cocoa classes? As a rule of thumb I would say that you should
    never assume that anything is thread safe unless it's explicitly stated
    that it is.

    Try to create a test case where you can reproduce the problem. It would
    be useful to have if you'd like to have more input from the list, or if
    you would like to contact Apple about it.

    Can you remove the crashes completely by locking access to the images
    by only one thread at a time? How easy is it to reproduce the problem?

    j o a r
  • On 31 Jan 2005, at 19:18, j o a r wrote:

    >
    > On 2005-01-31, at 19.47, Benjohn wrote:
    >
    >> I'm trying to sort out a crash in our application. Having turned lots
    >> of things off, I'm currently suspicious that it's down to two threads
    >> concurrently querying the same NSImage (specificially, asking for its
    >> bounds). Can this cause a problem?
    >
    > "bounds" is not a property of NSImage...

    Yes, sorry, I'm actually calling "pixelsWide" and "pixelsHigh" on an
    NSBitmapImageRep.

    > Have you read the available documentation for thread safety concerns
    > with Cocoa classes? As a rule of thumb I would say that you should
    > never assume that anything is thread safe unless it's explicitly
    > stated that it is.

    *nods* That seems like a useful rule of thumb. It seems odd to me that
    an non mutating, accessor function (that's already been called many
    times) could cause a problem, but as the implementation is a black box,
    I suppose I can't make any assumptions about it at all.

    > Try to create a test case where you can reproduce the problem. It
    > would be useful to have if you'd like to have more input from the
    > list, or if you would like to contact Apple about it.
    >
    > Can you remove the crashes completely by locking access to the images
    > by only one thread at a time? How easy is it to reproduce the problem?

    I'm about to give locking a go. Currently it is not easy to reproduce
    the problem. It would be easy enough to build a test case for this
    specific possibility however.

    Thanks,
    Benjohn
previous month january 2005 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            
Go to today
MindNode
MindNode offered a free license !