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

Catalog app - pdf preview crashes in iPhone 5s emulator #2

Open
lc3t35 opened this issue Jul 18, 2017 · 1 comment
Open

Catalog app - pdf preview crashes in iPhone 5s emulator #2

lc3t35 opened this issue Jul 18, 2017 · 1 comment
Assignees
Labels

Comments

@lc3t35
Copy link

lc3t35 commented Jul 18, 2017

When I click on the "Preview Sample PDF" button, the app crashes with this message :
2017-07-18 18:53:51.432 Cobalt Catalog[8793:1621201] This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes.

- (void) onMessageWithCobaltController: (CobaltViewController *)viewController
                               andData: (NSDictionary *)data {
    NSString * callback = [data objectForKey:kJSCallback];
    NSString * action = [data objectForKey:kJSAction];
    if (action != nil && [action isEqualToString:@"pdf"]) {
        if (DEBUG_COBALT) NSLog(@"PdfPlugin received data %@", data.description);

        // prepare data
        _viewController = viewController;
        // add defined tokens
        _tokens = @[kAPITokenSource,
                    kAPITokenPath,
                    kAPITokenLocal,
                    kAPITokenRemote,
                    kAPITokenTitle,
                    kAPITokenDetail];

        // parse dictionary
        _filedata = [[NSDictionary alloc] initWithDictionary:[self parseDictionary:data]];
        if (_filedata == NULL || _filedata.count == 0) {
            NSLog(@"Error while parsing file datas, check your javascript.");
            return;
        }
        if (DEBUG_COBALT) NSLog(@"PdfPlugin input parsing done: %@", _filedata.description);

        // open Remote Pdf
        NSString *source = [_filedata objectForKey:kAPITokenSource];
        if ([source isEqualToString:kAPITokenRemote]) {
            // get url
            NSURL *url = [NSURL URLWithString:[_filedata objectForKey:kAPITokenPath]];
            // check iOS version
            if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"9.0")) {
                SFSafariViewController *svc = [[SFSafariViewController alloc] initWithURL:url];
                svc.delegate = self;
HERE =======> [viewController presentViewController:svc animated:YES completion:nil];   
            } else if (SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(@"8.9")) { // version 0 to 8.9
                [[UIApplication sharedApplication] openURL:url];
            }
        } else if ([source isEqualToString:kAPITokenLocal]) { // open Local Pdf
            if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"3.2")) {
                [self previewDocument:[_filedata objectForKey:kAPITokenPath]];
            }
            // can't open pdf
        }
        // send callback
        [viewController sendCallback: callback
                            withData: nil];
    }
}
@Doc1faux
Copy link
Contributor

Hi @lc3t35,

That's a known issue on our side that we have not took the time yet to investigate because it's not a Cobalt core feature (i.e. a plugin).

But we will plan to fix it!

@Doc1faux Doc1faux self-assigned this Jul 18, 2017
@Doc1faux Doc1faux added the bug label Jul 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants