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

[Applicaion/GuiComponent] - don't call init/deinit of subcomponents of guicomponent from application #15825

Closed
wants to merge 28 commits into from

Conversation

Memphiz
Copy link
Member

@Memphiz Memphiz commented Mar 27, 2019

Instead refactor init/deinit of guicomponent to do the righthing - fixes #15561

This might be the proper fix instead of #13878
It ensures that loadskin/unloadskin calls init/deinit of guicomponent instead of the subcomponent (windowmanager). To make it work the init/deinit of guicomponent was altered to not deregister from servicebroker during deinit - but only in the dtor.
Also the application cleanup now only calls reset on the gui because the dtor already does the deinit (would have been a double deinit before which is a nop).

With this the stereoscopic mode selection works properly again (and it turns off 3d mode after playback if setting is configured that way)

@Memphiz Memphiz added Type: Fix non-breaking change which fixes an issue Component: GUI engine v18 Leia labels Mar 27, 2019
@Memphiz
Copy link
Member Author

Memphiz commented Mar 27, 2019

@FernetMenta did i get your intention right here? At least that is what i understood from your comments here: #13743

@FernetMenta
Copy link
Contributor

@Memphiz if you want to fix #13878 I suggest https://pastebin.com/BX5makLi

@Memphiz
Copy link
Member Author

Memphiz commented Mar 28, 2019

But with this you still have application init a sub component of GUI (the window manager) + you added a circular dependency between gui and window manager.
Not sure how this is better?

Also why did you add the GUI message header to all the GUI classes?

@FernetMenta
Copy link
Contributor

One step after another. Moving msg target one level higher solves the linked issue but leaves some issues in the design.
Deinitializing a component and leaving it registered on ServiceBroker for other components to use is imo worse. If you want to follow this path you should unregister it and fix all client calls that don't check for gui being nullptr. That would fix it properly.

@Memphiz
Copy link
Member Author

Memphiz commented Mar 28, 2019

Right - that’s worse indeed.
How about modifying your approach in the following way:
Add an interface IGuiMsgHookHandler and add the method ProcessMsgHooks to it.
Pass this interface to the window manager ctor instead of the full blown GUI component.

This would get rid of the circular dependency involving friend class and gives window manager only what it needs from GUI component.

@Memphiz Memphiz force-pushed the fix_stereoscopic branch 2 times, most recently from 6c1df18 to b2884a4 Compare March 28, 2019 20:27
@Memphiz
Copy link
Member Author

Memphiz commented Mar 28, 2019

@FernetMenta updated with your changes and adapted by splitting CGUIComponent up into 2 interfaces ... one for windowmanager (containing the ProcessMsgHooks only) and one for the rest of kodi (containing all but the ProcessMsgHooks).

@FernetMenta
Copy link
Contributor

@Memphiz I used the concept of a friend class to protect the msg driver method. I agree, this is ugly but it is recognisable as a quick and dirty approach. If you introduce interfaces, you should start to do it right or upcoming changes will be a mess too. Init/Deinit do not fit into the same interface as methods like GetInfoManager.
If you touch ServiceBroker, you should change the raw pointer to a shared pointer like this is already done for a couple of objects.

@Memphiz
Copy link
Member Author

Memphiz commented Mar 29, 2019

So what’s the preferred approach - using your approach as is or removing deinit/init from the interface, make it a shared pointer in broker and leave application with the complete GUI component object?

@FernetMenta
Copy link
Contributor

So what’s the preferred approach

If this is directed to me, you ask the wrong person. I just wanted to give some insights on why my patch looks like it is. Since nobody else cared about the issue for months, I think it's your preference that counts.

@@ -337,7 +337,7 @@ bool CEventServer::ExecuteNextAction()
unsigned int actionID;
CActionTranslator::TranslateString(actionEvent.actionName, actionID);
CAction action(actionID, 1.0f, 0.0f, actionEvent.actionName);
CGUIComponent* gui = CServiceBroker::GetGUI();
IGUIComponent* gui = CServiceBroker::GetGUI();
if (gui)
Copy link
Member

Choose a reason for hiding this comment

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

