thomas-ernest / plugin.video.arteplussept

Watch Arte+7 content in Kodi
GNU General Public License v2.0
6 stars 4 forks source link

thumbnails seem very memory hungry #44

Closed hypnotoad closed 9 months ago

hypnotoad commented 9 months ago

I really like the addon and its progress over the last years!

I would like to mention one problem which happens on systems with restricted ram (1GB in my case). Displaying video lists in the arte addon seems to utilize lots of memory (in the order of 500MB for usual lists) which causes hangs of the whole system sometimes.

I have found that adding swap space seems to solve the problem for me, but looking into the code, it seems that the thumbnails are full hd images which might be copied, decoded and cached by kodi multiple times and in parallel. If there would be a simple fix in arteitem.py, I would be glad if this could be fixed (I could also try a PR).

thomas-ernest commented 9 months ago

Hello @hypnotoad ,

Yes, thumbnails are downloaded in HD because they may be used as background images according to skins and their settings.

Your use case is valid. What do you think about extending the existing video quality settings to videos and thumbnails ? I guess that this piece of configuration is set to low on your system. I prefer to limit configuration (which makes applications complex to maintain) if possible.

Any contribution is welcome. In case you wanna contribute, note that there is a PR open on improving the video quality settings.

Best regards,

hypnotoad commented 9 months ago

Hi Thomas,

it is a raspberry pi 4 with 1GB of ram. It plays everything on highest quality due to its builtin decoder. So video settings are high (I am a video quality enthusiast with some broadcast background). It just does not have so much ram, although the usual consumption of Kodi is in the 300MB range. I did not have any ram problem so far besided this particular issue.

I am not expert in the Kodi internals, but to me it looks like the image urls of preview and thumbnail are independently used for downloads which are not shared in memory anyways. And I would guess that preview images are only downloaded for the currently selected item, while thumbnails for all visible items.

So I would propose to change the url method to def _get_image_url(self, thumbnail = False) and use an alternative thumbnail resolution. But there are two code paths and I don't understand understand the first one.

I saw that youtube and vimeo also do not have these thumbnails. That would be the simplest solution to me.

Best, Ralf

thomas-ernest commented 9 months ago

Hello @hypnotoad ,

Let me try to explain what I understood to progress on the solution, please.

hypnotoad commented 9 months ago

Hi Thomas,

I agree to the first 2 points. It should not be too complicated to implement them. Regarding the 2 code paths: I mean https://github.com/thomas-ernest/plugin.video.arteplussept/blob/master/resources/lib/mapper/arteitem.py#L246 vs. https://github.com/thomas-ernest/plugin.video.arteplussept/blob/master/resources/lib/mapper/arteitem.py#L254. I guess only the second one is relevant, but I would not be able to define a resolution for the first one. Is the first if branch still relevant?

About youtube and vidmeo: I am not familiar with the code base, but I from my experience they did not display video thumbnails. I looked up the code base and it seems that

thomas-ernest commented 9 months ago

Hello @hypnotoad ,

Hope you're doing good. Thank you for your concise answers providing me the expected info. Very constructive.

I open PR #47 . It is implementing a different way to retrieve thumbnails and fanart / preview images as discussed. I cannot make sure about its memory consumption, though. Thumbnails must be 6 times smaller now. Are you able to test it or to review the PR please ?

Thanks in advance

hypnotoad commented 5 months ago

Dear @thomas-ernest , I realized today that your fix is still not in the current release. It would be great if it could be released - it makes a huge difference: Kodi accidentially overwrote my git-checkout of the current master with the newest release 1.4.2, and I immediately had hanging and crashing systems. After reverting to current git master, everything was smooth again.

In the meantime, I think the problem is related to how xbmcswift processes the listeitem objects. In newer Kodi versions, Memory usage seems fine, but the high resolution images seem to overload my RPi system in different ways now. Likely it is I/O. I cannot debug that properly as debugging tools also freeze as soon as I start scrolling through lists with lots of icons.