Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

RPi Zero: Crash issue in displayio
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

RPi Zero: Crash issue in displayio

by ronfischler on Sat Aug 15, 2020 3:01 am

This crash happens soon after I have attempted to update the text in a text area previously created by label.Label(). My text area was previously appended to a text group. Periodically I update this text, destined for my attached 2" TFT display, with something that looks like this:
text_group[0].text = "Foobar..."

This works most of the time, but it appears this displayio code is running in a separate thread from my code, and there is a race condition. If the displayio thread loses the race, it crashes with the following traceback:

Exception in thread Thread-1:
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/home/pi/.local/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/home/pi/.local/lib/python3.8/site-packages/displayio/display.py", line 248, in _refresh_loop
self.refresh()
File "/home/pi/.local/lib/python3.8/site-packages/displayio/display.py", line 235, in refresh
self._current_group._fill_area(buffer) # pylint: disable=protected-access
File "/home/pi/.local/lib/python3.8/site-packages/displayio/group.py", line 160, in _fill_area
layer._fill_area(buffer) # pylint: disable=protected-access
File "/home/pi/.local/lib/python3.8/site-packages/displayio/group.py", line 160, in _fill_area
layer._fill_area(buffer) # pylint: disable=protected-access
File "/home/pi/.local/lib/python3.8/site-packages/displayio/group.py", line 160, in _fill_area
layer._fill_area(buffer) # pylint: disable=protected-access
File "/home/pi/.local/lib/python3.8/site-packages/displayio/tilegrid.py", line 269, in _fill_area
if self._absolute_transform.mirror_x:
AttributeError: 'NoneType' object has no attribute 'mirror_x'


Whenever this happens, it errors off at the same point every time. I assume this happens when I am updating the text area again and displayio has not finished completing the last update I had made? Is there a way for me to somehow check if the displayio code is finished or not, before I attempt another update to my text area?

I looked at the code in tilegrid.py, and before attempting to manipulate the mirror_x attribute, there is a check for NoneType first, but the object must have changed after the check, but preceeding the use of the mirror_x attribute. Is there a way to make this atomic?

ronfischler
 
Posts: 27
Joined: Thu Jul 23, 2020 3:15 pm

Re: RPi Zero: Crash issue in displayio

by MakerMelissa on Tue Aug 18, 2020 1:51 pm

Hi, it looks like you discovered a bug. Thanks for letting us know. I have created a new issue at https://github.com/adafruit/Adafruit_Bl ... /issues/39.

MakerMelissa
 
Posts: 176
Joined: Wed Jun 05, 2013 2:10 am

Re: RPi Zero: Crash issue in displayio

by ronfischler on Tue Aug 18, 2020 2:03 pm

MakerMelissa wrote:Hi, it looks like you discovered a bug. Thanks for letting us know. I have created a new issue at https://github.com/adafruit/Adafruit_Bl ... /issues/39.


Thank you very much for the response! I look forward to the fix. I note that I never saw this behavior occur when running my code on the Feather M4, only on my RPi Zero. Thank you again.

ronfischler
 
Posts: 27
Joined: Thu Jul 23, 2020 3:15 pm

Re: RPi Zero: Crash issue in displayio

by MakerMelissa on Tue Aug 18, 2020 2:43 pm

I have just pushed an update that should help this. It should be available on PyPI soon. You can update with the following command:

Code: Select all | TOGGLE FULL SIZE
pip3 install --upgrade adafruit-blinka-displayio

MakerMelissa
 
Posts: 176
Joined: Wed Jun 05, 2013 2:10 am

Re: RPi Zero: Crash issue in displayio

by ronfischler on Tue Aug 18, 2020 6:36 pm

I updated my RPi Zero to use adafruit-blinka-displayio-0.5.3 and so far, it is working great! I will do considerably more testing tonight, but out of the gate, it looks good. Thank you MakerMelissa.

ronfischler
 
Posts: 27
Joined: Thu Jul 23, 2020 3:15 pm

Re: RPi Zero: Crash issue in displayio

by ronfischler on Wed Aug 19, 2020 12:22 pm

I have been running the update to displayio since yesterday, and the crash in tilegrid.py is gone. My code and displayio appear to run asynchronously now, without issue. Thanks again for fixing this.

ronfischler
 
Posts: 27
Joined: Thu Jul 23, 2020 3:15 pm

Re: RPi Zero: Crash issue in displayio

by MakerMelissa on Wed Aug 19, 2020 12:24 pm

Excellent news. Thanks for letting us know.

MakerMelissa
 
Posts: 176
Joined: Wed Jun 05, 2013 2:10 am

Please be positive and constructive with your questions and comments.