webcanvas not drawing a picture

I’ve got a webcanvas that I want to fill with black and then center a picture on it. The black fill is working fine, but the picture won’t show up. Looking at everything in the debugger, the picture is there and the x,y starting point is where I expect them to be. But, I just get a black screen when the canvas draws. Anything seem obviously wrong to anyone?

[code]Sub Paint(g as WebGraphics)
dim p as Picture
dim x, y as integer

g.ForeColor = session.curr_bg_color

g.FillRect(0, 0, g.Width, g.Height) '<-- black background works fine

p = session.pic_buffer(session.curr_page_index)

if p = nil then

p = picture.open(session.pages(session.curr_page_index).Right)
Session.pic_buffer(Session.curr_page_index) = p

end if

p = p.ResizeToFit(me.Width, me.Height)

if p.Height = me.Height then
y = 0
else
y = (me.Height / 2) - (p.Height / 2)
end if

if p.width = me.width then
x = 0
else
x = (me.width / 2) - (p.width / 2)
end if

g.DrawPicture(p, x, y) '<— in the debugger, the picture appears correctly in p, and x and y are the expected values

End Sub
[/code]

And if I had only searched deeper here i would have found https://forum.xojo.com/11099-webcanvas-and-pictures/p1#p80147 which helpfully points out not to create picture in the paint event.