Skip to content

Only setup controller devices after UI has loaded to prevent control object dependency loop#4651

Merged
ronso0 merged 3 commits intomixxxdj:2.4from
ywwg:controllers-after-window
Mar 14, 2023
Merged

Only setup controller devices after UI has loaded to prevent control object dependency loop#4651
ronso0 merged 3 commits intomixxxdj:2.4from
ywwg:controllers-after-window

Conversation

@ywwg
Copy link
Copy Markdown
Member

@ywwg ywwg commented Jan 29, 2022

Alternative to #4647

@ywwg
Copy link
Copy Markdown
Member Author

ywwg commented Jan 29, 2022

I don't have qt6 working so I can't test with QML

Comment thread src/main.cpp
&MixxxMainWindow::initializationProgressUpdate);
pCoreServices->initialize(pApp);
mainWindow.initialize();
pCoreServices->getControllerManager()->setUpDevices();
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this line could alternatively go in mixxxmainwindow

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

At least there is an asymetie for the QMl and widget case. Can we move both to main, or do we have a good reason for the current places?

Comment thread src/qml/qmlapplication.cpp
@Holzhaus
Copy link
Copy Markdown
Member

Holzhaus commented Jan 29, 2022

Not that this does not solve the problem. It only works in certain circumstances, i.e. the skin in use needs to define the same COs that the mapping uses.

Use a custom skin that doesn't support maximize_library? -> The controller mapping becomes unusable.

The same goes for the QML UI, which doesn't support skin-defined COs at all.

IMHO, built-in mapping mustn't use any non-standard COs, so that they always work, regardless of the skin that is used. So we either need to make these COs official (as proposed in #4647) or we need to remove usage of non-standard COs like maximize_library from all built-in mappings.

@uklotzde
Copy link
Copy Markdown
Contributor

Couldn't get my controller working with the QML version so I cannot really comment on this PR.

The legacy skins at least work.

@ywwg
Copy link
Copy Markdown
Member Author

ywwg commented Jan 29, 2022

ok I see what you mean. Let's keep #4647 and make these official COs

@ywwg ywwg closed this Jan 29, 2022
@ronso0
Copy link
Copy Markdown
Member

ronso0 commented Jan 29, 2022

Use a custom skin that doesn't support maximize_library? -> The controller mapping becomes unusable.

Please explain what "unusable" means @Holzhaus
Is A the entire mapping rejected or
B just that particular button/knob/LED mapping?
I did not find an explanation, neither in https://bugs.launchpad.net/mixxx/+bug/1914969
nor https://bugs.launchpad.net/mixxx/+bug/1941027
or https://mixxx.zulipchat.com/#narrow/stream/113295-controller-mapping/topic/.5BPreviewDeck.5D.2C.20show_previewdeck
or https://mixxx.zulipchat.com/#narrow/stream/109171-development/topic/initialize.20skin.20controls

A would affect mappings that use unofficial skin COs for connectControl/makeConnection, right?
Because unofficial skin COs used for <outputs> in xml will throw a warning but besides that the mapping "works".

@ronso0
Copy link
Copy Markdown
Member

ronso0 commented Jan 30, 2022

Besides:
thanks @ywwg for the quick fix, I didn't notice it's that easy. I think this is what I will use personally
(FWIW building commit with ControllerManager is 1cebbb7)

Also, I think we should have both
#4647 for the 'unofficial' controls we offer in the View menu
#4651 so other (skin) controls can be used with custom mappings

@Holzhaus
Copy link
Copy Markdown
Member

A. Trying to use a non-existing CO from JavaScript results in a JS exception, making the whole mapping unusable.

