ionic-team / capacitor

Build cross-platform Native Progressive Web Apps for iOS, Android, and the Web ⚡️
https://capacitorjs.com
MIT License
12.19k stars 1.01k forks source link

Getting white screen and and error in iOS #1083

Closed smelzer closed 5 years ago

smelzer commented 5 years ago

I am using the CAPPlugin to create a "Manager" object that manages 2 ViewControllers.

@objc func capture(_call: CAPPluginCall) 
{
        if let manager = AppManager
                    .init(capPluginCall: call, andBridgeController: self.bridge.viewController) {
            manager.capture()
        } else {
            print("Could not instantiate the AppManager")
        }
    }

Everything is working fine in general, unless i toggle between the two ViewControllers within the Manager several times. When I do this and then I cancel out of them using the Manager, I may (or may not) get a white screen and then I may (or may not) go back to the beginning of the app (like Ionic restarted itself).

The only consistent thing is I cannot reproduce the error at all if I never toggle to the second ViewController within the AppManager.

I have written several iOS apps before and do not feel like I am doing anything special in the ViewControllers themselves. The AppManager handles the Ionic side as follows, where 'capture' is the method called from Typescript:

-(id)initWithCAPPluginCall:(CAPPluginCall *)_call
            andBridgeController:(UIViewController *)_bridgeViewController {
    self = [super init];
    if (self) {
        call = _call;
        bridgeViewController = _bridgeViewController;
    }
    return self;
}

-(void)capture {
     dispatch_async(dispatch_get_main_queue(), ^{
        UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
         self-> viewControllerA = [storyboard instantiateViewControllerWithIdentifier:@"viewControllerA"];
         self-> viewControllerA.delegate = self;
         [self->bridgeViewController presentViewController:self-> viewControllerA animated:NO completion:nil];
    });
}

The problem child is in the dismissal call:

-(void)didCancel {
    NSLog(@"in didCancel");
    dispatch_async(dispatch_get_main_queue(), ^{
        [self-> viewControllerA dismissViewControllerAnimated:NO completion:nil];
    });
    NSLog(@"finished didCancel");
}

The log lines show up just fine:

2018-12-28 18:38:34.815547-0500 App[7404:1141810] in didCancelCapture 2018-12-28 18:38:34.815626-0500 App[7404:1141810] finished didCancelCapture

And then either I get one of the two following messages:

⚡️ [log] - Hello RestProvider Provider

and the rest of the Ionic/Angular startup process and end up back at the home page or I get nothing and the white screen just sits there with the following log message after a 10 second or so delay:

2018-12-28 18:42:16.396262-0500 App[7404:1141810] Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service

I have checked in Instruments and didn't see anything that stood out.

I am looking for ideas of where to check for issues.

Thanks, Steve

mlynch commented 5 years ago

Hmm, really can't think of many reasons this would be happening, apart from memory pressure. What does memory usage look like as you do it? I don't think this has anything to do with Capacitor on my first quick glance.

One random idea to try: store a class reference to that manager instance in that first Swift example in case it's just a case of something getting deallocated.

smelzer commented 5 years ago

Thank you. I tried the ivar idea to no avail as well as checked the memory. Nothing unusual in the memory footprint.

I see several issues with Ionic showing a white screen for the SplashScreen native component. I am really curious what causes a white screen in Ionic. It would give me something to look at more closely.

smelzer commented 5 years ago

Any idea what could cause this error. There is not much in Google:

Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service

Thanks.

smelzer commented 5 years ago

NEVERMIND. I wasted a bunch of my time and some of everyone who read this' time, especially mlynch.

I didn't return a valid value back to JS.

mlynch commented 5 years ago

Glad you figured it out! Cheers

bobbydowling commented 4 years ago

I am actually seeing the same error: Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service

It's an Angular 9+ app wrapped in Capacitor. Works fine in Android. In iOS I get the blank white screen.

Memory pressure seems okay:

image

image

Any ideas?

ionitron-bot[bot] commented 2 years ago

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.