ionic-framework: Popover Dismiss Causes “RangeError: Maximum call stack size exceeded” on Android Device

I am using ionic2 beta8.

I have copied exact usage example from http://ionicframework.com/docs/v2/2.0.0-beta.8/api/components/popover/Popover/#usage

The only thing I changed is I have created separate files for popover.ts popover.html.

After all those changes everything worked fine in browser. But when I test that in Android device, when I try to dismiss the popover (either by calling this.viewController.dismiss() method or clicking on backdrop) I see that UI hung up and nothing happens.

I checked logs in Android Monitoring tool then I found following exception in log.



[INFO:CONSOLE(34947)] "EXCEPTION: Error in ./PopoverCmp class PopoverCmp - inline template:0:14", source: file:///android_asset/www/build/js/app.bundle.js (34947)
[INFO:CONSOLE(34947)] "ORIGINAL EXCEPTION: RangeError: Maximum call stack size exceeded", source: file:///android_asset/www/build/js/app.bundle.js (34947)
[INFO:CONSOLE(34947)] "ORIGINAL STACKTRACE:", source: file:///android_asset/www/build/js/app.bundle.js (34947)
[INFO:CONSOLE(34947)] "RangeError: Maximum call stack size exceeded
    at Object.re.RequireObjectCoercible (file:///android_asset/www/build/js/es6-shim.min.js)
    at Object.re.ToObject (file:///android_asset/www/build/js/es6-shim.min.js:10:4947)
    at Function.keys (file:///android_asset/www/build/js/es6-shim.min.js:10:24378)
    at _baseExtend (file:///android_asset/www/build/js/app.bundle.js:69658:27)
    at _baseExtend (file:///android_asset/www/build/js/app.bundle.js:69665:17)
    at _baseExtend (file:///android_asset/www/build/js/app.bundle.js:69665:17)
    at _baseExtend (file:///android_asset/www/build/js/app.bundle.js:69665:17)
    at _baseExtend (file:///android_asset/www/build/js/app.bundle.js:69665:17)
    at _baseExtend (file:///android_asset/www/build/js/app.bundle.js:69665:17)
    at _baseExtend (file:///android_asset/www/build/js/app.bundle.js:69665:17)", source: file:///android_asset/www/build/js/app.bundle.js (34947)
[INFO:CONSOLE(34947)] "ERROR CONTEXT:", source: file:///android_asset/www/build/js/app.bundle.js (34947)
[INFO:CONSOLE(34947)] "[object Object]", source: file:///android_asset/www/build/js/app.bundle.js (34947)
[INFO:CONSOLE(260)] "Uncaught EXCEPTION: Error in ./PopoverCmp class PopoverCmp - inline template:0:14
ORIGINAL EXCEPTION: RangeError: Maximum call stack size exceeded
ORIGINAL STACKTRACE:
RangeError: Maximum call stack size exceeded
    at Object.re.RequireObjectCoercible (file:///android_asset/www/build/js/es6-shim.min.js)
    at Object.re.ToObject (file:///android_asset/www/build/js/es6-shim.min.js:10:4947)
    at Function.keys (file:///android_asset/www/build/js/es6-shim.min.js:10:24378)
    at _baseExtend (file:///android_asset/www/build/js/app.bundle.js:69658:27)
    at _baseExtend (file:///android_asset/www/build/js/app.bundle.js:69665:17)
    at _baseExtend (file:///android_asset/www/build/js/app.bundle.js:69665:17)
    at _baseExtend (file:///android_asset/www/build/js/app.bundle.js:69665:17)
    at _baseExtend (file:///android_asset/www/build/js/app.bundle.js:69665:17)
    at _baseExtend (file:///android_asset/www/build/js/app.bundle.js:69665:17)
    at _baseExtend (file:///android_asset/www/build/js/app.bundle.js:69665:17)
ERROR CONTEXT:
[object Object]", source: file:///android_asset/www/build/js/zone.js (260)
Debugger is no longer active


Here is code I am using

import { Component } from '@angular/core';
import { App, NavController, NavParams, MenuController, Popover, ViewController } from "ionic-angular";
import { Storage, LocalStorage } from 'ionic-angular';

import { AuthService } from "./../../../services/user/auth";
import { AuthModel } from "./../../../models/user/auth";


@Component({
    template: `
        <ion-list>
            <ion-list-header>Welcome</ion-list-header>
            <button ion-item (click)="onLogout($event)">Logout</button>
        </ion-list>
    `,
    providers: []
})
class PopoverPage {
    private storage;

    constructor(private viewController: ViewController, private nav: NavController, private authService: AuthService, private auth: AuthModel) {
        this.storage = new Storage(LocalStorage);
    }

    close() {
        console.log('On Close Popover');
        this.viewController.dismiss();
    }

    onLogout() {
        this.close();
    }
}

@Component({
    templateUrl: "build/pages/app/dashboard/dashboard.html",
    providers: []
})
export class DashboardNewPage {
    private storage;

    constructor(protected app: App, protected nav: NavController, protected navParams: NavParams, private menu: MenuController, private authService: AuthService, private auth: AuthModel) {
        this.storage = new Storage(LocalStorage);
    }

    public onPopover(event) {
        let popover = Popover.create(PopoverPage);
        this.nav.present(popover, {
            ev: event
        });
    }
}

onPopover function is getting called when nav button is triggered and that markup is present in dashboard.html

This page is rootPage of app and it gets loaded immediately.

Last thing I see in logcat is ‘console.log(‘On Close Popover’);’ execution. After that it shows exception.

Let me know if I did something wrong here. Please note that this works perfectly fine in browser. But fails in android device.


I guess that the possible cause might be that:

The object that is passed to ToObject() method is too big - this will work on a desktop browser because it has bigger stack so it could handle it but obviously fails on mobile.

It might be an issue with the es6-shim ToObject() method (either a bug or it’s not very effective or not optimized) - most desktop browsers should have a native implementation of this method and therefore it works fine but obviously on mobile there’s no native implementation yet.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 4
  • Comments: 32 (6 by maintainers)

Most upvoted comments

Hi @pjsb and @thgfrzm, I think it would be better to set this css adjustments:

.popover-content{ top: 44px !important; margin-left: auto !important; right: 10px !important; transform-origin: right top 0px !important; }

+1 using:

  • Moto G (2013) XT1032, Android 4.4.4.

No problems in:

  • browser,
  • Sony Xperia Z1 Compact - Android 5.x.x or
  • Sony Xperia Z3 Compact - Android 6.x.x.

workaround:

showFilterPopover(event){
    let popover = this.popoverController.create(SearchFilterPopover);
    popover.present({ ev: null }); // <- pass 'null' to event and adjust the CSS
}

hi Jens @pjsb, actually I’m just overwriting the popover-style class. This solution needs some adjustments. Put at the same page.scss that call the popover

.popover-style{
  .popover-content{
    top: 10px !important;
    left: 23% !important;
    transform-origin: right top 0px !important;
  }
}

Hello @Geoffrey-D same issue on Elephone P7000 android version 5.0, but works fine on Samsung S6, Nexus 6, Nexus 5.

I’m just referencing the related forum discussion for more details: https://forum.ionicframework.com/t/54511

Using crosswalk solved the issue for me. For my part, I will use crosswalk in production as I have other issues that crosswalk fixed (the material design animations was also not working without crosswalk). For those that also want to use crosswalk and do https calls, be aware that it will not accept self-signed certificat.

I am also getting the exact same issue. Ionic Team, please do not close this issue as this is very important one. I have tried all sort of fix, but still couldn’t found a way to fix it. (It works perfectly fine in Google Chrome & on a Lumia 550 Windows 10 device with 1 GB RAM).

You can also replicate this issue on a Genymotion Android Emulator:

Genymotion Android Image: Google Nexus 10 - 5.1.0 - API 22, 2560x1600, 320 DPI, Ionic CLI Version: v2.0.0-beta.32

Sample Code: Template:

  <ion-navbar>
      <ion-buttons end="">
        <button class="disable-hover bar-button bar-button-default bar-button-icon-only">
          <span class="button-inner">
            <ion-icon name="search" role="img" class="ion-ios-search" aria-label="search" ng-reflect-name="search"></ion-icon>
          </span>
          <ion-button-effect></ion-button-effect>
        </button>

        <button class="disable-hover bar-button bar-button-default bar-button-icon-only" (click)="more($event)">
          <span class="button-inner">
            <ion-icon name="more" role="img" class="ion-ios-more" aria-label="more" ng-reflect-name="more"></ion-icon>
          </span>
          <ion-button-effect></ion-button-effect>
        </button>
      </ion-buttons>
      <div class="toolbar-content">
        <ion-title>Popular Stations</ion-title>
      </div>
  </ion-navbar>
</ion-header>

Popover Page:

import {Component} from '@angular/core';
import {NavController, ViewController} from 'ionic-angular';

@Component({
  template: '
    <ion-list>
      <ion-list-header>Ionic</ion-list-header>
      <button ion-item (click)="close()">Learn Ionic</button>
      <button ion-item (click)="close()">Documentation</button>
      <button ion-item (click)="close()">Showcase</button>
      <button ion-item (click)="close()">GitHub Repo</button>
    </ion-list>'
})

export class MoreOptionsPage {
  constructor(private viewCtrl: ViewController) {}

  close() {
    this.viewCtrl.dismiss();
  }
}

Displaying the Popover:

more(e){
    let popover = Popover.create(MoreOptionsPage);    
    this.nav.present(popover, {ev: e});
  }

Android Log:

I/chromium( 2112): ORIGINAL STACKTRACE:

I/chromium( 2112): RangeError: Maximum call stack size exceeded

I/chromium( 2112):     at Object (native)

I/chromium( 2112):     at Object.re.ToObject (file:///android_asset/www/build/js/es6-shim.min.js:10:4947)

I/chromium( 2112):     at Function.keys (file:///android_asset/www/build/js/es6-shim.min.js:10:24378)

I/chromium( 2112):     at _baseExtend (file:///android_asset/www/build/js/app.bundle.js:76634:27)

I/chromium( 2112):     at _baseExtend (file:///android_asset/www/build/js/app.bundle.js:76641:17)

I/chromium( 2112):     at _baseExtend (file:///android_asset/www/build/js/app.bundle.js:76641:17)

I/chromium( 2112):     at _baseExtend (file:///android_asset/www/build/js/app.bundle.js:76641:17)

I/chromium( 2112):     at _baseExtend (file:///android_asset/www/build/js/app.bundle.js:76641:17)

I/chromium( 2112):     at _baseExtend (file:///android_asset/www/build/js/app.bundle.js:76641:17)

I/chromium( 2112):     at _baseExtend (file:///android_asset/www/build/js/app.bundle.js:76641:17)

I/chromium( 2112): ERROR CONTEXT:

I/chromium( 2112): [object Object]", source: file:///android_asset/www/build/js/zone.js (260)

I can’t agree more. This issue is an important one as it crashes smartphones with low memory, even though it works on recent phones. There is a memory leak that needs to be fixed!

You can’t close this issue - two other issues have been closed and referenced to this issue, at least 10 people are reporting this problem. Ionitron you don’t know what you’re doing!

Hey @jgw96, here is the repo : https://github.com/Geoffrey-D/issue-6918-temp. Everything should be in there (I did it fast). Tell me if you have any issue with it