I have a strange behavior in an ionic4 application, I will try to explain the problem although it is quite difficult to reproduce it.
When the application (only occurs on Android) has been open for a few hours (in the foreground or background, it is indifferent, but the process was not killed), certain views of the application do not load correctly if are accessed from the menu. The menu uses the this.navCtrl.navigateRoot ([url]) method to access the new view, and when the error occurs what appears is the screen with the header, content and footer colors but without rendering any elements (no content)
The extrange goes here:
- On the one hand, I have “console.log” in all life cycle events, and I see that although ionViewWillEnter and ionViewDidEnter have been executed, ngOnInit has not been executed
- In “network” tab from devtools, I can see that all API request were executed with no errors.
- If I swipe from left to right, the menu is displayed correctly and the ngOnInit event is executed and the view loads correctly with no errors
- If I press the Android “back button”, the ngOnInit event is also executed and the view loads correctly
- If I go to background and return inmediately, the ngOnInit event is also executed
Console log from the last point:
=== PLATFORM PAUSE ===
== ngOnInit ==
=== PLATFORM RESUME ===
As you can see, ngOnInit is executed before the platform resume event…
Given the characteristics of the problem, it is very difficult to me to reproduce it, since when the application has not been open for a long time, this problem does not occur.