ipycanvas icon indicating copy to clipboard operation
ipycanvas copied to clipboard

Race condition in Pattern creation from Image widget

Open martinRenou opened this issue 4 years ago • 1 comments

There is a race condition in the Pattern object creation from an Image widget.

Setting fill_style = pattern just after creating the pattern results in the fill_style to not be properly set. This seems to happen a lot more in JupyterLab than Jupyter Notebook.

We can fix it by making the style set async.

martinRenou avatar Dec 27 '20 10:12 martinRenou

For reproducing this:

from ipywidgets import Image

from ipycanvas import Canvas, hold_canvas

import urllib.request

urllib.request.urlretrieve('https://github.com/martinRenou/ipycanvas/raw/master/examples/sprites/smoke_texture0.png', 'smoke_texture0.png')

sprite = Image.from_file('smoke_texture0.png')

canvas = Canvas(width=200, height=200)

pattern = canvas.create_pattern(sprite)

canvas.fill_style = pattern
canvas.fill_rect(0, 0, canvas.width, canvas.height)

canvas

martinRenou avatar May 03 '22 06:05 martinRenou