Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autoScrollToBestProgramme/focusCurrentProgram don't always focus correctly on the corrent program #64

Open
jleahy2 opened this issue Mar 2, 2024 · 9 comments

Comments

@jleahy2
Copy link

jleahy2 commented Mar 2, 2024

I have noticed that autoScrollToBestProgramme doesn't always seem to focus on the correct item for some reason. There are 2 things going on in there: jumpTo() and focusCurrentProgram().

I've tried to dig into this a bit, and jumpTo() seems to always work correctly. No matter where I am, It always scrolls the view to the correct area with the current program. However, focusCurrentProgram() does not seem to be working correctly for some reason.

Sometimes it does focus on the current program for the selected channel as it should, however it often it doesn't, highlighting something in front of it.

I've noticed that it seems to work much better if you are viewing older program data behind the current time. Every time I've tried this, autoScrollToBestProgramme() will scroll forward and correctly focus on the current program. The problem seems to be when you're looking at programs in the future that are beyond the current time.

A lot of the time when I try to run autoScrollToBestProgramme() when I've moved into the future, jumpTo() gets called and it scrolls the grid back properly, however focusCurrentProgram() often fails to correctly bring focus to the actual correct current program for that channel.

I've noticed in the log that it will say "Scrolling to PROGRAMNAME, started at 1709931600000", so it's definitely finding the correct program, but the focus sometimes either doesn't change at all, or it moves to the wrong program that is not currently playing.

The issue seems most likely to show up when you are trying to autoScrollToBestProgramme for a specific channel that you're already on. Say if you're on index 5 of the channels, and you scroll to the right past the current time and then try to autoScrollToBestProgramme back to the same channel you're on, it has a high probability of happening, but sometimes (although seldomly) it does get it right.

I've tried unsuccessfully to fix this.

@jleahy2 jleahy2 changed the title Help Adding Support For Channel Categories Slide Out Help getting gaps to be clickable Mar 3, 2024
@jleahy2 jleahy2 changed the title Help getting gaps to be clickable - Mar 7, 2024
@jleahy2 jleahy2 changed the title - autoScrollToBestProgramme/focusCurrentProgram don't always focus correctly on the corrent program Mar 8, 2024
@dzolnai
Copy link
Member

dzolnai commented Aug 9, 2024

@jleahy2 sorry for my late reply. Are you calling autoScrollToBestProgramme yourself (like automatically), or are you using a button for it? Is it being called while the grid has still focus?

@jleahy2
Copy link
Author

jleahy2 commented Aug 9, 2024

Thanks for your reply @dzolnai.

I am trying to hook it to the 'escape/back' button on my android tv remote so that it brings me back to the current program when I go to view a program in the future on the current channel, but want to go back to the one that's currently playing.

For instance, I want to see what's on this channel that's playing 3 hours from now on, I scroll to the right, and then I want to be able to press the back/escape key to automatically bring the focus/jump back to the current time.

Well, jumpTo() works great. It always (every single time) brings the page back to the currently active program. But, for whatever reason, I can not get it to always bring the focus back to the correct program. But, yeah for some reason, the app knows what program it needs to set focus to as I can see it in the log and I've verified that it is the correct one, but often times it just will not highlight the correct one.

It jumps back to the correct page, but it often is selecting another program after the one it should be for some reason.

Sometimes (albeit rarely) it does set the focus correctly, but I can't seem to get it to work perfectly. I don't know if it's a race condition between the autoselect and jumpto?

I have managed to kind of work around this by basically throwing the autoselect into a loop where it checks to see if it actually did focus on the correct item, but ... obviously this is not ideal. It's a hacky work around and while it "works" it is buggy and you can definitely see it iterating through the loop while trying to find the correct one. So, it's not a very good solution. I'm hoping for a proper one.


Ultimately, what I am really trying to do is to find a way to automatically keep the left most program be the one that's always currently playing. Meaning, I need to somehow find a way to automatically purge old programs say, every 30 minutes, but keeping all the currently playing/future programs. That way, old programs would be completely removed, the left most items on every channel would always be the currently playing - and then, I would just need to somehow make a hook to just somehow automatically scroll back to the left most program (which would always be the currently playing one) when I press escape/back. I haven't had any success with this yet.

Thanks for any help/advice/insight :) I greatly appreciate it!

@dzolnai
Copy link
Member

dzolnai commented Aug 12, 2024

I am also suspecting a race condition, or something 'steals' the focus from the correct program. If you can make a reproduction case in the demo project, I can take a look at it.

@jleahy2
Copy link
Author

jleahy2 commented Aug 12, 2024

I am also suspecting a race condition, or something 'steals' the focus from the correct program. If you can make a reproduction case in the demo project, I can take a look at it.

Wow, thank you! I will pull down the demo project again, and try to make an example case to show you here this week.

@jleahy2
Copy link
Author

jleahy2 commented Aug 12, 2024

I am also suspecting a race condition, or something 'steals' the focus from the correct program. If you can make a reproduction case in the demo project, I can take a look at it.

I actually discovered today the problem exists in the example demo project, so I made a video to help show what I'm talking about:

https://www.youtube.com/watch?v=SeqJk6p-Ja4

The video shows 2 questions:

1 - the main issue related to the focus not always selecting the correct program

2 - a question I have trying to make this more mobile friendly (trying to disable individual channel scrolling)

Thanks again for your time and help!

@dzolnai
Copy link
Member

dzolnai commented Aug 13, 2024

Thank you, I can see it clearly happening now. Didn't think of using the mouse while navigating with arrows :)
Anyways, this is an edge case where the grid is scrolling while it has focus. My recommendation is, to disable the focus while that is happening, and just putting focus back on the grid when it is settled.
I fixed that for the jump to now button, but I assume you need to set the isJumpingGridInTime flag to true in your case as well.
See my latest commit on the master branch for the fix.

@jleahy2
Copy link
Author

jleahy2 commented Aug 13, 2024

Thank you, I can see it clearly happening now. Didn't think of using the mouse while navigating with arrows :) Anyways, this is an edge case where the grid is scrolling while it has focus. My recommendation is, to disable the focus while that is happening, and just putting focus back on the grid when it is settled. I fixed that for the jump to now button, but I assume you need to set the isJumpingGridInTime flag to true in your case as well. See my latest commit on the master branch for the fix.

Wow that's fantastic! I just tried the new code, that fixed it, thank you so much! :)

Do you happen to have any ideas how the second problem I am encountering can be solved by chance? I showed it at the end of the video I posted. When I run the demo application on my tablet, the individual channels scroll when scrolling your finger on any channel/prgram.

I would like to find a way to keep the individual channels from scrolling, and instead of them all scroll together like they do using the keyboard/remote, but still allow the individual programs to be tapped to focus them?

@dzolnai
Copy link
Member

dzolnai commented Aug 15, 2024

I just pushed an extra commit where fix this edge case. See the commit and the documentation of the feature flag (turned off by default). I think this should solve the last of your issues.

@jleahy2
Copy link
Author

jleahy2 commented Aug 16, 2024

I just pushed an extra commit where fix this edge case. See the commit and the documentation of the feature flag (turned off by default). I think this should solve the last of your issues.

Thank you for this! I think we are closer - it is kind of working, but I am still experiencing quite a few bugs with how it works. I made a video to show it. I tried it on the tablet and also on the computer, and the same issues occur on both:

https://www.youtube.com/watch?v=5_uzmLh33Jk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants