Page MenuHomePhabricator

[BUG] Sharing from article view does not always respond to taps
Closed, ResolvedPublic

Description

Reported by beta testers and re-created on my 5C (running 9.2). Unfortunately this is not 100% re-create-able, but here was my personal experience:

  • Open the app
  • click on the Random Article card on Explore
  • Load the Claro River (Pardo River) article
  • Tap the share icon
  • Nothing happens :(
  • Go back to explore
  • Click the Featured Article
  • Tap the share icon
  • Works as expected :)

Event Timeline

JMinor raised the priority of this task from to Needs Triage.
JMinor updated the task description. (Show Details)
JMinor subscribed.
JMinor set Security to None.

@BGerstle-WMF I found the issue - but am unable to fix (Xcode keeps crashing during debuting swift code) But maybe you can see what is wrong by visually interrogating the code.

The article I tested on was: "Macarostola pyrelictis"

The catch block below is never invoked when self.article.imageURL == nil. The issue seems to be in PromiseKit as it looks like we are passing the error wrapped Promise correctly.

- (void)fetchImageThenShowShareCard {
    @weakify(self);
    [[WMFImageController sharedInstance] fetchImageWithURL:[NSURL wmf_optionalURLWithString:self.article.imageURL]].then(^(WMFImageDownload* download){
        @strongify(self);
        [self showShareOptionsWithImage:download.image];
    }).catch(^(NSError* error){
        @strongify(self);
        [self showShareOptionsWithImage:nil];
    });
}

The offending method is:

WMFImageController.checkForValidURL()

@Fjalapeno so, this is expected behavior: if the url is nil, then nothing happens because the promise is cancelled. just need to add special handling

@BGerstle-WMF - hmmm. Can you tell me why that is expected? Following the code path it seems to send an error.

Shouldn't vending "WMFImageControllerErrorCode.InvalidOrEmptyURL.error" cause the catch block to fire? Can you explain why that error results in the promise being cancelled instead?

private func checkForValidURL(url: NSURL?, @noescape then: (NSURL) -> Promise<WMFImageDownload>) -> Promise<WMFImageDownload> {
    return url.map(then) ?? Promise(error: WMFImageControllerErrorCode.InvalidOrEmptyURL.error)
}

@Fjalapeno because that specific error is considered a cancellation by PromiseKit, as are some others declared in the WMFImageControllerErrorCode enum. this makes fetch attempts for empty/invalid URLs a no-op w/o any special handling (which is the desired behavior in most cases).

JMinor raised the priority of this task from High to Needs Triage.Feb 5 2016, 11:35 PM

Tested Claro River and a handful of other articles. Share button worked on all I tried.

Tested on iPhone 5C with iOS 9.2.1 app v5.0.0 665.