And even if we changed that and just logged a warning (which we shouldn't, because this really helps detecting mapping bugs), it would lead to weird behavior. Because if the CO doesn't exist when the mapping is loaded, then the script won't be notified when the CO is created. So even after switching skins, the button does not work unless the mapping is reloaded.

@Holzhaus
Copy link
Copy Markdown
Member

Also, I think we should have both
#4647 for the 'unofficial' controls we offer in the View menu
#4651 so other (skin) controls can be used with custom mappings

I agree. #4651 is not a replacement for this PR, but it would fix the case that someone uses a custom skin + custom mapping and wants to use custom COs in both.

@Swiftb0y
Copy link
Copy Markdown
Member

A. Trying to use a non-existing CO from JavaScript results in a JS exception, making the whole mapping unusable.

IIRC thats only the case in controllerDebug mode, but the this solution suffers from other major issues so it doesn't matter.

@ronso0
Copy link
Copy Markdown
Member

ronso0 commented Jan 30, 2022

And even if we changed that and just logged a warning (which we shouldn't, because this really helps detecting mapping bugs), it would lead to weird behavior. Because if the CO doesn't exist when the mapping is loaded, then the script won't be notified when the CO is created. So even after switching skins, the button does not work unless the mapping is reloaded.

It's all about this, right?
throwJSError(err) means the js engine stops evaluating the script?

ControlObjectScript* coScript = getControlObjectScript(group, name);
if (coScript == nullptr) {
// The test setups do not run all of Mixxx, so ControlObjects not
// existing during tests is okay.
if (!m_pScriptEngineLegacy->isTesting()) {
m_pScriptEngineLegacy->throwJSError(
"script tried to connect to "
"ControlObject (" +
group + ", " + name + ") which is non-existent.");
}
return QJSValue();
}

Okay, log a warning (= popup message) would be plausible, as well as that particular control not working if there is no counterpart in Mixxx, that's natural. But the "rest" of the mapping should work -- compared to "control non-existant, mapping disabled", open the js file, fix/disable the respective part, save, reload mapping.

What I'm trying to say:
It would be nice if the situation for users with custom mappings could be improved with simple, straight-forward fixes like this PR, #4647 and another one for the snippet quoted above? (if that actually disables mapping when not in controllerDebug mode

Note: it should still not be permitted to use 'inofficial' COs in built-in mappings because the UX could be impaired.

@ywwg
Copy link
Copy Markdown
Member Author

ywwg commented Feb 5, 2022

I think I agree with ronso0 -- we should allow controllers to invent new control objects to easily enable new features. We could make sure that in debug or controller developer mode, we pop up a warning but continue to load the mapping. In release mode, it should be fine to silently create the control and log a warning. that would mean a little more work for this PR.

So I think maybe we should include this fix as well as #4661 -- we have a new list of official GUI controls that should be fully supported, and we can make life easier for script developers.

@ywwg ywwg reopened this Feb 5, 2022
@Holzhaus
Copy link
Copy Markdown
Member

Holzhaus commented Feb 5, 2022

I think I agree with ronso0 -- we should allow controllers to invent new control objects to easily enable new features.

Controllers we never capable of inventing new control objects, only skins.

I can see why someone thought it was a good idea to let skins create new COs, but this leads to all kinds of issues and also incompatibilities with controller mappings (skin lock-in). Anyway, now that we have that feature, we cannot remove it until we drop legacy skins.

We could make sure that in debug or controller developer mode, we pop up a warning but continue to load the mapping. In release mode, it should be fine to silently create the control and log a warning.

It may be tempting to just log a warnings, but IMHO it would be wrong for 2 reasons:

  1. It's harder to detect broken mappings when only a warning is logged. We cannot verify if a mapping contributor actually tried the mapping in "developer mode" or not.
  2. I'd rather notice issues upfront when starting Mixxx, rather than noticing that my controller mapping only works partially and having to deal with that halfway into a set.

So I think we should not change that.

that would mean a little more work for this PR.

If we really decide to change the JS exception to a log message, that should be a separate PR anyway.

So I think maybe we should include this fix as well as #4661.

Yes, fixing the dependency issue for people who want to use skins and mappings with custom, unofficial COs makes sense.

@ronso0
Copy link
Copy Markdown
Member

ronso0 commented Feb 5, 2022

I was only referring to the current state of this PR: skin controls available for mappings -- no new features.

@ywwg
Copy link
Copy Markdown
Member Author

ywwg commented Feb 6, 2022

so @ronso0 do you think we still need something like this now that #4661 is in?

@Holzhaus
Copy link
Copy Markdown
Member

Holzhaus commented Feb 6, 2022

so @ronso0 do you think we still need something like this now that #4661 is in?

What does "something like this" refer to? If it refers to this PR (i.e. if you're asking if we should fix the initialization order to fix the dependency issues), then the answer is "yes we should fix it".

Currently this PR does not build due to the issue that Uwe pointed out above. After that is fixed, I'd be in favor of merging it.

@ronso0
Copy link
Copy Markdown
Member

ronso0 commented Feb 6, 2022

so @ronso0 do you think we still need something like this now that #4661 is in?

Yes, I'd appreciate this fix here. It's very simple and I don't spot what could go wrong.
I linked the building commit with the missing inlcude Uwe noticed 1cebbb7, but I didn't properly test it yet with my mapping.

Potential CON:
it takes slightly longer until controllers are ready to go? Or is that cancelled out by less parallel jobs while the UI is loading?

@ywwg
Copy link
Copy Markdown
Member Author

ywwg commented Feb 10, 2022

ok I will fix the issue so we can merge this as well.

I don't think the delay in controllers being available is particularly noticeable to the user.

@ronso0
Copy link
Copy Markdown
Member

ronso0 commented Mar 17, 2022

ping @ywwg

@ywwg
Copy link
Copy Markdown
Member Author

ywwg commented Mar 18, 2022

ah I'll fix the build issue and repush

@ywwg
Copy link
Copy Markdown
Member Author

ywwg commented Mar 18, 2022

confirmed builds with qt6

@ywwg
Copy link
Copy Markdown
Member Author

ywwg commented Mar 19, 2022

@ronso0 anything else needed for this?

@ronso0
Copy link
Copy Markdown
Member

ronso0 commented Mar 22, 2022

Code LGTM.
If this wasn't yet tested with both legacy skins and QML I can test this with my controller tomorrow night, though only with legacy skins.

@github-actions
Copy link
Copy Markdown

This PR is marked as stale because it has been open 90 days with no activity.

@github-actions github-actions Bot added the stale Stale issues that haven't been updated for a long time. label Jun 21, 2022
@ronso0
Copy link
Copy Markdown
Member

ronso0 commented Oct 15, 2022

Appearantly also relevant for COs created by the preferences, for example [Controls], ShowDurationRemaining
#10967

Did someone test it with QML? (I can't, haven't setup Qt6 yet)

@ronso0 ronso0 added this to the 2.4.0 milestone Dec 4, 2022
@daschuer daschuer added needs review and removed stale Stale issues that haven't been updated for a long time. labels Dec 8, 2022
@robbert-vdh
Copy link
Copy Markdown
Contributor

This patch also fixes EQ parameter changes not going through when they're read from a controller on Mixxx startup.

@ronso0
Copy link
Copy Markdown
Member

ronso0 commented Dec 19, 2022

@robbert-vdh Thanks for testing. Could you also test with Qt 6, for sake of completeness?
If that works as well we can finally merge this.

@robbert-vdh
Copy link
Copy Markdown
Contributor

@ronso0 I'm using Qt 6.4.1.

@robbert-vdh
Copy link
Copy Markdown
Contributor

Wait, never mind, Mixxx is built against Qt5. Let me try building against Qt6.

@robbert-vdh
Copy link
Copy Markdown
Contributor

Mixxx doesn't build against Qt 6.4.3 for me. Form the 3000 lines of compiler errors it looks like something that previously implicitly converted no longer does, but I sadly don't have the time to decipher this right now.

@ywwg
Copy link
Copy Markdown
Member Author

ywwg commented Jan 16, 2023

would be cool to get this merged in! This is tested with legacy skins, can someone check against QML?

@ronso0
Copy link
Copy Markdown
Member

ronso0 commented Jan 16, 2023

would be cool to get this merged in! This is tested with legacy skins, can someone check against QML?

@mixxxdj/developers

@ronso0
Copy link
Copy Markdown
Member

ronso0 commented Mar 14, 2023

Hitting merge now, finally! Thanks for the fix.

@ronso0 ronso0 merged commit b3a199f into mixxxdj:2.4 Mar 14, 2023
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.

8 participants