Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash in [ARTiledImageView downloadAndRedrawTilesWithURLs:] (ARTiledImageView.m:154) #2

Closed
dblock opened this issue May 5, 2014 · 3 comments

Comments

@dblock
Copy link
Owner

dblock commented May 5, 2014

Somehow this can crash:

- (void)downloadAndRedrawTilesWithURLs:(NSDictionary *)urls
{
    __weak typeof (self) wself = self;

    for (NSString *tileCacheKey in urls.keyEnumerator) {
        NSURL *tileURL = [urls objectForKey:tileCacheKey];
        if ([self.downloadOperations objectForKey:tileCacheKey]) {
            continue;
        }

In Artsy's Eigen app: https://rink.hockeyapp.net/manage/apps/37029/app_versions/16/crash_reasons/12678564 (requires logon)

Thread 9 Crashed:
0   libobjc.A.dylib                      0x39e03622 objc_msgSend + 1
1   CoreFoundation                       0x2f4be199 -[__NSDictionaryM objectForKey:] + 142
2   Artsy                                0x001bec5d -[ARTiledImageView downloadAndRedrawTilesWithURLs:] (ARTiledImageView.m:154)
3   Artsy                                0x001bea51 -[ARTiledImageView drawRect:] (ARTiledImageView.m:130)
4   UIKit                                0x31e1bda5 -[UIView drawLayer:inContext:] + 372
5   QuartzCore                           0x31a492c1 -[CALayer drawInContext:] + 100
6   QuartzCore                           0x31b19cb9 tiled_layer_render(_CAImageProvider*, unsigned int, unsigned int, unsigned int, unsigned int, void*) + 1458
7   QuartzCore                           0x31a76f33 CAImageProviderThread(unsigned int*, bool) + 464
8   libdispatch.dylib                    0x3a2e8ad7 _dispatch_root_queue_drain + 220
9   libdispatch.dylib                    0x3a2e8d29 _dispatch_worker_thread2 + 54
10  libsystem_pthread.dylib              0x3a423bd3 _pthread_wqthread + 298
11  libsystem_pthread.dylib              0x3a423a98 start_wqthread + 8
@dblock dblock changed the title Crash in Crash in [ARTiledImageView downloadAndRedrawTilesWithURLs:] (ARTiledImageView.m:154) May 5, 2014
@dblock
Copy link
Owner Author

dblock commented May 5, 2014

@orta any ideas what this could be?

@orta
Copy link
Collaborator

orta commented May 6, 2014

this is weird,

my initial thoughts were that the ARTiledImageView could be nil'd during this, but the crash seems to be entirely related to local scope, so it's very unlikely. Perhaps this is a case of a secondary thread making changes to the urls dictionary? ( again, I think this won't be the case as urls isn't a instance var )

One potential fix, could be to switch to using - (void)enumerateKeysAndObjectsUsingBlock:(void (^)(id key, id obj, BOOL *stop))block but you really should be safe to use the key when you're iterating

@dblock dblock closed this as completed in cd3cd38 May 20, 2014
@dblock
Copy link
Owner Author

dblock commented May 20, 2014

The only explanation that I can come up with is that the object is being destroyed on one thread, and still being access on another. We do [self.downloadOperations objectForKey:tileCacheKey], as self.downloadOperations is being cleared because dealloc calls cancelConcurrentDownloads, which calls [self.downloadOperations removeAllObjects];, on different threads.

I added a synchronized block, see cd3cd38.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants