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.
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;
}
}
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;
}
I am testing my app with some beta testers and at least one of them has reported this problem. I also have it on my iWork8 tablet which is not a low-spec tablet. I am using ionic2 beta11. Please fix this in the beta12 beceaude this is a mayor release blocker for my app.
hey @martijnlutgens , be aware that using crosswalk solve this issue, as well as using some css as explained by @bea91.
Cheers
I know but I didn't want to resort to using crosswalk because I have never used it and that would cost me extra time to figure that out.
I also tried the css but it didn't seem to help. But I found out that I had forgotten to change the event to NULL. The CSS solution from bea91 solved it eventually. Tnx!
@martijnlutgens I am glad that it helped you, but be aware that crosswalk can be added in 1 code line and will improve (a lot) performances on Android 4.x and fix many issues (like material design on Android 4.x)
with the proviso that Crosswalk won't work with Ionic Cloud Package
Hello all! This has been fixed in the rc.0 release of Ionic 2. We are now using Aot compile which means that we no longer have to dynamically compile templates. Thanks!
Still happening for me in rc0 when passing an event into PopupController.present options (when testing in Chrome w/ ionic serve).
"@angular/compiler": "2.0.0",
"@angular/compiler-cli": "0.6.2",
"@angular/core": "2.0.0",
"@angular/forms": "2.0.0",
"@angular/http": "2.0.0",
"@angular/platform-browser": "2.0.0",
"@angular/platform-browser-dynamic": "2.0.0",
"@angular/platform-server": "2.0.0",
"@ionic/storage": "1.0.3",
"adal-angular": "^1.0.12",
"fs": "0.0.1-security",
"ionic-angular": "2.0.0-rc.0",
"ionic-native": "2.0.3",
"ionicons": "3.0.0",
"reflect-metadata": "0.1.8",
"rxjs": "5.0.0-beta.12",
"zone.js": "0.6.21",
Hi everyone, I am working on ionic2 project.but i am facing one issue IOS like,suppose if we open popover or sidemenu continuesly then next time if we open sidemenu or popover it automatically closes.this happens only in IOS.please suggest.
I've this problem with ion-refresh. I added the code from the documentation but got the error MainPage.html:20 ERROR RangeError: Maximum call stack size exceeded. I receive this error also when I remove all the other stuff on the page.
I get it on all devices. Should I open a new issue for this?
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 Ionic, please create a new issue and ensure the template is fully filled out.