I have Krypton 17.1 and MySQL 5.7.18 holding the data for my libraries.
I go into the TV Shows and am shown the list of my shows. Selecting a show, I am presented with the seasons in that show (seasons list). I select a season and i am shown all the episodes. i watch one of them. My skin, “Aeon Nox 5: Redux”, which shows the number of unwatched episodes, does not show an updated unwatched count when i go “back” to the “season list”. Thinking this might be a skin issue, i switched to Confluence and the problem persists.
I checked “tvshow_view” on MySQL and the “watchedcount” value was correctly incremented. I also noticed, from the log snippet below, that no query was run to fetch the season list.
<!-- Marked as WATCHED -->
17:35:32.594 T:5348 DEBUG: CInputManager::OnKey: w (0xf057) pressed, action is ToggleWatched
17:35:32.650 T:14984 DEBUG: Mysql Start transaction
17:35:32.657 T:14984 DEBUG: Mysql execute: delete from bookmark where idFile=9935 and type=1
17:35:32.663 T:14984 DEBUG: Mysql execute: update files set playCount=1,lastPlayed='2017-05-01 17:35:32' where idFile=9935
17:35:32.667 T:12980 DEBUG: CAnnouncementManager - Announcement: OnUpdate from xbmc
17:35:32.667 T:12980 DEBUG: GOT ANNOUNCEMENT, type: 16, from xbmc, message OnUpdate
17:35:32.676 T:5348 DEBUG: Keyboard: scancode: 0x11, sym: 0x0077, unicode: 0x0000, modifier: 0x0
17:35:32.754 T:14984 DEBUG: Mysql commit transaction
17:35:32.802 T:5348 DEBUG: Clearing cached fileitems [videodb://tvshows/titles/104/1/?tvshowid=104]
17:35:32.804 T:5348 DEBUG: CGUIMediaWindow::GetDirectory (videodb://tvshows/titles/104/1/?tvshowid=104)
17:35:32.804 T:5348 DEBUG: ParentPath = [videodb://tvshows/titles/104/1/?tvshowid=104]
17:35:33.306 T:5348 DEBUG: ------ Window Init (DialogBusy.xml) ------
17:35:34.993 T:14984 DEBUG: CVideoDatabase::RunQuery took 2141 ms for 24 items query: select * from episode_view WHERE (episode_view.idShow = 104) AND ((episode_view.c12 = 1 or (episode_view.c12 = 0 and (episode_view.c15 = 0 or episode_view.c15 = 1))))
17:35:35.001 T:5348 DEBUG: Saving fileitems [videodb://tvshows/titles/104/1/?tvshowid=104]
17:35:35.003 T:5348 DEBUG: -- items: 24, sort method: 0, ascending: true
17:35:35.063 T:5348 DEBUG: WindowVideoNav::GetDirectory
17:35:35.580 T:5348 DEBUG: ------ Window Deinit (DialogBusy.xml) ------
<!-- Going BACK to season list -->
17:35:38.169 T:5348 DEBUG: Keyboard: scancode: 0x0e, sym: 0x0008, unicode: 0x0008, modifier: 0x0
17:35:38.291 T:5348 DEBUG: CInputManager::OnKey: backspace (0xf008) pressed, action is Back
17:35:38.292 T:5348 DEBUG: CGUIMediaWindow::GetDirectory (videodb://tvshows/titles/104/)
17:35:38.292 T:5348 DEBUG: ParentPath = [videodb://tvshows/titles/]
<!-- CFileItemList::Load from cache here -->
17:35:38.294 T:5348 DEBUG: Loading items: 6, directory: videodb://tvshows/titles/104/ sort method: 0, ascending: true
17:35:38.312 T:5348 DEBUG: WindowVideoNav::GetDirectory
I switched to the built-in database engine and following the steps from before, the unwatched number updates properly on the season list.
<!-- Marked as WATCHED -->
17:45:08.538 T:5884 DEBUG: CInputManager::OnKey: w (0xf057) pressed, action is ToggleWatched
17:45:08.553 T:7404 DEBUG: CAnnouncementManager - Announcement: OnUpdate from xbmc
17:45:08.553 T:7404 DEBUG: GOT ANNOUNCEMENT, type: 16, from xbmc, message OnUpdate
17:45:08.621 T:5884 DEBUG: Keyboard: scancode: 0x11, sym: 0x0077, unicode: 0x0000, modifier: 0x0
17:45:08.744 T:5884 DEBUG: CGUIMediaWindow::GetDirectory (videodb://tvshows/titles/15/1/?tvshowid=15)
17:45:08.745 T:5884 DEBUG: ParentPath = [videodb://tvshows/titles/15/1/?tvshowid=15]
17:45:08.757 T:9108 DEBUG: CVideoDatabase::RunQuery took 1 ms for 10 items query: select * from episode_view WHERE (episode_view.idShow = 15) AND ((episode_view.c12 = 1 or (episode_view.c12 = 0 and (episode_view.c15 = 0 or episode_view.c15 = 1))))
17:45:08.768 T:5884 DEBUG: WindowVideoNav::GetDirectory
<!-- Going BACK to season list -->
17:45:10.267 T:5884 DEBUG: Keyboard: scancode: 0x0e, sym: 0x0008, unicode: 0x0008, modifier: 0x0
17:45:10.309 T:5884 DEBUG: CInputManager::OnKey: backspace (0xf008) pressed, action is Back
17:45:10.309 T:5884 DEBUG: CGUIMediaWindow::GetDirectory (videodb://tvshows/titles/15/)
17:45:10.310 T:5884 DEBUG: ParentPath = [videodb://tvshows/titles/]
<!-- Did not load from cache and looked up the db-->
17:45:10.349 T:3256 DEBUG: CVideoDatabase::RunQuery took 27 ms for 4 items query: SELECT * FROM season_view WHERE season_view.idShow = 15
17:45:10.350 T:3256 DEBUG: CVideoDatabase::RunQuery took 1 ms for 0 items query: select * from movie_view join movielinktvshow on movielinktvshow.idMovie=movie_view.idMovie WHERE movielinktvshow.idShow = 15
17:45:10.362 T:5884 DEBUG: WindowVideoNav::GetDirectory
From what i gather at xbmc/windows/GUIMediaWindow.cpp (below fragment), the “items” is not cached when using the built-in database because it returns the data pretty quickly, and that using MySQL it did get cached because it took over 1s to return.
if ((XbmcThreads::SystemClockMillis() - time) > 1000 && items.CacheToDiscIfSlow())
items.Save(GetID());
Based on the log snippets above, I see CFileItemList::RemoveDiscCache getting called once to invalidate the cache for the episode list, but not for the parent season list, and when going back to the season list, because Kodi thinks it has a valid cache, it doesn’t make a fresh query and uses the previously cached data which has an outdated [un]watchedcount.
Does this happen to you? Does my logic make sense to you?
PS: I tested this on clean Kodi 17.2 RC1 20170419-661dd08d22, and got the same results.