Skip to content

Commit

Permalink
Android: Fix white screen of death. (#4728)
Browse files Browse the repository at this point in the history
* Bea saves the day

Remove Inital Items

Co-Authored-By: Beatriz Rizental <[email protected]>

* Assert this won't happen again

Bonk people trying to use initalItem again.

Co-Authored-By: Beatriz Rizental <[email protected]>

* Fix qml test

* Update nebula/ui/components/VPNStackView.qml

Co-authored-by: Beatriz Rizental <[email protected]>

* Update nebula/ui/components/VPNStackView.qml

Co-authored-by: Beatriz Rizental <[email protected]>

* Fix other tests

Co-authored-by: Beatriz Rizental <[email protected]>
  • Loading branch information
strseb and brizental committed Oct 26, 2022
1 parent 7c775aa commit 84549e9
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 4 deletions.
11 changes: 9 additions & 2 deletions nebula/ui/components/VPNStackView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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.");

}

}
Expand Down
6 changes: 6 additions & 0 deletions src/mozillavpn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
1 change: 1 addition & 0 deletions src/mozillavpn.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/ui/screens/ScreenInitialize.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
2 changes: 1 addition & 1 deletion src/ui/screens/ScreenInitializeMobileOnboarding.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
2 changes: 2 additions & 0 deletions tests/auth/mocmozillavpn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""; }
Expand Down
2 changes: 2 additions & 0 deletions tests/qml/mocmozillavpn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ void MozillaVPN::hardResetAndQuit() {}

void MozillaVPN::hardReset() {}

void MozillaVPN::exitForUnrecoverableError(const QString& reason) {}

void MozillaVPN::crashTest() {}

QString MozillaVPN::devVersion() { return qVersion(); }
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/mocmozillavpn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""; }
Expand Down

0 comments on commit 84549e9

Please sign in to comment.