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

Fix sporadic crash on home screen #1645

Merged
merged 1 commit into from
Jan 14, 2024
Merged

Conversation

cewert
Copy link
Member

@cewert cewert commented Jan 13, 2024

The crash in #1642 should never happen in theory because we are setting the global constants super early in the app. This PR should fix the crash by setting a default backdrop color value and overwriting it with a random value like before but only if the global var is valid.

Issues

Fixes #1642

@cewert cewert added the bug-fix This fixes a bug. label Jan 13, 2024
@cewert cewert requested a review from a team as a code owner January 13, 2024 02:03
backdropColor = "#00a4db" ' set default in case global var is invalid
localGlobal = m.global

if isValid(localGlobal) and isValid(localGlobal.constants) and isValid(localGlobal.constants.poster_bg_pallet)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're using an index value to directly access the poster_bg_pallet array, we should use isValidAndNotEmpty() on it here to ensure it has values.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll update this but I don't think it's possible for the array to be valid and empty

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some testing on this. An empty array will evaluate as valid.

test = []
print isValid(test)

Output will be true

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with what you're saying in general but I don't think it's possible for this specific array to ever be valid and empty. It's assigned a value when it's created (the 3rd line of actual code in main) and we never modify these values because they are constants. So why would it be empty?

Copy link
Member

@1hitsong 1hitsong Jan 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So why would it be empty?

The same reason why the global variables that we know are set before this code hits are getting flagged as inValid - because Brightscript defies reason 😆

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have trust issues with brightscript too but the more I think about this the more I think we should leave it as it is and only make your change as needed if it shows up in the crash log. This node is used for every media item on the home screen so there could be dozens or hundreds of these HomeItems on the screen and for each one we'd need to check if the global constant array is empty in addition to all the extra validation that was added in this PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point. It would be a good refactoring to instead pass the background color to the homeitem on generation and do the valid check on the global values in the parent element. That way we reduce the number of checks we perform on global.

@cewert cewert linked an issue Jan 13, 2024 that may be closed by this pull request
Copy link
Member

@1hitsong 1hitsong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved as-is, but make note a good follow up would be for us to test the m.global variable before the home items are generated and pass the chosen backdropcolor into it. That could potentially save us tons of condition checks.

However, it will require a refactoring to make it happen.

@cewert cewert merged commit 5be021e into jellyfin:2.0.z Jan 14, 2024
13 checks passed
@cewert cewert deleted the fix-homeitem-crash branch January 14, 2024 00:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-fix This fixes a bug.
Projects
Development

Successfully merging this pull request may close these issues.

roku crash log - HomeItem.brs(23)
2 participants