Error in closing a modal page on a modal page


#1

CLI: 3.0.2
Cross-platform modules: 3.0.1
Runtime(s):3.0.1
Plugin(s): -

Hello,

I need to show a modal page, as a close up of an article which has pdf attachments. So, in this modal page I can tap on an attachment, and then it opens a new modal page with the content of the attachment.

The problem is that the close event (after calling close()) on the second modal crashes the app.

The error is

1   0x10057d71b NativeScript::FFICallback<NativeScript::ObjCMethodCallback>::ffiClosureCallback(ffi_cif*, void*, void**, void*)
2   0x100c5215e ffi_closure_unix64_inner
3   0x100c52a92 ffi_closure_unix64
4   0x1018586ca __56-[UIPresentationController runTransitionForCurrentState]_block_invoke
5   0x101777adb _applyBlockToCFArrayCopiedToStack
6   0x101777955 _afterCACommitHandler
7   0x103890507 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
8   0x103890460 __CFRunLoopDoObservers
9   0x103886293 __CFRunLoopRun
10  0x103885bc6 CFRunLoopRunSpecific
11  0x104e1ca58 GSEventRunModal
12  0x101754580 UIApplicationMain
13  0x100c528ed ffi_call_unix64
14  0x1134b7e20
file:///app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js:416:100: JS ERROR Error: View already has a parent. View: Page(195) Parent: Frame(1)
Jun 16 15:11:05 Klugi-2 com.apple.CoreSimulator.SimDevice.C91EA47F-51C5-4473-9093-207937C57CA4.launchd_sim[1996] (UIKitApplication:org.nativescript.opapnetmobile[0x2258][10321]): Service exited due to signal: Segmentation fault: 11

The code of the component of the second modal is

import { Component, OnInit, AfterViewInit, ViewContainerRef } from '@angular/core';

import { ModalDialogService, ModalDialogParams } from "nativescript-angular/modal-dialog";
import { Page } from "ui/page";


@Component({
    selector: 'webview-flypage',
    moduleId: module.id,
    templateUrl: "./webviewFlypage.component.html",
    styleUrls: ['../css/global.css']
})
export class WebviewFlypageComponent implements OnInit {

    _url: string;

    constructor(
        private params: ModalDialogParams,
        private page: Page,
        private vcRef: ViewContainerRef, ) {
    }

    ngOnInit() {
         this._url = this.params.context;
    }

    public close() {
        this.params.closeCallback();
    }
}

Thank you in advance,
Harry


Error: Current componentRef is different for cached componentRef
#2

I solved this with a workaround. I send the attachments URL to be opened in the browser by using the openUrl method.

This opens the url in the os browser and handles the file as expected.


#3

Another idea would be to use the excellent nativescript-pdf plugin so you can show the PDF inline in the modal.


#4

Yes, you are right. I tried this plugin and it worked, but an attachment could be any type of file, so I think the best way to handle it is it to give it to the browser.

Perhaps, a better way to handle the attachments is in ios to use utils.openFile and in android to use the download manager plugin and the open it through the is ui.

I will try them in the future.