From: Joe Wreschnig Date: Wed, 17 Sep 2014 21:34:13 +0000 (+0200) Subject: Disable DPR > 1 on Safari due to bugs and performance issues. X-Git-Url: https://git.yukkurigames.com/?p=pwl6.git;a=commitdiff_plain;h=0fcb2653386058a7206bb31920834f66fabf3e4e;ds=sidebyside Disable DPR > 1 on Safari due to bugs and performance issues. --- diff --git a/src/yuu/core.js b/src/yuu/core.js index cbeb2a0..24e3f2b 100644 --- a/src/yuu/core.js +++ b/src/yuu/core.js @@ -7,6 +7,9 @@ (function (yuu) { "use strict"; + yuu.isSafari = function (ua) { + return /^((?!chrome).)*safari/i.test(ua || navigator.userAgent); + }; yuu.require = function (m) { try { return require(m); } diff --git a/src/yuu/gfx.js b/src/yuu/gfx.js index 2c3088e..3765aaa 100644 --- a/src/yuu/gfx.js +++ b/src/yuu/gfx.js @@ -12,7 +12,22 @@ var gl; var canvas; - var dpr = yuu.DPR = this.devicePixelRatio || 1; + // Safari on OS X has issues with DPR != 1 where the backbuffer + // scales down, then back up. I'm pretty sure this is not a + // problem with this code, because I see similar artifacting on + // most demos, e.g. + // https://www.khronos.org/registry/webgl/sdk/demos/google/shiny-teapot/index.html + // + // With DPR = 1 this presumably still happens but the negative + // effect is lessened. + // + // Safari on iOS does _not_ have this problem (another reason why + // I suspect it's a bug in Safari and not this code), but reducing + // fragment count by 75% is generally a good idea on these devices + // anyway. + var dpr = yuu.DPR = !yuu.isSafari() + ? (this.devicePixelRatio || 1) + : 1; yT.defineProperty(Int8Array.prototype, "GL_TYPE", 0x1400); yT.defineProperty(Uint8Array.prototype, "GL_TYPE", 0x1401);