ctx: texture loading problem for <file>
$ convert -size 240x240 gradient: 0.png
$ convert -size 400x400 gradient:blue 1.png
$ mpremote fs cp 0.png :/sd/
$ mpremote fs cp 1.png :/sd/
# reboot Flow3r
$ mpremote run image_bug.py
- 3 working black/blue cycles
- afterwards: "texture loading problem for /sd/1.png"
- even when running image_bug.py again
As discussed in Matrix, it does not seem heap related, at least mem_info()
looks fine to me.
import gc
import micropython
import st3m.run
from st3m.application import Application, ApplicationContext
from st3m.input import InputState
from ctx import Context
class ImageBug(Application):
def __init__(self, app_ctx: ApplicationContext) -> None:
super().__init__(app_ctx)
self._timeout = 0
self._index = 0
def think(self, ins: InputState, delta_ms: int) -> None:
self._timeout += delta_ms
if self._timeout >= 2000:
gc.collect()
print(micropython.mem_info())
self._index = (self._index + 1) % 2
self._timeout = 0
def draw(self, ctx: Context) -> None:
ctx.image(f"/sd/{self._index}.png", -120, -120, 240, 240)
if __name__ == '__main__':
st3m.run.run_app(ImageBug)