Monday, March 4, 2013

Re: SuperDevMode and same origin policy

On Sunday, March 3, 2013 10:52:29 PM UTC+1, Harold wrote:
Hi all,

I am using super dev mode and i have an issue, i think,, with same origin policy.

I have a ClientBundle containing many ImageResource which will be used as WebGL textures.

To load those images i do :

Image image = new Image(myImageResource.getSafeUri().asString();

Don't do that. Use new Image(myImageResource), or use a DataResource.
 
RootLayoutPanel.get().add(image);
image.setVisible(false);
this.img.addLoadHandler(this);
this.img.addErrorHandler(this);

where this is a class implenting LoadHandler and ErrorHandler.

Then in the onLoad method :

this.InitializeTexture(this.img.getElement());
RootLayoutPanel.get().remove(this.img);

And finally the InitializeTexture :

/**
* \brief Initializes the gl texture with the loaded image.
*/
public void InitializeTexture(Element inElement)
{
        // Set current texture object as active
this.Bind(WebGLRenderingContext.TEXTURE_2D);
// If generating mipmap is requested, parameter the texture filtering to using them and generate mipmaps ...
if(this.generateMipmap)
{
this.gl.texParameteri(WebGLRenderingContext.TEXTURE_2D, WebGLRenderingContext.TEXTURE_MAG_FILTER, WebGLRenderingContext.LINEAR);
this.gl.texParameteri(WebGLRenderingContext.TEXTURE_2D, WebGLRenderingContext.TEXTURE_MIN_FILTER, WebGLRenderingContext.LINEAR_MIPMAP_NEAREST);
this.gl.generateMipmap(WebGLRenderingContext.TEXTURE_2D);
}
else // else do not use mipmap
{
this.gl.texParameteri(WebGLRenderingContext.TEXTURE_2D, WebGLRenderingContext.TEXTURE_MAG_FILTER, WebGLRenderingContext.LINEAR);
this.gl.texParameteri(WebGLRenderingContext.TEXTURE_2D, WebGLRenderingContext.TEXTURE_MIN_FILTER, WebGLRenderingContext.LINEAR);
}
this.gl.texParameteri(WebGLRenderingContext.TEXTURE_2D, WebGLRenderingContext.TEXTURE_WRAP_S, WebGLRenderingContext.CLAMP_TO_EDGE);
this.gl.texParameteri(WebGLRenderingContext.TEXTURE_2D, WebGLRenderingContext.TEXTURE_WRAP_T, WebGLRenderingContext.CLAMP_TO_EDGE);
// And finaly, set the image pixels data in the texture object.
this.gl.texImage2D(WebGLRenderingContext.TEXTURE_2D, 0, WebGLRenderingContext.RGBA, WebGLRenderingContext.RGBA, WebGLRenderingContext.UNSIGNED_BYTE, inElement);
// Finaly unbind the texture object
this.Unbind(WebGLRenderingContext.TEXTURE_2D);
}

All is ok in production mode but when i use superdevmode i get under chrome and firefox a security error while calling texImage2D method.

Do you think that is a SOP issue ?

See http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#security-with-canvas-elements
Though SuperDevMode sends "Access-Control-Allow-Origin: *" so it should work…
 

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment