myell0w/MTDURLPreview

Crash occurs on iPhone 5s

Opened this issue · 1 comments

When using MTDURLPreview on an iPhone 5s there is crash that is reproducible. It doesn't occur on a 5 or 4s. In my project, SDWebImage is included in my workspace as well.

CODE SNIPPET

//viewWillAppear snippet

    __weak typeof(self) weakSelf = self;

    [MTDURLPreview loadPreviewWithURL:webURL
                           completion:^(MTDURLPreview *preview, NSError *error){

                             __strong __typeof(weakSelf)strongSelf = weakSelf;

                             [strongSelf.previewView setTapActionWithBlock:^{

                               CPLWebViewViewController *webController = [[CPLWebViewViewController alloc] initWithURL:webURL.absoluteString webTitle:preview.title];

                               [weakSelf.navigationController pushViewController:webController animated:YES];
                             }];

                             CGFloat xCoordinate = CGRectGetMinX(strongSelf.profileImageView.frame);
                             CGFloat yCoordinate = CGRectGetMaxY(strongSelf.contentLabel.frame) + 10.0f;
                             CGFloat width       = CGRectGetWidth(strongSelf.view.frame) - 10.0f;
                             CGFloat height      = 0.0f;

                             /**
                              * The content label is empty so we'll just adjust based
                              * on the image view
                              */

                             if (CGRectGetHeight(strongSelf.contentLabel.frame) == 0) {
                               yCoordinate = CGRectGetMaxY(strongSelf.profileImageView.frame) + 10.0f;
                             }

                             CGRect previewFrame = CGRectMake(xCoordinate,
                                                              yCoordinate,
                                                              width,
                                                              height);
                             strongSelf.previewView.frame = previewFrame;

                             [strongSelf.view addSubview:strongSelf.previewView];

                             [strongSelf.previewView setFromURLPreview:preview];
                           }];
  }

STACK TRACE

Thread : Crashed: com.apple.main-thread
0  libobjc.A.dylib                0x000000019366c0b8 objc_retain + 24
1  Crowdplace                     0x00000001000bb20c -[UIImageView(WebCache) setImageWithURL:placeholderImage:]
2  Crowdplace                     0x00000001000b04a8 -[MTDURLPreviewView setFromURLPreview:] (MTDURLPreviewView.m:145)
3  Crowdplace                     0x00000001000ab358 __46-[CPLPostDetailViewController viewWillAppear:]_block_invoke (CPLPostDetailViewController.m:160)
4  libdispatch.dylib              0x0000000193c2c014 _dispatch_call_block_and_release + 24
5  libdispatch.dylib              0x0000000193c2bfd4 _dispatch_client_callout + 16
6  libdispatch.dylib              0x0000000193c2f1dc _dispatch_main_queue_callback_4CF + 336
7  CoreFoundation                 0x000000018710ac2c __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
8  CoreFoundation                 0x0000000187108f6c __CFRunLoopRun + 1452
9  CoreFoundation                 0x0000000187049c20 CFRunLoopRunSpecific + 452
10 GraphicsServices               0x000000018cd31c0c GSEventRunModal + 168
11 UIKit                          0x000000018a17afdc UIApplicationMain + 1156
12 Crowdplace                     0x0000000100099600 main (main.m:16)
13 libdyld.dylib                  0x0000000193c47aa0 start + 4

Just as FYI commenting out these lines will prevent the crash. Obviously, doesn't address the core problem