I know this is all very much WIP and there is a long way to go with refactoring things step by step, but by browsing those changes I really wondered why the EventServer needs to know anything about the GUI? Having it trigger a sound by itself is IMO terribly wrong and should be handled by g_application.OnAction(action) consumers. I know it's something for a different patch, just wondered if this oddity will be gone in the long run.

Copy link
Member Author

@Memphiz Memphiz Apr 2, 2019

Choose a reason for hiding this comment

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

Well this oddity will go as soon as someone makes it go ;) - I have no plans for the GUI component I just wanted to fix the stereoscopic regression in a way that was accepted.

@Memphiz
Copy link
Member Author

Memphiz commented Apr 4, 2019

updated. removed init/deinit from the interface and made gui a shared_ptr in application an servicebroker.

@jenkins4kodi jenkins4kodi added the Rebase needed PR that does not apply/merge cleanly to current base branch label Apr 4, 2019
xbmc/Application.cpp Outdated Show resolved Hide resolved
xbmc/Application.cpp Outdated Show resolved Hide resolved
}

void CGUIComponent::Deinit()
{
CServiceBroker::UnregisterGUI();
Copy link
Contributor

Choose a reason for hiding this comment

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

unregister from ServiceBroker is mandatory here. Deinit puts the service out of order

Copy link
Member Author

Choose a reason for hiding this comment

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

But it’s inconsistent to have it done in the object that gets registered. The owner is application - the owner is responsible to resolve the injected dependencies - like it is done with other broker registrees already.

Copy link
Contributor

Choose a reason for hiding this comment

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

you only unregister it at cleanup but it has to be unregistered during unload/load skin and maybe other operation too. encapsulation makes sense here.
btw: unregister needs to wait until last client has released the shared pointer. that's the reason why it is a shared pointer: https://github.com/xbmc/xbmc/blob/master/xbmc/Application.cpp#L2535

Copy link
Member Author

Choose a reason for hiding this comment

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

Is this new behavior? Can't see where the GUI was deregistered during unload/load skin before tbh. But its a good idea to change skins only while no GUI Users are calling into the component for sure.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have added some more commits towards your directions. Though the check for the gui pointer might be not easily doable ... i started it but still have 1025 hits on unguarded accesses ... :(

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this new behavior? Can't see where the GUI was deregistered during unload/load skin before tbh

Sorry, I forgot to mention that this was my personal view on this, not an official direction of team kodi.
The scenario I had in mind was i.e. that you run headless kodi, launch an X11 desktop and Kodi Ui gets visible, close the desktop -> Kodi falls back to headless, log on to Wayland -> you get Wayland UI of Kodi, ...

Copy link
Member Author

Choose a reason for hiding this comment

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

As far as I am concerned nobody in team kodi has GUI ownership atm - so no need to stress that your opinion is not official or what not. Just discussing improvements here and trying to find a way to give that shared pointer a meaning ;)

Copy link
Member

Choose a reason for hiding this comment

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

True and true.
We still want to support the scenario you mentioned @FernetMenta and appreciate your feedback a lot.
I think I speak for the team, when I say this.

@jenkins4kodi jenkins4kodi removed the Rebase needed PR that does not apply/merge cleanly to current base branch label Apr 9, 2019
@jenkins4kodi jenkins4kodi added the Rebase needed PR that does not apply/merge cleanly to current base branch label Jun 9, 2019
@jenkins4kodi
Copy link
Contributor

@Memphiz this needs a rebase

@a1rwulf a1rwulf mentioned this pull request Aug 8, 2019
13 tasks
@phunkyfish
Copy link
Contributor

@Memphiz would you like to progress this, close it or put it on the backburner?

@phunkyfish phunkyfish added the PR Cleanup: Ask Author PR appears to still be relevant and mergeable. Comment to author to check on status. label Mar 8, 2020
@Memphiz Memphiz closed this Mar 9, 2020
@Rechi Rechi removed the v19 Matrix label Mar 9, 2020
@phunkyfish phunkyfish added PR Cleanup: Author Closed PR closed on the authors request. and removed PR Cleanup: Ask Author PR appears to still be relevant and mergeable. Comment to author to check on status. labels Mar 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: GUI engine PR Cleanup: Author Closed PR closed on the authors request. Rebase needed PR that does not apply/merge cleanly to current base branch Type: Fix non-breaking change which fixes an issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

stereoscopic not working properly
8 participants