Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@ladyada
Resolves: #150
I believe the root cause of the issue is the refresh thread running on it's own cycle in the background while the user code is manipulating Groups, TileGrids, Bitmaps etc. which cause refresh to be needed. I think there is a period of time during the refresh process after
_get_refresh_areas()
has been called for a given object, and before_finish_refresh()
gets called for that same object. During that window of time if the user code manipulates the object making it need to be re-drawn it won't actually get drawn because_finish_refresh()
gets called first which makes the next call to_get_refresh_areas()
not return any areas to draw because_finish_refresh()
clears / resets the dirty area to empty.This change resolves it by adding a
_needs_refresh
bool that gets set to True whenever any change that triggers a refresh occurs. Then inside_finish_refresh()
we only do the finish logic when that bool is False. The bool is flopped to False in_get_refresh_areas()
once we know that our triggered refresh is in process.I tested this fix successfully with the reproducer from the issue.
Unrelated to the issue above, I also removed a duplicated
_finish_refresh()
function inside of Bitmap. The remaining function is here: https://github.com/adafruit/Adafruit_Blinka_Displayio/blob/main/displayio/_bitmap.py#L294