croneter / PlexKodiConnect

Plex integration in Kodi done right
GNU General Public License v2.0
1.16k stars 77 forks source link

Huge Plex library (>6000 movies) crashes Kodi on initial sync #531

Closed ghost closed 5 years ago

ghost commented 6 years ago

Crash on movie item number 6691 (Home Alone 2 according to onscreen GUI).

Log 1 (log 2 to follow)

https://drive.google.com/open?id=1Wcsvmb4_bos0Ro5vVfGEnH53_vR726Nv

Log 2 @croneter this one on 6616 (The Guardian according to onscreen GUI).

https://drive.google.com/open?id=1R5EMSCHIo4zpQGuFfpes_FtOx790lOvz

croneter commented 6 years ago

There is nothing at all in the log indicating an issue with neither PKC nor Kodi, unfortunately.

I must tell you that Kodi 17.6 is not the most stable piece of software. I myself get crashes from time to time. This should improve with Kodi 18, once it's out of beta phase.

I'll close this issue as there is nothing I can do, unfortunately.

ghost commented 6 years ago

Shame as even after a complete fresh install it seems broken on a Pi 3. I take it you don't have one to test with?

That crash dump I PM'D you was from the Pi 3 by the way.

croneter commented 6 years ago

I personally use a Pi 3. Kodi crashes from time to time. Can you test using something ELSE than LibreElec and a Pi?

croneter commented 6 years ago

You might want to take this up with the LibreElec team in their forum. Again - theoretically, PKC should not be able to crash Kodi...

ghost commented 6 years ago

I doubt I'll get anywhere with them and it has worked before without issue via LibreELEC even with 8.2.5 so I have no idea whats causing it. It seems like the load of the initial sync or maybe my huge library size just freezes Kodi dead. I chose the Pi 3 cause it's the only device that does full resolution 3D MVC playback. Something i can only get in Kodi. :)

croneter commented 6 years ago

The testing would be solely to check whether another Kodi, outside the LibreElec world, also crashes.

PKC resumes sync after a crash - where it left off. Does your entire library sync after a couple of crashes?

ghost commented 6 years ago

That's the thing. It starts from scratch. There's no resuming and it beginnings the 7K ish sync (just movies, tv is about 50K+) from the beginning again.

Would you suggest any particular flavour of Kodi?

OpenELEC maybe?

croneter commented 6 years ago

Weird... That indicates that the Kodi database gets reset.

Try pulling the plug after 5k each time

croneter commented 6 years ago

If you don't mind me having access to your library, could you please temporarily add me as a friend (username croneter)? I could thus try to reproduce the issue. My library is way too small right now :wink:

ghost commented 6 years ago

Invited.

croneter commented 6 years ago

Please try the new BETA version 2.3.11 and report back

ghost commented 6 years ago

Will give it a go and report back! Thank you!

ghost commented 6 years ago

@croneter not fixed. froze at 6499 items.

croneter commented 6 years ago

I just synced all your 8000+ movies plus the rest to Kodi 17.6 on Windows 10. Please take this issue to the LibreElec guys...

image

ghost commented 6 years ago

Can you confirm it happens on your Pi 3 with Librelec as well?

On 31 Aug 2018, at 21:24, croneter notifications@github.com<mailto:notifications@github.com> wrote:

I just synced all your 8000+ movies plus the rest to Kodi 17.6 on Windows 10. Please take this issue to the LibreElec guys...

[image]https://user-images.githubusercontent.com/4637940/44934304-a3bdd380-ad6c-11e8-9a7e-63d31782cc04.png

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/croneter/PlexKodiConnect/issues/531#issuecomment-417779799, or mute the threadhttps://github.com/notifications/unsubscribe-auth/APXIU3RO_Jebiu5qz4fmIqWQS0Vws2LWks5uWZuQgaJpZM4WMZ_U.

croneter commented 6 years ago

Not yet, am on the road for another week

ghost commented 6 years ago

@croneter when you're back would you mind confirming if it crashes for you on a Pi 3 with LibreELEC 8.2.5? I'll then reach out the LibreELEC guys after. 👍

croneter commented 5 years ago

Invited.

Could you please grant me access to your PMS again? I'd like to test on my Raspi 3 with LibreElec, see if mine also crashes. Thanks @danjames92 !

ghost commented 5 years ago

Sure, no problem.

ghost commented 5 years ago

Done.

croneter commented 5 years ago

Thanks! Looking at the massive (!!) size of your library: could it be that your LibreElec is simply running out of disk space? I guess you're also using a rather small SD card

ghost commented 5 years ago

Wasn't caching images I think with a 16GB card. I'll have to confirm.

Just a quick FYI, "vMovies -Remux" is the start of me rebuilding my libraries using /data instead of /mnt/unionfs as a root path.

croneter commented 5 years ago

I can confirm that my LibreElec crashes around movie number ~6100. Sync with Kodi 17.6 on Windows works, though. Hence: Nothing I can do at the moment from the PKC side, then...

Edit: Kodi crashes. I can still SSH to LibreElec. Nothing in the logs that indicates what's going on. Memory/RAM not running out, either

Edit2: Well, sometimes LibreElec crashes entirely and I'm not even able to SSH

ghost commented 5 years ago

How many sync threads were you using? I found sometimes it got further using 1. There's an issue somewhere. ☚ī¸

Edit: could you try a build with a heavily limited writing capacity to the database like you did before but more so? I.e. One write every x seconds etc

croneter commented 5 years ago

Nope the number of threads seemed random. And definitely no - Kodi on Windows works. I will not implement a work-around for a single platform that is bound to be updated very soon anyway, sorry. Besides the number of writes per second does not seem to be the issue, otherwise the library scan would crash sooner

milnash commented 5 years ago

Same happens with Nvidia Shield on a huge library. My crash seems to be because of RAM running out. And it is not my movies, 7000+, it is my TV Show episodes, 75 000+. Using Kodi 17.6.

Work around:

  1. I manually exit Kodi before RAM running out and causing the crash.
  2. Start Kodi again.
  3. Wait couple of minutes and then the sync continues.

Note: If I let Kodi crash, the sync starts from scratch again.

milnash commented 5 years ago

Same happens with Nvidia Shield on a huge library. My crash seems to be because of RAM running out. And it is not my movies, 7000+, it is my TV Show episodes, 75 000+. Using Kodi 17.6.

Work around:

  1. I manually exit Kodi before RAM running out and causing the crash.
  2. Start Kodi again.
  3. Wait couple of minutes and then the sync continues.

Note: If I let Kodi crash, the sync starts from scratch again.

I was wrong. My work around does not work. Have been trying for 2 days to get my sync working. Trying with Kodi 18 Beta 3 now to see if it is better, but my RAM is running out and TV shows has only synced 40%...

Hope someone figures this out.

croneter commented 5 years ago

@milnash Could you please share a debug log file? This bug will be very hard to pin down

croneter commented 5 years ago

@milnash Does this also happen if you PKC and Kodi on e.g. a Windows machine?

milnash commented 5 years ago

@milnash Does this also happen if you PKC and Kodi on e.g. a Windows machine?

No. Only with my Nvidia Shield and I guess it's because my Windows machine has 16GB RAM. Is it possible to add something in the code to free up the memory if it reaches below let's say 300MB? Free memory is visible in Kodi. I'm no coder as you can guess :)

croneter commented 5 years ago

If you enable Kodi debug logging, you always see the available free ram. Does that figure decrease if you sync on the shield until it crashes? How about the Windows machine?

Thing is, ram should be freed continuously as pkc syncs

milnash commented 5 years ago

Yes, the RAM decreases on the Shield during the sync and then crashes when it reaches 180 MB free. I can try with a Windows machine - but I guess you also have a Windows machine? I can share my Plex server with you so you can test and play movies or shows if you want :)

croneter commented 5 years ago

Excited to hear back from you - I think I got the bugger! :laughing: Do try PKC version 2.4.9 and let me know

ghost commented 5 years ago

Oh this is exciting! I will give it a go again. :)

Hope having access to my library helped!

croneter commented 5 years ago

Hmm, does not seem to be quite fixed yet :disappointed:

I think we're looking at some kind of Python "arena fragmentation bug" caused by xml.etree.ElementTree, see https://bugs.python.org/issue11849

croneter commented 5 years ago

Also see here: https://benbernardblog.com/tracking-down-a-freaky-python-memory-leak/

croneter commented 5 years ago

It's much better, but my Pi 3 still crashes

ghost commented 5 years ago

Yeah you're right. I get crashes with 8.2.5 too. Was ok with CoreELEC 8.95.3 but that's not what you're looking at here.

jmurph116 commented 5 years ago

Just like to point out that I still haven't been able to get PKC to sync my library on any of my devices either. Tried using kodi 17.6 and Kodi 18 beta 3 on multiple devices. I too, have an incredibly large library. Kodi crashes around the 8k mark of movies and then the sync will start from scratch upon reboot.

croneter commented 5 years ago

I found a solution: use xml.etree.cElementTree instead of xml.etree.ElementTree to avoid arena fragmentation. Hopefully, all you guys have a C-implementation of etree available for your Kodi machines... :grin: Commit: https://github.com/croneter/PlexKodiConnect/commit/c5741c7225860afb015aaff8eeff4b79d016c117

ghost commented 5 years ago

Fingers crossed! 2.5.0 out today? :)

croneter commented 5 years ago

Even now, though it's called 2.4.10 ;-)

Looking solved on my Raspberry Pi 3 :laughing:

croneter commented 5 years ago

@danjames92 Your library is so huge I now need to rewire the sync process... :-). Stay tuned

ghost commented 5 years ago

I try my hardest to make your project fun to work on... not inadvertent at all ;) Yep, I was just about to say it's still crashing with 2.4.10 on my Odroid C2, I see the ram usage increase until about 200MB free where it seems to freeze.

:)

milnash commented 5 years ago

Any progress here? Let me know if you want my server or if you want me to try anything.

croneter commented 5 years ago

I should be able to push a new beta version in the next few days. This is a GIANT rewrite....

ghost commented 5 years ago

@croneter eta wen son :)

i'm kidding

croneter commented 5 years ago

Please try the new PKC beta version 2.5.0. Problem solved?

ghost commented 5 years ago

Will wait for 2.5.10 for V18 Leia login fix. 👍

croneter commented 5 years ago

Huh? Try 2.5.1 now. Login Dialog as well as Choose Plex Home User dialogs should be fixed, if that's what you mean