Jump to content

Background color of stage not working in chrome for android


Xoriff
 Share

Recommended Posts

Hi, I've started using Pixi for a little project that I'm working on and so far I'm liking it.

 

But when I tried opening it up in my Galaxy Nexus' browser (I'm using chrome), the stages background color doesn't seem to come through.

 

I've created a jsfiddle that demonstrates the problem here: http://jsfiddle.net/PeA8j/1/

 

On my desktops browser and the stock android browser the result window shows a small green stage.  But in chrome on my phone it shows nothing.  If I add sprites to the stage it shows those.  Just not the background color.  Any ideas?

Link to comment
Share on other sites

Hmmm, searching as you suggested, the best likely hit was this: http://www.html5gamedevs.com/topic/114-canvasclearrect-bug-in-android-stock-browser/

 

But that seems to indicate that the problem is with the stock android browser.  But in the stock browser, it works just fine, only in the android chrome app does it not set the background color.

 

I'm running cyanogenmod 10.1.3-toro (android 4.2.2).

Link to comment
Share on other sites

Ok.  Did some more sleuthing.  I mimicked what Pixi does in PIXI.CanvasRenderer.prototype.render to set the backgroundColor style on the canvas element and it works correctly.

 

Furthermore, it seems like it works when I do this through Pixi so long as I comment out the three lines that follow this backgroundColor style setting.

i.e. 

this.context.setTransform(1,0,0,1,0,0); this.context.clearRect(0, 0, this.width, this.height)this.renderDisplayObject(stage);
 
I don't know what it is about what these three lines are doing, but when any of them run, it clears the background color in chrome on my android. 
 
I've confirmed that this issue is specific to android chrome.  This fiddle demonstrates the issue: http://jsfiddle.net/QnFH3/2/
 
Apparently in nearly all browsers, messing with a canvases context does not cause that canvas to ignore it's backgroundColor style.  But in android+chrome, doing anything with the context for the canvas makes chrome abandon it's backgroundColor property.  Not sure how this could be gotten around.
Link to comment
Share on other sites

Yup, setting the background color of the container div made it such that messing with the canvases context did not cancel out the background color.

 

So, I guess a fix to this could be for pixi to insert a div-nested canvas instead of a naked canvas and use that outer div for styling and such.  Though I have no idea how much work that would entail or if it's even possible.

 

In the mean time I'll just do this manually for my current project.

 

Thanks for the help.

Link to comment
Share on other sites

Yup, setting the background color of the container div made it such that messing with the canvases context did not cancel out the background color.

 

So, I guess a fix to this could be for pixi to insert a div-nested canvas instead of a naked canvas and use that outer div for styling and such.  Though I have no idea how much work that would entail or if it's even possible.

 

In the mean time I'll just do this manually for my current project.

 

Thanks for the help.

 

This is not something we will do in PIXI, but it is pretty easy to do yourself outside the library.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...