NEEOInc / neeo-sdk

NEEO Brain SDK
https://neeoinc.github.io/neeo-sdk/
MIT License
49 stars 17 forks source link

Listview getter times out rather quickly. #88

Closed nklerk closed 6 years ago

nklerk commented 6 years ago

When I query kodi to provide me all movies or albums, the response time can take a while. The listview will timeout and while the promise is still active. I’m not certain wether this is a bug or a feature, lol

MichaelKohler commented 6 years ago

We are supporting pagination, I'm not sure if Kodi does as well though. If Kodi supports pagination, you could check for the "offset" provided to the browse callback and only return the elements from that index on. The max limit is 64 for one page. When the user scrolls down, the next page would be requested from the driver. I think loading 64 entries should be within the timeout.

neophob commented 6 years ago

@nklerk do you use pagination when you query Kodi? (see https://kodi.wiki/view/JSON-RPC_API/v6#List.Limits) - if not this should speed up the query time quite alot.

if you already use pagination, what's does "the response time can take a while" mean in milliseconds?

nklerk commented 6 years ago

I currently query every item for a specific item type. I know that a offset is possible I’ll see if I can implement it.

nklerk commented 6 years ago

The solution now grabs all data in background so there are no loading times.

neophob commented 6 years ago

You could use the promisecache helper in the SDK aswell. The idea there is, that it would fetch the movie list and cache it for a certain amount of time. if kodi supports an event that tells you that the list is updated, you could invalidate that list. the you wouln't need to constantly fetch the movie list (which cost resources which might be obsolete in most cases anyway)

nklerk commented 6 years ago

I have just implemented full pagination. @ https://github.com/nklerk/neeo_driver-kodi/tree/next Thanks for the advice!

neophob commented 6 years ago

@nklerk I'll close, feel free to reopen if this is not solved

tmrobert8 commented 6 years ago

@neophob Too funny - just found a bug in this and I can't seem to reopen this ticket - so I'll let you do it! Basically if the limit is too low - the paging stops working.

How to recreate Open up the file browser code - set the limit to 5. Run the example and you'll see that it will never page

tmrobert8 commented 6 years ago

Actually - the paging is very weird at lower settings. If you set it at 10, you'll see it requests 3 at a time (offsets += 3 on each request) and paging backwards seems to always request offset=0 again.

MichaelKohler commented 6 years ago

@tmrobert8 I'm gonna have a quick look at this tomorrow. Is this happening on the remote as well?

On the app, we only load the next page if we're 20% from the bottom of the screen, and of course with 5 elements that won't be the case. Will definitely need to rethink this. For the remote this should work, would need to verify it though.

tmrobert8 commented 6 years ago

TR2 is where I was trying stuff - so yes on the remote

MichaelKohler commented 6 years ago

@tmrobert8 I could reproduce this, we will quickly discuss this internally and then report back here what we think of that. Good catch!

MichaelKohler commented 6 years ago

I'm gonna work on a fix for this.

nklerk commented 6 years ago

0.o

pfiaux commented 6 years ago

We have a fix in our pipeline, it will be available in a future firmware version along with other list improvements.