HTML5 SetColor 'cross-origin' bug
Monkey Forums/Monkey Programming/HTML5 SetColor 'cross-origin' bug
| ||
| I was getting this error in Chrome (can't get Firefox to run from Monkey for some reason!), after using SetColor to draw rects followed by an image: Monkey Runtime Error : SecurityError: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': The canvas has been tainted by cross-origin data. D:/DevTools/Monkey/modules/mojo/graphics.monkey<461> D:/Development/Monkey/noise/noise.monkey<34> D:/DevTools/Monkey/modules/mojo/app.monkey<113> Example code:
Import mojo
#MOJO_IMAGE_FILTERING_ENABLED = False
Const STEPSIZE:Int = 8
Class NoiseMaker Extends App
Field loading:Image
Method OnCreate ()
loading = LoadImage ("loading.png")
SetUpdateRate 30
End
Method OnUpdate ()
End
Method OnRender ()
Cls
For Local y:Int = 0 Until 640 Step STEPSIZE
For Local x:Int = 0 Until 640 Step STEPSIZE
Local rgb:Int = Rnd (0, 256)
SetColor rgb, rgb, rgb
DrawRect x, y, STEPSIZE, STEPSIZE
Next
Next
' SetColor 255, 255, 255
DrawImage loading, 32, 32
End
End
Function Main ()
New NoiseMaker
End
I can *either* draw the rects *or* the image, but not both! However, if I then add a SetColor before drawing the image -- see commented-out line above -- it's fine. Wonder if that could be automated or otherwise detected and flagged on the HTML5 target... ? |
| ||
| I'd guess that you are loading the resulting html file into your browser directly rather than via a server. The security issues are why Monkey has a HTTP server for launching HTML5 builds. |
| ||
| Gah! You're right! Thanks -- I'd sort of forgotten about MServer, having had Chrome launching directly for many moons. Sorry, Mark, ignore... |