-
Notifications
You must be signed in to change notification settings - Fork 117
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
Conversation
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. |
a451ecc
to
63c4433
Compare
8829be8
to
ebddc2f
Compare
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.
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. |
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.
Why move this in?
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.
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> |
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.
Why the changes in this file?
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.
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) |
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.
Why remove this?
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.
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.
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.
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.
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.
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).
@@ -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 |
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.
Do we need filterproxymodel.cpp/.h?
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.
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) { |
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.
🧹
qmlRegisterSingletonInstance("Mozilla.VPN", 1, 0, "VPNProducts", | ||
ProductsHandler::instance()); | ||
} | ||
|
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.
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.
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.
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()
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. |
I wanted to; it would have cleaned things up nicely and left all the composer stuff in the |
1b6583f
to
ce44ede
Compare
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:
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 withqt6_add_qml_module()
might do the trick.Reference
Github issue: #7912 (VPN-5472)
Checklist