ozRocker Posted May 18, 2016 Share Posted May 18, 2016 I sometimes get a javascript error on my site http://www.punkoffice.com/webiverse while the skybox is loading at the first page. It only happens on my iPhone, but like 1 out of 7 times. When the error happens the skybox fails to load and the sky is just black. I'm loading my scene. When it loads I'll add a light, camera, ground then skybox, one after the other. Everything else comes out fine. At this stage there's no asynchronous calls going on so this shouldn't be caused by a race condition in my code. The error I get is: TypeError: undefined is not an object (evaluating 't[c].width') (anonymous function) babylon.2.4.js:3:29698 a babylon.2.4.js:2:26402 onload babylon.2.4.js:2:6865 My skybox code is: private static setupSkyBox() { var skybox = BABYLON.Mesh.CreateBox("skyBox", 700.0, this.scene); var skyboxMaterial = new BABYLON.StandardMaterial("skyBox", this.scene); skyboxMaterial.backFaceCulling = false; skyboxMaterial.reflectionTexture = new BABYLON.CubeTexture("images/skybox/plainsky", this.scene); skyboxMaterial.reflectionTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE; skyboxMaterial.diffuseColor = new BABYLON.Color3(0, 0, 0); skyboxMaterial.specularColor = new BABYLON.Color3(0, 0, 0); skybox.material = skyboxMaterial; Tools.debug(1,"Skybox"); } Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted May 18, 2016 Share Posted May 18, 2016 do you mind doing the same test with babylon.max.js? Quote Link to comment Share on other sites More sharing options...
ozRocker Posted May 19, 2016 Author Share Posted May 19, 2016 19 hours ago, Deltakosh said: do you mind doing the same test with babylon.max.js? ok, here is the error in reference to the babylon.max.js file: TypeError: undefined is not an object (evaluating 'imgs[index].width') babylon.2.4.max.js:7063:88 (anonymous function) babylon.2.4.max.js:7062:87 onload babylon.2.4.max.js:5536 onload babylon.2.4.max.js:4491 possibly a race condition in there which only gets triggered on mobile devices? cos it looks like the imgs haven't loaded yet. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted May 19, 2016 Share Posted May 19, 2016 Hard to debug do you mind sharing a page with .max.js so I can have a look? Quote Link to comment Share on other sites More sharing options...
ozRocker Posted May 20, 2016 Author Share Posted May 20, 2016 Its in Engine.prototype.createCubeTexture this code here: for (var index = 0; index < faces.length; index++) { _this._workingContext.drawImage(imgs[index], 0, 0, imgs[index].width, imgs[index].height, 0, 0, width, height); gl.texImage2D(faces[index], 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, _this._workingCanvas); } The error happens when it first tries to access imgs[index].width because imgs is undefined at that time. Note that this problem doesn't happen all the time. Maybe 1 out of 10 times on mobile devices. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted May 20, 2016 Share Posted May 20, 2016 The thing is that this code is inside the img.onload Quote Link to comment Share on other sites More sharing options...
ozRocker Posted May 20, 2016 Author Share Posted May 20, 2016 15 minutes ago, Deltakosh said: The thing is that this code is inside the img.onload Do you think its the mobile browser that's causing the problem? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted May 20, 2016 Share Posted May 20, 2016 I'm pretty sure it is...seems like Safari calls OnLoad before data is completely parsed Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.