From 84549e94e7f60efeba8b9e4325eae914e2e942bd Mon Sep 17 00:00:00 2001 From: Sebastian Streich Date: Wed, 26 Oct 2022 15:13:47 +0200 Subject: [PATCH] Android: Fix white screen of death. (#4728) * Bea saves the day Remove Inital Items Co-Authored-By: Beatriz Rizental * Assert this won't happen again Bonk people trying to use initalItem again. Co-Authored-By: Beatriz Rizental * Fix qml test * Update nebula/ui/components/VPNStackView.qml Co-authored-by: Beatriz Rizental * Update nebula/ui/components/VPNStackView.qml Co-authored-by: Beatriz Rizental * Fix other tests Co-authored-by: Beatriz Rizental --- nebula/ui/components/VPNStackView.qml | 11 +++++++++-- src/mozillavpn.cpp | 6 ++++++ src/mozillavpn.h | 1 + src/ui/screens/ScreenInitialize.qml | 2 +- src/ui/screens/ScreenInitializeMobileOnboarding.qml | 2 +- tests/auth/mocmozillavpn.cpp | 2 ++ tests/qml/mocmozillavpn.cpp | 2 ++ tests/unit/mocmozillavpn.cpp | 2 ++ 8 files changed, 24 insertions(+), 4 deletions(-) diff --git a/nebula/ui/components/VPNStackView.qml b/nebula/ui/components/VPNStackView.qml index 1fef10339b..3cdf7b2cec 100644 --- a/nebula/ui/components/VPNStackView.qml +++ b/nebula/ui/components/VPNStackView.qml @@ -17,8 +17,15 @@ StackView { } Component.onCompleted: function(){ - if(!currentItem && typeof initialItem === "number" ){ - console.error("Failed to parse initialItem, try Component.OnComplete:push(someURI)"); + if(!currentItem && initialItem) { + // We don't show anything right now and inital item is set, + // On android if initialItem is anything But a component + // it will totaly parse that into garbage values and fail + // + // See https://github.com/mozilla-mobile/mozilla-vpn-client/pull/2638 + console.error("Using the initialItem property does not work on some platforms. Use Component.onCompleted: stackview.push(someURI)"); + VPN.exitForUnrecoverableError("Setting initialItem on a StackView is illegal. See previous logs for more information."); + } } diff --git a/src/mozillavpn.cpp b/src/mozillavpn.cpp index 59eab600ee..3508fbafb8 100644 --- a/src/mozillavpn.cpp +++ b/src/mozillavpn.cpp @@ -1676,6 +1676,12 @@ void MozillaVPN::hardResetAndQuit() { quit(); } +void MozillaVPN::exitForUnrecoverableError(const QString& reason) { + Q_ASSERT(!reason.isEmpty()); + logger.error() << "Unrecoverable error detected: " << reason; + quit(); +} + void MozillaVPN::crashTest() { logger.debug() << "Crashing Application"; char* text = new char[100]; diff --git a/src/mozillavpn.h b/src/mozillavpn.h index a668faea1c..d3f49331cf 100644 --- a/src/mozillavpn.h +++ b/src/mozillavpn.h @@ -164,6 +164,7 @@ class MozillaVPN final : public QObject { Q_INVOKABLE bool validateUserDNS(const QString& dns) const; Q_INVOKABLE void hardResetAndQuit(); Q_INVOKABLE void crashTest(); + Q_INVOKABLE void exitForUnrecoverableError(const QString& reason); Q_INVOKABLE void requestDeleteAccount(); Q_INVOKABLE void cancelReauthentication(); Q_INVOKABLE void updateViewShown(); diff --git a/src/ui/screens/ScreenInitialize.qml b/src/ui/screens/ScreenInitialize.qml index 3afd4fb169..8587b8a359 100644 --- a/src/ui/screens/ScreenInitialize.qml +++ b/src/ui/screens/ScreenInitialize.qml @@ -12,9 +12,9 @@ VPNStackView { id: stackview objectName: "initialStackView" anchors.fill: parent - initialItem: "qrc:/ui/screens/initialize/ViewInitialize.qml" Component.onCompleted: function() { + stackview.push("qrc:/ui/screens/initialize/ViewInitialize.qml") VPNNavigator.addStackView(VPNNavigator.ScreenInitialize, stackview) } } diff --git a/src/ui/screens/ScreenInitializeMobileOnboarding.qml b/src/ui/screens/ScreenInitializeMobileOnboarding.qml index 756d5fc278..785f425b75 100644 --- a/src/ui/screens/ScreenInitializeMobileOnboarding.qml +++ b/src/ui/screens/ScreenInitializeMobileOnboarding.qml @@ -12,9 +12,9 @@ VPNStackView { id: stackview objectName: "initialStackView" anchors.fill: parent - initialItem: "qrc:/ui/screens/initialize/ViewMobileOnboarding.qml" Component.onCompleted: function() { + stackview.push("qrc:/ui/screens/initialize/ViewMobileOnboarding.qml") VPNNavigator.addStackView(VPNNavigator.ScreenInitialize, stackview) } } diff --git a/tests/auth/mocmozillavpn.cpp b/tests/auth/mocmozillavpn.cpp index a6f27696c2..eaaf40a6ec 100644 --- a/tests/auth/mocmozillavpn.cpp +++ b/tests/auth/mocmozillavpn.cpp @@ -157,6 +157,8 @@ void MozillaVPN::hardReset() {} void MozillaVPN::crashTest() {} +void MozillaVPN::exitForUnrecoverableError(const QString& reason) {} + QString MozillaVPN::devVersion() { return qVersion(); } QString MozillaVPN::graphicsApi() { return ""; } diff --git a/tests/qml/mocmozillavpn.cpp b/tests/qml/mocmozillavpn.cpp index fc516c4ca1..6262eacdb0 100644 --- a/tests/qml/mocmozillavpn.cpp +++ b/tests/qml/mocmozillavpn.cpp @@ -163,6 +163,8 @@ void MozillaVPN::hardResetAndQuit() {} void MozillaVPN::hardReset() {} +void MozillaVPN::exitForUnrecoverableError(const QString& reason) {} + void MozillaVPN::crashTest() {} QString MozillaVPN::devVersion() { return qVersion(); } diff --git a/tests/unit/mocmozillavpn.cpp b/tests/unit/mocmozillavpn.cpp index ff6afb6d81..d038f15337 100644 --- a/tests/unit/mocmozillavpn.cpp +++ b/tests/unit/mocmozillavpn.cpp @@ -160,6 +160,8 @@ void MozillaVPN::hardReset() {} void MozillaVPN::crashTest() {} +void MozillaVPN::exitForUnrecoverableError(const QString& reason) {} + QString MozillaVPN::devVersion() { return qVersion(); } QString MozillaVPN::graphicsApi() { return ""; }