Skip to content

Commit 74b2a21

Browse files
authored
Remove iOS 10 specific HLS workaround (#5450)
Co-authored-by: Noeri Huisman <[email protected]>
1 parent edea854 commit 74b2a21

File tree

7 files changed

+0
-175
lines changed

7 files changed

+0
-175
lines changed

src/shaders/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ require('./standard');
33
require('./phong');
44
require('./sdf');
55
require('./msdf');
6-
require('./ios10hls');
76
require('./shadow');

src/shaders/ios10hls.js

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/systems/material.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
var registerSystem = require('../core/system').registerSystem;
22
var THREE = require('../lib/three');
33
var utils = require('../utils/');
4-
var isHLS = require('../utils/material').isHLS;
54
var setTextureProperties = require('../utils/material').setTextureProperties;
65

76
var bind = utils.bind;
@@ -156,18 +155,6 @@ module.exports.System = registerSystem('material', {
156155
texture.minFilter = THREE.LinearFilter;
157156
setTextureProperties(texture, data);
158157

159-
// If iOS and video is HLS, do some hacks.
160-
if (this.sceneEl.isIOS &&
161-
isHLS(videoEl.src || videoEl.getAttribute('src'),
162-
videoEl.type || videoEl.getAttribute('type'))) {
163-
// Actually BGRA. Tell shader to correct later.
164-
texture.format = THREE.RGBAFormat;
165-
texture.needsCorrectionBGRA = true;
166-
// Apparently needed for HLS. Tell shader to correct later.
167-
texture.flipY = false;
168-
texture.needsCorrectionFlipY = true;
169-
}
170-
171158
// Cache as promise to be consistent with image texture caching.
172159
videoTextureResult = {texture: texture, videoEl: videoEl};
173160
textureCache[hash] = Promise.resolve(videoTextureResult);

src/utils/material.js

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
var THREE = require('../lib/three');
22

3-
var HLS_MIMETYPES = ['application/x-mpegurl', 'application/vnd.apple.mpegurl'];
4-
53
var COLOR_MAPS = new Set([
64
'emissiveMap',
75
'envMap',
@@ -183,15 +181,6 @@ function handleTextureEvents (el, texture) {
183181
if (!texture.image || texture.image.tagName !== 'VIDEO') { return; }
184182

185183
texture.image.addEventListener('loadeddata', function emitVideoTextureLoadedDataAll () {
186-
// Check to see if we need to use iOS 10 HLS shader.
187-
// Only override the shader if it is stock shader that we know doesn't correct.
188-
if (!el.components || !el.components.material) { return; }
189-
190-
if (texture.needsCorrectionBGRA && texture.needsCorrectionFlipY &&
191-
['standard', 'flat'].indexOf(el.components.material.data.shader) !== -1) {
192-
el.setAttribute('material', 'shader', 'ios10hls');
193-
}
194-
195184
el.emit('materialvideoloadeddata', {src: texture.image, texture: texture});
196185
});
197186
texture.image.addEventListener('ended', function emitVideoTextureEndedAll () {
@@ -200,15 +189,3 @@ function handleTextureEvents (el, texture) {
200189
});
201190
}
202191
module.exports.handleTextureEvents = handleTextureEvents;
203-
204-
/**
205-
* Given video element src and type, guess whether stream is HLS.
206-
*
207-
* @param {string} src - src from video element (generally URL to content).
208-
* @param {string} type - type from video element (generally MIME type if present).
209-
*/
210-
module.exports.isHLS = function (src, type) {
211-
if (type && HLS_MIMETYPES.includes(type.toLowerCase())) { return true; }
212-
if (src && src.toLowerCase().indexOf('.m3u8') > 0) { return true; }
213-
return false;
214-
};

tests/shaders/ios10hls.test.js

Lines changed: 0 additions & 32 deletions
This file was deleted.

tests/systems/material.test.js

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -211,41 +211,6 @@ suite('material system', function () {
211211
});
212212
});
213213

214-
test('sets texture flags appropriately when given a <video> element that isHLS on iOS', function (done) {
215-
var videoEl = document.createElement('video');
216-
var system = this.system;
217-
var data = {src: VIDEO1};
218-
219-
// Mock iOS.
220-
var sceneEl = this.el.sceneEl;
221-
var realIsIOS = sceneEl.isIOS;
222-
sceneEl.isIOS = true;
223-
assert.equal(sceneEl.isIOS, true);
224-
225-
// Set up and verify video element to be treated as HLS.
226-
videoEl.setAttribute('src', VIDEO1);
227-
videoEl.setAttribute('type', 'application/x-mpegurl');
228-
assert.equal(AFRAME.utils.material.isHLS(videoEl.getAttribute('src'), videoEl.getAttribute('type')), true);
229-
230-
system.loadVideo(videoEl, data, function (texture) {
231-
assert.equal(texture.image, videoEl);
232-
233-
// Verify system thought this was iOS HLS.
234-
assert.equal(sceneEl.isIOS, true);
235-
assert.equal(AFRAME.utils.material.isHLS(videoEl.getAttribute('src'), videoEl.getAttribute('type')), true);
236-
237-
// Undo mock of iOS.
238-
sceneEl.isIOS = realIsIOS;
239-
240-
// Verify iOS HLS flags from systems/material.js have been applied.
241-
assert.equal(texture.format, THREE.RGBAFormat);
242-
assert.equal(texture.needsCorrectionBGRA, true);
243-
assert.equal(texture.flipY, false);
244-
assert.equal(texture.needsCorrectionFlipY, true);
245-
done();
246-
});
247-
});
248-
249214
test('caches identical video textures', function (done) {
250215
var system = this.system;
251216
var src = VIDEO1;

tests/utils/isHLS.test.js

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)