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

feat: improve screen rendering framework #13737

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

acolombier
Copy link
Member

This is a refactor largely inspired from the work in #13459 to simplify the hook system used for screen rendering.

src/controllers/controller.h Outdated Show resolved Hide resolved
Comment on lines 526 to 530
} else if (oneShot) {
} else if (oneShot && CmdlineArgs::Instance().getControllerDebug()) {
qCDebug(m_logger) << "Starting one-shot timer:" << timerId;
} else {
qCDebug(m_logger) << "Starting timer:" << timerId;
Copy link
Member

Choose a reason for hiding this comment

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

this seems half backed now, either check it for both or none. Though shouldn't it be unnecessary to check, because the logging category takes care of it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah indeed, needs more doing.
By category, I assume you mean the debug category? If yes, this is unfortunately not enough about the noisy logging related to controller communication is blindly fed to the debug category everywhere on the code base.

Copy link
Member

Choose a reason for hiding this comment

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

ah, yeah, thats unfortunate. I think we have some code somewhere though that adjusts the default logging category. That should get rid of the controller debug code in theory. Maybe thats broken? Can you look into it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fair enough, I didn't realise this was supposed to be a feature since #4523

I'm not sure if it doesn't work as expected or if I misunderstood the point of having a dedicated CLI arg - are we expecting controller debug message to show when running with --log-level debug?

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if it doesn't work as expected or if I misunderstood the point of having a dedicated CLI arg

Well, the dedicated CLI flag was there first, so we tried our best to keep it for backwards compatibility.

are we expecting controller debug message to show when running with --log-level debug?

I'm actually not sure. I'd have to go through the PR again to look it up. Either way, it seems broken, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Either way, it seems broken, right?

My assumption from reading the --help output was that it wouldn't log controller related debug message if not explicitly opted-in so with that understanding, yes it's broken.
But we could also say the man is misleading and that --controller-debug will enable debug message only for controller, whereas --log-level debug enable all log messages, including controller ones.

IMO, it should be 1) - when I implemented the S4 Mk3 mapping, I add to add that nasty workaround, otherwise I would get a 10G+ logfile after an hour session, due to that message logging every single HID packet coming in every 20ms

Copy link
Member Author

@acolombier acolombier Oct 16, 2024

Choose a reason for hiding this comment

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

@Swiftb0y are you happy to keep this work around as-is and create a follow up issue + FIXME comment?

Copy link
Member

Choose a reason for hiding this comment

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

works for me, yes

src/test/controllerscriptenginelegacy_test.cpp Outdated Show resolved Hide resolved
src/qml/qmlmixxxcontroller.h Outdated Show resolved Hide resolved
src/qml/qmlmixxxcontroller.h Outdated Show resolved Hide resolved
@acolombier acolombier mentioned this pull request Oct 16, 2024
2 tasks
@acolombier acolombier force-pushed the feat/improve-screen-rendering-framework branch from c6fd897 to 99fed94 Compare October 17, 2024 00:33
Copy link
Member

@Swiftb0y Swiftb0y left a comment

Choose a reason for hiding this comment

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

only remaining complaint from me tbh

QHash<QString, TransformScreenFrameFunction> m_transformScreenFrameFunctions;
// the QML root item. Note that the pointer is owned by the QML scene which
// will free them on shutdown (ControllerScriptEngineLegacy::shutdown)
QHash<QString, mixxx::qml::QmlMixxxControllerScreen*> m_rootItems;
Copy link
Member

Choose a reason for hiding this comment

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

lets avoid introducing manual memory management. You can wrap this in a unique_ptr. If that doesn't work because QHash needs the key to be copy-able, use std::unordered_map instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

Any reason why introducing a smart pointer on a Qt-owned reference here? Just in case you've missed the comment, the pointer is managed by the QML scene, we don't have any control over it.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I just spotted it now. Well the problem is that we do call delete on it. So its very easy to mistake it as properly owning. I also fear that the pointer can easily outlive the RenderingEngine their tied to. Ideally the pointers would stay entirely in their rendering engine and in order to access them, you need to access the rendering engine.

Copy link
Member

Choose a reason for hiding this comment

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

So sometimes you do delete them and sometimes you don't. It would be really nice if you could fix those ownership issues here.

Copy link
Member Author

Choose a reason for hiding this comment

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

It looks liked I was wrong about the QML ownersphip

The ownership of the returned object instance is transferred to the caller.

So I will replace that Hash/fatPtr with unordered_map/unique_ptr

Copy link
Member

Choose a reason for hiding this comment

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

ah, yeah. I was interpreting the

rootItem->setParentItem(pScreen->quickWindow()->contentItem());

line as transferring ownership, but thats obviously wrong on second look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants