-
-
Notifications
You must be signed in to change notification settings - Fork 241
fix(router): avoiding throw for app stability improvements #1344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
8038a53
to
610a394
Compare
I should mention that an alternative to Mobile app development is uniquely different than web development in this regard. Users are used to refreshing a broken website. Force quitting and relaunching an app however due to crash is more likely to result in complete removal of app. |
610a394
to
89c1158
Compare
Hey @NathanWalker The problem here is that event if those throws are not there - the user will end up navigating to a blank page which is nearly the same as crash. Simply Better approach - we can work on extending the tracing module, so that even if we don't throw in certain cases that we know something bad has happened - we can provide an way for developers to handle and report the error to analytics/crash-reporting for their production apps. Let me know if this makes sense and I can open an issue (probably in core repo) and we can work out the API there. |
d6297fb
to
26ac24c
Compare
@vakrilov I like your idea of extending the tracing module. Main thing I would encourage is to try and help prevent production {N} apps from crashing caused by a Ultimately control over |
Closing this in favor of this strategy. |
@vakrilov Reopening since this strategy is not available yet and this is currently causing production crashes. More than anything we should discuss this since routing is the most fragile portion of any app due to user navigating erratically. There should at minimum be 0 |
2d96bb5
to
88d5725
Compare
} | ||
|
||
return this.activated.instance; | ||
} | ||
get activatedRoute(): ActivatedRoute { | ||
if (!this.activated) { | ||
throw new Error("Outlet is not activated"); | ||
log("Outlet is not activated"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vakrilov worth noting that obviously this logic mirrors what Angular framework does for router-outlet
: https://github.com/angular/angular/blob/master/packages/router/src/directives/router_outlet.ts#L76-L83 however again argument here is {N} is not a web app and therefore cannot withstand a throw
in userland due to detrimental effect app crash has in mobile apps vs. web apps.
@@ -229,7 +235,8 @@ export class PageRouterOutlet implements OnDestroy { // tslint:disable-line:dire | |||
resolver: ComponentFactoryResolver | null): void { | |||
|
|||
if (this.locationStrategy._isPageNavigatingBack()) { | |||
throw new Error("Currently in page back navigation - component should be reattached instead of activated."); | |||
log("Currently in page back navigation - component should be reattached instead of activated. " + routeTransitionWarning); | |||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vakrilov This is actually the biggest culprit to Android crashes and app becoming unresponsive of them all. On Android only (very rarely if ever happens on iOS) sometimes the back page navigation transition timing is different and this could be called before _finishBackPageNavigation
gets fired on location strategy however just logging and allowing it to finish will correct itself on it's own. Definitely don't want to throw
here.
Also issues tying back to this |
It's also possible some improvements found here: #1404 could improve the situation however again |
@vakrilov would be curious your thoughts around:
and how best to handle when |
88d5725
to
b3e136a
Compare
Ok upon further testing what I have in this PR now solves it 100%. I can repro this privately to any core team member via screenshare to anyone that would like to explore further. We are using this PR in a custom pack in PNP now to resolve this issue with 100% reliability. |
100% agree on @NathanWalker 's approach here to ultimately not throw inside routing related functionality. In our case (using named page-router-outlets after migrating to {N} 4.1 and angular 6.0.6) navigation is completely broken now due to the |
Hey @NathanWalker - 👍 👍 👍 for the PR We had some router-related PRs and testing during the last 2 weeks and that's why this PR was pushed back a little in the pipeline. Can you please rebase it so that we can put it trough the CI again? One more thing. There is a good change that if you reach the Can you change those cases to use |
c02d468
to
1b5bfae
Compare
@vakrilov sounds good, I made the changes you requested 👍 |
let { cachedFrameRootOutlet } = this.frameService.findFrame(frame); | ||
|
||
const lastState = this.peekState(cachedFrameRootOutlet || this.currentOutlet); | ||
public _beginModalNavigation(): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't remove the frame: Frame
param. Also, some logic from the method is removed. I guess something gone went while updating the branch?
} | ||
|
||
const lastState = this.peekState(this.currentOutlet); | ||
public _beginPageNavigation(name: string): NavigationOptions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above - the entire method logic is changed.
Hey @NathanWalker - there are some build errors that @ADjenkov commented on. Probably a result of a the rebase. |
I’ll take a look on Thursday definitely sounds like rebase issue. |
e21c068
to
31d31f2
Compare
31d31f2
to
4ab6c2f
Compare
test |
@@ -102,6 +102,8 @@ function routeToString(activatedRoute: ActivatedRoute | ActivatedRouteSnapshot): | |||
return activatedRoute.pathFromRoot.join("->"); | |||
} | |||
|
|||
const routeTransitionWarning = "This could be due to route transition timing and could be ignored."; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vakrilov shoot so sorry this should be deleted as I don’t believe it ended up being used - not in front of computer but could fix up tomorrow or if you just want to remove this line just wanted to flag it before it went in.
PR Checklist
What is the current behavior?
During normal usage of a NativeScript app a user can experience instability and unresponsiveness while navigating around an app. This is often experienced when monkeying around as users enjoy doing with mobile apps. Due to extraneous usage of
throw
throughout router handling, this monkeying around of a {N} app would eventually cause one of thesethrow
's to trigger and throwing the app into unstable state and other times just simply crash.What is the new behavior?
Developers can now properly commence a deep dive debugging sessions by turning tracing on to investigate various UX flows to find suitable fixes within their own apps.