https://bugs.kde.org/show_bug.cgi?id=517340
Bug ID: 517340
Summary: Simon Stålenhag POTD: correlated/dependent random
indices cause only 45 of 321 images to ever be shown
Classification: Plasma
Product: plasmashell
Version First master
Reported In:
Platform: Other
OS: Other
Status: REPORTED
Severity: normal
Priority: NOR
Component: Picture of the Day wallpaper
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
Target Milestone: 1.0
SUMMARY
randomArrayValueByKey() in simonstalenhagprovider.cpp creates a new
std::mt19937 with the same daily seed each time it's called. But it's called
_twice_ (once for album, once for image), both random indices are derived from
_exactly the same seed_ and random engine state, making them dependent, rather
than independent.
Over the ~1500 days since Plasma 5.24.0 release, only 45 out of 321 available
images have ever been "randomly" selected and shown.
Here is the relevant code:
https://invent.kde.org/plasma/kdeplasma-addons/-/blob/master/wallpapers/potd/plugins/providers/simonstalenhagprovider.cpp#L32
This bug was introduced by the fix for Bug #453391, which aimed to resolve
Simon Stålenhag’s Wallpapers changing more than once a day.
STEPS TO REPRODUCE
Run simulation at https://ideone.com/F4J3WZ (https://pastebin.com/Gi0tw1SM) or:
1. Use Simon Stålenhag as Picture of the Day provider daily
2. Observe images being highly repetitive
3. Download Simon Stålenhag archive and find that most images have never been
shown
OBSERVED RESULT
Only around 45 of 321 images are ever shown, with highly skewed frequency,
rather than uniform
EXPECTED RESULT
All 321 images should appear with roughly equal probability over time.
FIX
Mix key.size() into the seed to make the two calls produce different random
values:
Change line
https://invent.kde.org/plasma/kdeplasma-addons/-/blob/master/wallpapers/potd/plugins/providers/simonstalenhagprovider.cpp#L32
:
- std::mt19937 randomEngine(QDate(2022, 2, 3).daysTo(QDate::currentDate()));
+ std::mt19937 randomEngine(QDate(2022, 2, 3).daysTo(QDate::currentDate()) * 50
+ key.size());
This way, since entrypoint uses key "simonstalenhag-se-entrypoint" (size 28),
and metaData uses key "simonstalenhag.se" (size 17), they will have different
seeds and generate independent random indices, for each date.
--
You are receiving this mail because:
You are watching all bug changes.