-
Notifications
You must be signed in to change notification settings - Fork 47
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
Cached KeyImages cannot be stored #59
Comments
Can you post some soft of reproducible example (maybe a little one-file console application?) |
I don't have minimal example, but you can reproduce the issue in the following way:
public override void UpdateVisuals(List<KeyboardElementVisuals> buttons, List<KeyboardElementVisuals> encoders)
{
if (deck == null)
return;
if (sleep)
{
deck.SetBrightness(brightness);
sleep = false;
}
// Prepare images to display
for (int i = 0; i < buttons.Count; i++)
{
deck.SetKeyBitmap(i, buttons[i].CustomCache as KeyBitmap);
}
} The last line is the place where buttons are set from local (application) cache.
|
I know the project is moderately big, but there are only two files you may be interested in, related to the issue.
|
I haven't had time to try it with my stream deck v2 but I read a bit through the code and I'm pretty sure that you pass something that's actually // if buttons[i].CustomCache is not a KeyBitmap or null than this will throw!
deck.SetKeyBitmap(i, buttons[i].CustomCache as KeyBitmap);
I actually stopped at that point because there are so many possibilities where this value could end up being null. My guess is that something inside your caching code doesn't work as expected/intended and leads to null values inside // Note: just typed this in GitHub and have not compiled/tested it.
// Prepare images to display
for (int i = 0; i < buttons.Count; i++)
{
if (buttons[i].CustomCache is KeyBitmap kb)
{
deck.SetKeyBitmap(i, kb);
}
else
{
// CustomCache was null or not of type KeyBitmap
// throw Exception here or set break-point to diagnose the issue
// or log the error event
// or fall back to a different (known) KeyBitmap that is actually non-null
}
} On the long run you should try to be way stricter with all of your types. There should be very good reasons to use |
I created and stored a number of
KeyImage
images to improve performance during switching screens. However, during using such images, I ran into an exception:Workaround: Disable caching when creating Stream Deck device instance. Also. don't store
KeyBitmap
s, create them every time they are needed.The text was updated successfully, but these errors were encountered: