ljunkie / rarflix

Plex Roku Channel - original source from https://github.com/plexinc/roku-client-public
MIT License
117 stars 45 forks source link

Brightscript Debugger exception after PMS outages #211

Closed sa2000a closed 10 years ago

sa2000a commented 10 years ago

RARflix Dev 3.1.20 on NowTV and on Roku 2XS Has been running for over 24 hours - slideshow of 28453 shuffled and about half way through

Was playing with some debug tools on PMS that led to repeated server crashes over a period of about an hour : 21:40 to 22:40 15th February in the logs

Outcome: Roku 2XS RARflix survived this and continued with the slideshow NowTV RARflix re fetched images 3000 at a time getting error responses but appears to have managed to get 9000 out of the 28453 items, and embraked on reshuffling

It got exception, Array index might be wrong generalUtils.brs(592) swaparray function

Console Log will be emailed

ljunkie commented 10 years ago

sent via email: pasting here to to track..

Perfect. I see the issue and I will figure out the right way to fix this later when I have more time to analyze what exactly happened.. but this is the basic reason for the crash.

First of all, it tried to reload the context because the image it tried to get failed twice. A reload will only happen once very 5 minutes, so this is normal and expected.

So here were are starting the reload:

1) Had: 28435 items

2) requesting a new reload.. in chunks of 3k

3) Now Have: 9000 items ( only the first 3 request to the PMS were successful, then the PMS died..)

4) 15/2/14 22:43:31 : slideshow was shuffled - we need to reshuffle due to new context -- so it's trying to reshuffle the new items...

Here's where it gets interesting...

Variables: arr &h4010 bsc:roArray, refcnt=4 i &h0002 Integer val:0 j &h4002 Integer (2.1 was roInteger) val:14575

Either way, this all does make 99% perfect sense and I can add a fix to handle this issue.

ljunkie commented 10 years ago

Yep, all makes sense after looking at the code. It's possible the current index we are viewing is greater than items after the reload. This is fine if we are not shuffling as it will just move to index 0 on next, but the shuffle is very unhappy about that. Easy enough, reset the CurIndex back to zero if the CurIndex > num of items in array ( -1 due to zero index )

- ShuffleArray(m.Context, m.CurIndex)
+ if m.CurIndex > m.Context.count()-1 then m.CurIndex = 0
+ ShuffleArray(m.Context, m.CurIndex)
ljunkie commented 10 years ago

fixed d4c401e50679ca8a0cfbbf6ee1fa04847bed1dea

new zip: https://github.com/ljunkie/rarflix/raw/dev/RARflixDev-3.1.23.zip

ps. using the actual DEV branch now if you haven't noticed.