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

Change splash db upgrade logic #10731

Merged
merged 1 commit into from Oct 27, 2016
Merged

Change splash db upgrade logic #10731

merged 1 commit into from Oct 27, 2016

Conversation

phate89
Copy link
Contributor

@phate89 phate89 commented Oct 19, 2016

Change the splash screen to show the message of upgrading database only when we're actually upgrading a database.

Description

Motivation and Context

The old method wassn't aware if there was some upgrade and what db was doing the upgrade

How Has This Been Tested?

Tested upgrading my old mysql databases

Screenshots (if appropriate):

Types of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the Code guidelines of this project
  • My change requires a change to the documentation, either Doxygen or wiki
  • I have updated the documentation accordingly
  • I have read the CONTRIBUTING document
  • I have added tests to cover my change
  • All new and existing tests passed

@phate89
Copy link
Contributor Author

phate89 commented Oct 19, 2016

@Paxxi @DaveTBlake for review/test

@DaveTBlake
Copy link
Member

A welcome follow on from #10483 that only shows when migration tasks happening rather than every start up. @MilhouseVH, @tamland and @fritsch may be interested in this too.

#. Localized addon database name for splash screen
#: xbmc/addons/AddonDatabase.h
msgctxt "#24152"
msgid "Addon"

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@MilhouseVH
Copy link
Contributor

MilhouseVH commented Oct 19, 2016

Thanks @phate89 - it works well, I've tested upgrading MyMusic50 to MyMusic60 and MyVideos90 to MyVideos107, the latter is particularly time consuming. I'll include this PR in future builds.

There does however remain one issue: when <splash>false</splash> is added to advancedsettings.xml, there is no splash displayed, and also no migration messages (even when Music and Videos databases are being migrated). All the user sees is a totally blank (black) screen, with no messages.

IMHO the splash should be forced to appear along with the migration messages, regardless of the <splash> setting, whenever a migration is taking place.

One other nitpick would be to position the text a little higher, just in case of any overscanning or weird resolution issues - it seems a little unnecessary to position the text quite so low down (it appears to be close to the bottom edge of my 1920x1080 1:1 pixel screen).

@DaveTBlake
Copy link
Member

+1
Tested with a large MyMusic48 to MyMusic60.

I too would put the text a little higher, and probably shouldn't capatalise "Database", e.g.
"Music database migration in progress - please wait..."
But minor stuff, and I would happily live with it.

@ksooo ksooo added the Type: Fix non-breaking change which fixes an issue label Oct 20, 2016
@phate89
Copy link
Contributor Author

phate89 commented Oct 20, 2016

I updated the pr.. Now we update the text adding dot every second..
If someone is familiar with our CThread should check my code...

@tamland
Copy link
Member

tamland commented Oct 20, 2016

Sorry but not liking how this is currently implemented. The database should not have a dependency on the global application messenger. Instead it should be passed in as a callback/another agnostic structure, or the entire migration refactored and uncoupled from the database. This is why I didn't bothered with it in the first place.

Sleep(1000);
}
}
Show();

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@Paxxi
Copy link
Member

Paxxi commented Oct 20, 2016

@tamland trust that passing in a callback could be cleaner but more work. This is a step in the right direction and app messenger is purposely designed for this with very few dependencies itself.
Any work that removes some lower level dependency of a higher level is progress and I encourage it. Will review the implementation later when I'm at a computer

@phate89
Copy link
Contributor Author

phate89 commented Oct 20, 2016

@tamland I added a new commit that moves the update part (the same update procedure, no refactor for now) to databasemanager. So only databasemanager has a dependency on applicationmessenger..Is it better?

@phate89 phate89 closed this Oct 20, 2016
@phate89 phate89 reopened this Oct 21, 2016
@FernetMenta
Copy link
Contributor

you could offload the migrations tasks to an extra thread. then the main thread can wait in init for this task to be completed and display splash and messages accordingly.

@phate89
Copy link
Contributor Author

phate89 commented Oct 21, 2016

@FernetMenta thanks for the suggestions. Any help is appreciated.
The main problem wasn't to actually update from main thread but update the text every second to keep something moving.
You are suggesting move the loop in capplication? Something like

CDatabaseManager::GetInstance().StartInitialize();
while (CDatabaseManager::GetInstance().IsRunning())
{
  CSplash::GetInstance().Show(updatedMsg);
  if (CDatabaseManager::GetInstance().IsRunning())
    sleep (1000);
}

@FernetMenta
Copy link
Contributor

@phate89 yes, this will hold processing of the main thread until upgrade has finished. This is intended behaviour.

@phate89 phate89 force-pushed the update_db branch 2 times, most recently from 95190fc to 2beef54 Compare October 22, 2016 09:32
@phate89
Copy link
Contributor Author

phate89 commented Oct 22, 2016

@FernetMenta I updated the pr.. I moved the update logic to the db manager and moved the db upgrade and the addon migration to a separate thread (If I understood well our cthread)

if (CDatabaseManager::GetInstance().IsRunning())
Sleep(1000);
}
}

This comment was marked as spam.

This comment was marked as spam.

@tamland
Copy link
Member

tamland commented Oct 22, 2016

Not exactly thread safe.. Try creating a task and send it off with CJobManager::Submit instead, or spawn a new thread; don't inherit from Cthread. Things like CAddonSystemSettings shouldn't be a thread.

@FernetMenta
Copy link
Contributor

FernetMenta commented Oct 22, 2016

@phate89 using CThread may work but is not the best choice. What you really want to do is spawning an upgrade thread if required. Look into CJob and CJobManager. Those classes do what you need here.

EDIT : cross post :) @tamland had the same idea

@phate89
Copy link
Contributor Author

phate89 commented Oct 22, 2016

Thanks from the tip.. it'' quite nice ttt see we already have so many classes ready for several tasks.. I''l look into CJobManager and report back

@phate89
Copy link
Contributor Author

phate89 commented Oct 22, 2016

@tamland @FernetMenta I updated the pr using CJobManager::Submit. I hope I got it right this time :|

{
if (CDatabaseManager::GetInstance().m_bIsUpgrading)
CSplash::GetInstance().Show(std::string(i, ' ') + localizedStr + std::string(i, '.'));
if (notFinished)

This comment was marked as spam.

This comment was marked as spam.

{
for (int i = 1; i <= 3 && notFinished; ++i)
{
if (CDatabaseManager::GetInstance().m_bIsUpgrading)

This comment was marked as spam.

This comment was marked as spam.

@FernetMenta
Copy link
Contributor

Looks ok from my pov. I can't say much about the upgrade itself

@phate89
Copy link
Contributor Author

phate89 commented Oct 24, 2016

jenkins build this please

@phate89 phate89 force-pushed the update_db branch 2 times, most recently from f9e72b7 to 438e7fc Compare October 24, 2016 13:41
@tamland
Copy link
Member

tamland commented Oct 24, 2016

Getting closer:) but you need to use std::future or events, and wait. With the sleeps the migration is up to 1 second slower than it need to be.

@@ -141,13 +141,15 @@ std::vector<std::string> CAddonSystemSettings::MigrateAddons(std::function<void(

if (CSettings::GetInstance().GetInt(CSettings::SETTING_ADDONS_AUTOUPDATES) == AUTO_UPDATES_ON)
{
onMigrate();
m_bIsMigratingAddons = true;

This comment was marked as spam.

@phate89
Copy link
Contributor Author

phate89 commented Oct 24, 2016

@tamland
I know waiting is better but we also want to update the text every second to show some progress. It's something that can take several minutes so moving dots helps to see we're not stuck.

@tamland
Copy link
Member

tamland commented Oct 24, 2016

That's what it does. If you pass 1 second to the wait method it returns ready or timeout after 1 second. If it's ready before that it will be interrupted.

@phate89
Copy link
Contributor Author

phate89 commented Oct 24, 2016

@tamland I'm dumb of course you're right.. i updated it using our CEvent class

@@ -1123,8 +1124,22 @@ bool CApplication::Initialize()
g_curlInterface.Unload();

// initialize (and update as needed) our databases
CSplash::GetInstance().Show(g_localizeStrings.Get(24150));
CDatabaseManager::GetInstance().Initialize();
CEvent event;

This comment was marked as spam.

@phate89
Copy link
Contributor Author

phate89 commented Oct 24, 2016

now it should be ok.. thanks @FernetMenta @tamland for all the help..
jenkins build this please

@MartijnKaijser
Copy link
Member

win32 upgrade from v14 and all is fine. thx
jenkins build this please.

@MartijnKaijser
Copy link
Member

@FernetMenta @tamland if all good please merge :)

@FernetMenta
Copy link
Contributor

fine by me, @tamland your button

@tamland tamland merged commit 7d97806 into xbmc:master Oct 27, 2016
@phate89 phate89 deleted the update_db branch November 30, 2016 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Fix non-breaking change which fixes an issue v17 Krypton
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants