Black Lives Matter - Action and Equality.
0

Overlapping OnDiskBitmap screen updates and file IO?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Overlapping OnDiskBitmap screen updates and file IO?

by kevinjwalters on Sat May 09, 2020 7:01 pm

From the 5.x release notes including 5.3.0:

displayio operations that read from an SD card (e.g., OnDiskBitmap) will interfere with other SD card operations and can cause lockup. To work around this problem, do not read or write files on the SD while the display is updating, and vice versa.


Does this mean that nothing can be changed on the screen when SD card access is taking place? Is there a small risk with automatic refreshes with code that does

  1. Slap an image on screen
  2. Open another file and read it

could still cause a problem because the actual writes to the screen may occur between statements in 2? Is that low risk or should there be a forced screen refresh after 1 to ensure all changes are flushed to it or a disable of automatic refreshes?

kevinjwalters
 
Posts: 576
Joined: Sun Oct 01, 2017 3:15 pm

Re: Overlapping OnDiskBitmap screen updates and file IO?

by siddacious on Mon May 11, 2020 2:26 pm

I'll ping someone who can help.

siddacious
 
Posts: 246
Joined: Fri Apr 21, 2017 3:09 pm

Re: Overlapping OnDiskBitmap screen updates and file IO?

by jepler on Mon May 11, 2020 3:29 pm

Right, when you are going to read (or write!) a file on SD you need to make sure that background tasks are guaranteed not to also try to read from the SD.

The way I do that in JEplayer is by setting the auto_refresh flag to false while doing file I/O, and back to true when done.

This mostly affects displayio but can also affect mp3 file playback from the SD card; it's just that fewer people are doing the latter yet.

If you have any additional findings about this, you can add them to the issue: https://github.com/adafruit/circuitpython/issues/2417 including if you have ideas for refining the text in the release notes so that it is clearer.

It may be the case that sdcard in core C code will fix this, but I haven't tested it yet. https://github.com/adafruit/circuitpython/pull/2863 Again, feel free to add any findings to that PR if you check it out.

jepler
 
Posts: 23
Joined: Mon Oct 28, 2013 4:16 pm

Please be positive and constructive with your questions and comments.