Skip to content
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

VPN-5472: Merge Mozilla.Shared.qmlcomponents into Mozilla.VPN module #8843

Merged
merged 19 commits into from
Jan 30, 2024

Conversation

oskirby
Copy link
Collaborator

@oskirby oskirby commented Dec 19, 2023

Description

We have received a few reports of users encountering a blank UI screen on some Linux distributions. So far this seems to manifest on Ubuntu 20.04 intermittently. When this occurs, we find a QML error in the log of the form:

Warning: qrc:/ui/screens/ScreenHome.qml:9:1: module "Mozilla.VPN" is not installed (ScreenHome.qml:9)

However, this Mozilla.VPN QML module is created programmatically by the program. I suspect that this error occurs because something in the QML cache isn't able to figure out that this module exists, creating this module with qt6_add_qml_module() might do the trick.

Reference

Github issue: #7912 (VPN-5472)

Checklist

  • My code follows the style guidelines for this project
  • I have not added any packages that contain high risk or unknown licenses (GPL, LGPL, MPL, etc. consult with DevOps if in question)
  • I have performed a self review of my own code
  • I have commented my code PARTICULARLY in hard to understand areas
  • I have added thorough tests where needed

@oskirby oskirby changed the title VPN-5472: Merge Mozilla.Share.qmlcomponents into Mozilla.VPN modules VPN-5472: Merge Mozilla.Share.qmlcomponents into Mozilla.VPN module Dec 19, 2023
@oskirby oskirby changed the title VPN-5472: Merge Mozilla.Share.qmlcomponents into Mozilla.VPN module VPN-5472: Merge Mozilla.Shared.qmlcomponents into Mozilla.VPN module Dec 19, 2023
@oskirby
Copy link
Collaborator Author

oskirby commented Dec 19, 2023

Bah, humbug. Okay, so this did actually fix the QML cache loading jankiness, but it completely broke the QML_NAMED_ELEMENT() classes from the C++ world. I guess this means I'm on the right track at least.

@oskirby oskirby force-pushed the vpn-5472-ubuntu-focal-blank-screen branch from a451ecc to 63c4433 Compare December 28, 2023 01:11
@oskirby oskirby marked this pull request as ready for review January 16, 2024 17:51
@oskirby oskirby marked this pull request as draft January 16, 2024 17:54
@oskirby oskirby force-pushed the vpn-5472-ubuntu-focal-blank-screen branch from 8829be8 to ebddc2f Compare January 18, 2024 07:16
@oskirby oskirby marked this pull request as ready for review January 18, 2024 18:54
Copy link
Collaborator

@mcleinman mcleinman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. A couple questions so I can better understand this, as I don't know this part of the code super-well.

I don't have a Linux box or VM currently, so I'm not able to test it.

@@ -44,6 +44,11 @@ ProductsHandler::ProductsHandler(QObject* parent) : QAbstractListModel(parent) {
Q_ASSERT(!s_instance);
s_instance = this;

// If web purchases are supported, then we don't need to do anything.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why move this in?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find a way to conditionally register a singleton type purely using qt_add_qml_module() in a way that would respect the feature flags so I figured the cleanest solution was to register all the QML types in the Mozilla.VPN module (and to do so consistently regardless of feature flagging).

In order to replicate the intended behaviour of the C++ code that this replaces, it was necessary to ensure that the ProductsHandler class doesn't do anything when the feature flag is disabled even if we happen to instantiate it.

namespace {
Logger logger("FilterProxyModel");
}
#include <QDebug>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the changes in this file?

Copy link
Collaborator Author

@oskirby oskirby Jan 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to move this class into the Nebula library, it was important to make sure that the C++ code doesn't depend on code in the mozillavpn target, otherwise this would result in a dependency loop. This mostly just required that we drop the use of the VPN's logging infrastructure and just do it in pure Qt.

@@ -22,8 +22,6 @@ constexpr const char* ADDON_MESSAGE_SETTINGS_STATUS_KEY = "state";
class AddonMessage final : public Addon {
Q_OBJECT
Q_DISABLE_COPY_MOVE(AddonMessage)
QML_NAMED_ELEMENT(MZAddonMessage)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this?

Copy link
Collaborator Author

@oskirby oskirby Jan 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally I was finding that the QML types registered implicitly by the mozillavpn target were failing to make it into the QML namespace. To work around it, this PR is attempting to move all the QML type registration into the mozillavpn-ui target and we do it in src/ui/types/MZAddonMessage.h with the QML_FOREIGN() macro instead.

@oskirby oskirby requested a review from mcleinman January 29, 2024 16:36
Copy link
Collaborator

@mcleinman mcleinman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for those explanations. Code looks great to me, but I'm not able to test it - I don't have a Linux box set up.

Naomi, your call on whether you want to merge or wait for additional 👍🏻 on this one.

Copy link
Member

@lesleyjanenorton lesleyjanenorton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here I was really hoping this was just an issue of adding an import statement or two. Oof. Thanks for taking this on @oskirby!

A few things:

  • Why move the composer dir into src/ui? Is it possible to move it to nebula/ui instead? NBD if not but so far only QML types in Nebula are prefixed with "MZ". (Another matter for our tech debt pile: we no longer need to separate the QML according to what can be 'shared' or not)
  • I'm still completely baffled as to why Mozilla.Shared works and Mozilla.VPN randomly fails (although to your point on Slack, maybe Shared fails too and we just don't know it yet).

nebula/ui/components/qmldir Outdated Show resolved Hide resolved
@@ -161,8 +147,6 @@ target_sources(qml_tests PRIVATE
${MZ_SOURCE_DIR}/errorhandler.h
${MZ_SOURCE_DIR}/feature/feature.cpp
${MZ_SOURCE_DIR}/feature/feature.h
${MZ_SOURCE_DIR}/filterproxymodel.cpp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need filterproxymodel.cpp/.h?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do, it's just included as a part of the nebula library now instead of needing to be manually included in the tests.

@@ -58,16 +57,7 @@ class ConnectionHealth final : public QObject {

ConnectionStability stability() const { return m_stability; }

void overwriteStabilityForInspector(ConnectionStability stability) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹

qmlRegisterSingletonInstance("Mozilla.VPN", 1, 0, "VPNProducts",
ProductsHandler::instance());
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't introduced by your changes but does it still make sense to register MZAccessibleNotification and MZI18n here instead of qmlengineholder? Seems odd to be handling this in two places.

Copy link
Collaborator Author

@oskirby oskirby Jan 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, it is a bit weird registering things in multiple places like this. However, my ideal solution, if I were up to another refactoring challenge, would be to combine the Mozilla.VPN and Mozilla.Shared modules together. They are vestigial remains of our attempt to modularize the codebase and doing so would require that we register everything in the QML module instead of calling qmlRegisterSingletonInstance()

nebula/ui/components/forms/MZSearchBar.qml Show resolved Hide resolved
nebula/ui/components/MZGuideList.qml Show resolved Hide resolved
@lesleyjanenorton
Copy link
Member

Also want to note: My questions don't need to be answered if you're ready to merge. I'm just baffled and curious/wondering.

@oskirby
Copy link
Collaborator Author

oskirby commented Jan 30, 2024

* Why move the composer dir into src/ui? Is it possible to move it to nebula/ui instead? NBD if not but so far only QML types in Nebula are prefixed with "MZ". (Another matter for our tech debt pile: we no longer need to separate the QML according to what can be 'shared' or not)

I wanted to; it would have cleaned things up nicely and left all the composer stuff in the nebula library. Unfortunately, there's a dependency between the composer classes and the AddonApi which would result in a dependency loop between nebula and mozillavpn.

@oskirby oskirby force-pushed the vpn-5472-ubuntu-focal-blank-screen branch from 1b6583f to ce44ede Compare January 30, 2024 09:38
@oskirby oskirby merged commit 2d45b94 into main Jan 30, 2024
125 checks passed
@oskirby oskirby deleted the vpn-5472-ubuntu-focal-blank-screen branch January 30, 2024 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants