Bug 411797 - Comic plasmoid cache behavior somewhat buggy
Summary: Comic plasmoid cache behavior somewhat buggy
Status: REPORTED
Alias: None
Product: kdeplasma-addons
Classification: Plasma
Component: Comic (show other bugs)
Version: 5.16.4
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Marco Martin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-09-10 16:26 UTC by Hans-Peter Jansen
Modified: 2019-09-11 19:14 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Simple shell tool for comic strip management and development (2.15 KB, application/x-shellscript)
2019-09-10 16:26 UTC, Hans-Peter Jansen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Hans-Peter Jansen 2019-09-10 16:26:26 UTC
Created attachment 122580 [details]
Simple shell tool for comic strip management and development

This is a strange one, because it occurs only after a new comic strip is published from the source.

The new strip is displayed, when tabbing to it, prev is active, as expected, next is inactive, as expected. When hitting prev, the former strip is displayed, but next is still inactive (not expected), therefor one cannot change back to the current strip with prev and next buttons. One gets back to the current strip, if changing comic sources back and forth. One can jump to the current strip with the "Jump to" context menu option.

It smells like some synchronization problem between in memory and on disk presentation of the strip.

STEPS TO REPRODUCE
1. Load Perscheid and another comic source, eg. Dilbert (that is working still)
2. Perscheid releases a new strip once every weekday, wait for the next strip
3. Switch sources, observe prev/next button behavior

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: oepnSUSE Tumbleweed 20190907
KDE Plasma Version: 5.16.4
KDE Frameworks Version: 5.61.0
Qt Version: 5.13.0

Some notes:
I've attached a tool plasma-comic-tool.sh, that helps with comic source development. When you load my Perscheid source, it should display the current strip. Since Perscheid doesn't provide a name, I've assigned the strip number to the additionalText attribute, displayed on hovering the strip. At the time of this writing, it's 4023, and the system is running for a day. When it started, 4022 was current. After clearing the strip cache with "plasma-comic-tool.sh -s perscheid clean" and switching sources, this logging is triggered (display with "journalctl --all --follow --identifier plasmashell"):

```
Sep 10 17:37:13 xrated plasmashell[2900]: qml: onCurrentTabChanged:dilbert
Sep 10 17:37:14 xrated plasmashell[2900]: qml: onCurrentTabChanged:perscheid
Sep 10 17:37:14 xrated plasmashell[2900]: Fetch page http://www.martin-perscheid.de/4023.html
Sep 10 17:37:14 xrated plasmashell[2900]: No next strip.
Sep 10 17:37:14 xrated plasmashell[2900]: Fetch image http://www.martin-perscheid.de/image/cartoon/4023.gif
Sep 10 17:37:14 xrated plasmashell[2900]: "Author................" "Martin Perscheid"
Sep 10 17:37:14 xrated plasmashell[2900]: "Website URL..........." "http://www.martin-perscheid.de/"
Sep 10 17:37:14 xrated plasmashell[2900]: "Shop URL.............." "http://www.martin-perscheid.de/shop.html"
Sep 10 17:37:14 xrated plasmashell[2900]: "Title................." ""
Sep 10 17:37:14 xrated plasmashell[2900]: "Additional Text......." "4023"
Sep 10 17:37:14 xrated plasmashell[2900]: "Identifier............" QVariant(int, 4023)
Sep 10 17:37:14 xrated plasmashell[2900]: "First Identifier......" QVariant(int, 3999)
Sep 10 17:37:14 xrated plasmashell[2900]: "Last Identifier......." QVariant(int, 4023)
Sep 10 17:37:14 xrated plasmashell[2900]: "Next Identifier......." QVariant(Invalid)
Sep 10 17:37:14 xrated plasmashell[2900]: "Previous Identifier..." QVariant(int, 4022)
```

I've removed some unrelated output. Interestingly, no cache files are created at this point (probably due to not expecting those cache files vanishing), but when hitting prev, things start to look strange:

```
Sep 10 17:44:21 xrated plasmashell[2900]: Fetch page http://www.martin-perscheid.de/4021.html
Sep 10 17:44:21 xrated plasmashell[2900]: Fetch image http://www.martin-perscheid.de/image/cartoon/4021.gif
Sep 10 17:44:21 xrated plasmashell[2900]: "Author................" "Martin Perscheid"
Sep 10 17:44:21 xrated plasmashell[2900]: "Website URL..........." "http://www.martin-perscheid.de/"
Sep 10 17:44:21 xrated plasmashell[2900]: "Shop URL.............." "http://www.martin-perscheid.de/shop.html"
Sep 10 17:44:21 xrated plasmashell[2900]: "Title................." ""
Sep 10 17:44:21 xrated plasmashell[2900]: "Additional Text......." "4021"
Sep 10 17:44:21 xrated plasmashell[2900]: "Identifier............" QVariant(int, 4021)
Sep 10 17:44:21 xrated plasmashell[2900]: "First Identifier......" QVariant(int, 3999)
Sep 10 17:44:21 xrated plasmashell[2900]: "Last Identifier......." QVariant(int, 4023)
Sep 10 17:44:21 xrated plasmashell[2900]: "Next Identifier......." QVariant(int, 4022)
Sep 10 17:44:21 xrated plasmashell[2900]: "Previous Identifier..." QVariant(int, 4020)
Sep 10 17:44:21 xrated plasmashell[2900]: "MaxComicLimit on."

```

While it is displaying the strip 4022 correctly, logging tells us, it loaded 4021, and the cache is set now with:
```
-rw-rw-r-- 1 hp lisa 97661 10. Sep 17:44 perscheid%3A4021
-rw-rw-r-- 1 hp lisa   209 10. Sep 17:44 perscheid%3A4021.conf
-rw-rw-r-- 1 hp lisa   206 10. Sep 17:44 perscheid.conf
```

and perscheid.conf reveals some inconsistencies:
```
[General]
comics=perscheid%3A4021
firstStripIdentifier=3999
isLeftToRight=1
isTopToBottom=1
lastCachedStripIdentifier=4021
shopUrl=http://www.martin-perscheid.de/shop.html
suffixType=Number
title=Perscheid
```

It's obviously missing 4022 and 4023, and consequently noting strip 4021 only, while it displays 4022, and misses the return path to 4023 via next button.
Jumping back und forth (with prev and next) fills the cache with images up to 4021. 

Issues: why does it not store (cache) 4022 and 4023 (again), if it's missing. Related, this misbehavior prevents 4023 from being accessible (the usual way), since the highest cached file is 4021, which makes 4022 accessible, as observed:
```
$ cat perscheid%3A4021.conf
[General]
additionalText=4021
comicAuthor=Martin Perscheid
imageUrl=http://www.martin-perscheid.de/image/cartoon/4021.gif
nextIdentifier=4022
previousIdentifier=4020
websiteUrl=http://www.martin-perscheid.de/
```

It's not related to clearing the cache, since I started debugging with the cache untouched! Somehow, it remembers the initially loaded 4022 as current, and doesn't correct this state, when a new strip is published. I don't see a way, how I could be responsible or fix this behavior within my comic source script.

My Perscheid comic source is available on https://www.pling.com/p/1323091/
and https://github.com/frispete/plasma-addon-comic-perscheid.
Comment 1 Hans-Peter Jansen 2019-09-11 19:14:40 UTC
Further observation shows, that the comic plasmoid does not store the latest strip in cache. Today, the 11th of September, ~/.local/share/plasma_engine_comic contain the strips of yesterday, which you can see with date controlled sources:

-rw-rw-r--  1 hp lisa  237914 11. Sep 13:17 dilbert%3A2019-09-10
-rw-rw-r--  1 hp lisa     210 11. Sep 13:17 dilbert%3A2019-09-10.conf
-rw-rw-r--  1 hp lisa     596 11. Sep 13:17 dilbert.conf

-rw-rw-r--  1 hp lisa  447132 11. Sep 07:50 viewsamerica%3A2019-09-10
-rw-rw-r--  1 hp lisa     236 11. Sep 07:50 viewsamerica%3A2019-09-10.conf
-rw-rw-r--  1 hp lisa     701 11. Sep 07:50 viewsamerica.conf

while it displays the strips of today. Another hint of this claim is, that the progress circle is shown, when switching though sources multiple times, while logging shows, it fetches the todays strips again and again:

Sep 11 21:08:12 xrated plasmashell[2912]: "Author................" "Scott Adams"
Sep 11 21:08:12 xrated plasmashell[2912]: "Website URL..........." "https://dilbert.com/strip/2019-09-11"
Sep 11 21:08:12 xrated plasmashell[2912]: "Shop URL.............." ""
Sep 11 21:08:12 xrated plasmashell[2912]: "Title................." ""
Sep 11 21:08:12 xrated plasmashell[2912]: "Additional Text......." ""
Sep 11 21:08:12 xrated plasmashell[2912]: "Identifier............" QVariant(QDate, QDate("2019-09-11"))
Sep 11 21:08:12 xrated plasmashell[2912]: "First Identifier......" QVariant(QDate, QDate("1994-01-01"))
Sep 11 21:08:12 xrated plasmashell[2912]: "Last Identifier......." QVariant(QDate, QDate("2019-09-11"))
Sep 11 21:08:12 xrated plasmashell[2912]: "Next Identifier......." QVariant(Invalid)
Sep 11 21:08:12 xrated plasmashell[2912]: "Previous Identifier..." QVariant(Invalid)
Sep 11 21:09:30 xrated plasmashell[2912]: qml: onCurrentTabChanged:perscheid
Sep 11 21:09:30 xrated plasmashell[2912]: Fetch page http://www.martin-perscheid.de/4023.html
Sep 11 21:09:30 xrated plasmashell[2912]: No next strip.
Sep 11 21:09:30 xrated plasmashell[2912]: Fetch image http://www.martin-perscheid.de/image/cartoon/4023.gif
Sep 11 21:09:30 xrated plasmashell[2912]: "Author................" "Martin Perscheid"
Sep 11 21:09:30 xrated plasmashell[2912]: "Website URL..........." "http://www.martin-perscheid.de/"
Sep 11 21:09:30 xrated plasmashell[2912]: "Shop URL.............." "http://www.martin-perscheid.de/shop.html"
Sep 11 21:09:30 xrated plasmashell[2912]: "Title................." ""
Sep 11 21:09:30 xrated plasmashell[2912]: "Additional Text......." "4023"
Sep 11 21:09:30 xrated plasmashell[2912]: "Identifier............" QVariant(int, 4023)
Sep 11 21:09:30 xrated plasmashell[2912]: "First Identifier......" QVariant(int, 3999)
Sep 11 21:09:30 xrated plasmashell[2912]: "Last Identifier......." QVariant(int, 4023)
Sep 11 21:09:30 xrated plasmashell[2912]: "Next Identifier......." QVariant(Invalid)
Sep 11 21:09:30 xrated plasmashell[2912]: "Previous Identifier..." QVariant(int, 4022)
Sep 11 21:09:48 xrated plasmashell[2912]: qml: onCurrentTabChanged:viewsamerica
Sep 11 21:09:50 xrated plasmashell[2912]: "Author................" "CartoonArts International"
Sep 11 21:09:50 xrated plasmashell[2912]: "Website URL..........." "http://www.gocomics.com/viewsamerica/2019/09/11"
Sep 11 21:09:50 xrated plasmashell[2912]: "Shop URL.............." ""
Sep 11 21:09:50 xrated plasmashell[2912]: "Title................." ""
Sep 11 21:09:50 xrated plasmashell[2912]: "Additional Text......." ""
Sep 11 21:09:50 xrated plasmashell[2912]: "Identifier............" QVariant(QDate, QDate("2019-09-11"))
Sep 11 21:09:50 xrated plasmashell[2912]: "First Identifier......" QVariant(QDate, QDate("2007-02-04"))
Sep 11 21:09:50 xrated plasmashell[2912]: "Last Identifier......." QVariant(QDate, QDate("2019-09-11"))
Sep 11 21:09:50 xrated plasmashell[2912]: "Next Identifier......." QVariant(Invalid)
Sep 11 21:09:50 xrated plasmashell[2912]: "Previous Identifier..." QVariant(QDate, QDate("2019-09-10"))
Sep 11 21:10:00 xrated plasmashell[2912]: qml: onCurrentTabChanged:xkcd
Sep 11 21:10:00 xrated plasmashell[2912]: No next strip.
Sep 11 21:10:01 xrated plasmashell[2912]: "Author................" "Randall Munroe"
Sep 11 21:10:01 xrated plasmashell[2912]: "Website URL..........." "https://xkcd.com/2201/"
Sep 11 21:10:01 xrated plasmashell[2912]: "Shop URL.............." "https://store.xkcd.com/"
Sep 11 21:10:01 xrated plasmashell[2912]: "Title................." "Foucault Pendulum"
Sep 11 21:10:01 xrated plasmashell[2912]: "Additional Text......." "Trust me, you don't want to get on the wrong side of the paramilitary enforcement arm of the International Earth Rotation and Reference Systems Service."
Sep 11 21:10:01 xrated plasmashell[2912]: "Identifier............" QVariant(int, 2201)
Sep 11 21:10:01 xrated plasmashell[2912]: "First Identifier......" QVariant(int, 1)
Sep 11 21:10:01 xrated plasmashell[2912]: "Last Identifier......." QVariant(int, 2201)
Sep 11 21:10:01 xrated plasmashell[2912]: "Next Identifier......." QVariant(Invalid)
Sep 11 21:10:01 xrated plasmashell[2912]: "Previous Identifier..." QVariant(int, 2200)

We were here already 4 minutes ago:

Sep 11 21:13:33 xrated plasmashell[2912]: qml: onCurrentTabChanged:viewsamerica
Sep 11 21:13:35 xrated plasmashell[2912]: "Author................" "CartoonArts International"
Sep 11 21:13:35 xrated plasmashell[2912]: "Website URL..........." "http://www.gocomics.com/viewsamerica/2019/09/11"
Sep 11 21:13:35 xrated plasmashell[2912]: "Shop URL.............." ""
Sep 11 21:13:35 xrated plasmashell[2912]: "Title................." ""
Sep 11 21:13:35 xrated plasmashell[2912]: "Additional Text......." ""
Sep 11 21:13:35 xrated plasmashell[2912]: "Identifier............" QVariant(QDate, QDate("2019-09-11"))
Sep 11 21:13:35 xrated plasmashell[2912]: "First Identifier......" QVariant(QDate, QDate("2007-02-04"))
Sep 11 21:13:35 xrated plasmashell[2912]: "Last Identifier......." QVariant(QDate, QDate("2019-09-11"))
Sep 11 21:13:35 xrated plasmashell[2912]: "Next Identifier......." QVariant(Invalid)
Sep 11 21:13:35 xrated plasmashell[2912]: "Previous Identifier..." QVariant(QDate, QDate("2019-09-10"))