diff --git a/package.json b/package.json
index 80a668a5..4d5d472a 100644
--- a/package.json
+++ b/package.json
@@ -3,7 +3,7 @@
"title": "Quirk",
"description": "An HTML5 toy for exploring and understanding small quantum circuits.",
"license": "Apache-2.0",
- "version": "1.1.1",
+ "version": "1.2.0",
"homepage": "https://github.com/Strilanc/Quirk",
"bugs": {
"url": "https://github.com/Strilanc/Quirk/issues"
diff --git a/res/index.html b/res/index.html
index 4f51a578..47485db2 100644
--- a/res/index.html
+++ b/res/index.html
@@ -9,6 +9,14 @@
About Quirk
+
+ Loading Quirk...
+
+
diff --git a/src/browser/Polyfills.js b/src/browser/Polyfills.js
index 945a13da..f454e016 100644
--- a/src/browser/Polyfills.js
+++ b/src/browser/Polyfills.js
@@ -5,6 +5,16 @@ Float32Array.prototype.slice = Float32Array.prototype.slice || function(a, b, c)
Float64Array.prototype.slice = Float64Array.prototype.slice || function(a, b, c) {
return new Float64Array(Array.from(this).slice(a, b, c));
};
+Uint32Array.prototype.slice = Float64Array.prototype.slice || function(a, b, c) {
+ return new Uint32Array(Array.from(this).slice(a, b, c));
+};
+Uint16Array.prototype.slice = Float64Array.prototype.slice || function(a, b, c) {
+ return new Uint16Array(Array.from(this).slice(a, b, c));
+};
+Uint8Array.prototype.slice = Float64Array.prototype.slice || function(a, b, c) {
+ return new Uint8Array(Array.from(this).slice(a, b, c));
+};
+
const ARRAY_ITER = function() {
let self = this;
return function*() {
@@ -15,6 +25,13 @@ const ARRAY_ITER = function() {
};
Float32Array.prototype[Symbol.iterator] = Float32Array.prototype[Symbol.iterator] || ARRAY_ITER;
Float64Array.prototype[Symbol.iterator] = Float64Array.prototype[Symbol.iterator] || ARRAY_ITER;
+Uint32Array.prototype[Symbol.iterator] = Uint32Array.prototype[Symbol.iterator] || ARRAY_ITER;
+Uint16Array.prototype[Symbol.iterator] = Uint16Array.prototype[Symbol.iterator] || ARRAY_ITER;
+Uint8Array.prototype[Symbol.iterator] = Uint8Array.prototype[Symbol.iterator] || ARRAY_ITER;
+
+// This was missing on the iPhone I tested.
+window.performance = window.performance || {};
+window.performance.now = window.performance.now || (() => Date.now());
// Safari only puts properties on instances of WebGLRenderingContext.
const GL = WebGLRenderingContext;
diff --git a/src/circuit/CircuitDefinition.js b/src/circuit/CircuitDefinition.js
index 44079a96..8164cd9d 100644
--- a/src/circuit/CircuitDefinition.js
+++ b/src/circuit/CircuitDefinition.js
@@ -540,11 +540,9 @@ class CircuitDefinition {
let nonSwaps = seq(col.gates).
mapWithIndex((gate, i) => {
let pt = new Point(colIndex, i);
- if (gate === null || this.gateAtLocIsDisabledReason(pt) !== undefined) {
- return [];
- }
- let m = gate.matrixAt(time);
- if (gate === Gates.Special.SwapHalf || m.isIdentity()) {
+ if (gate === null
+ || gate === Gates.Special.SwapHalf
+ || this.gateAtLocIsDisabledReason(pt) !== undefined) {
return [];
}
@@ -552,6 +550,11 @@ class CircuitDefinition {
return gate.customShaders.map(f => (inTex, conTex) => f(inTex, conTex, i, time));
}
+ let m = gate.matrixAt(time);
+ if (m.isIdentity()) {
+ return [];
+ }
+
return [(inTex, conTex) => GateShaders.qubitOperation(inTex, m, i, conTex)];
}).
flatten();
diff --git a/src/main.js b/src/main.js
index 3acf22de..29f8ab95 100644
--- a/src/main.js
+++ b/src/main.js
@@ -322,10 +322,11 @@ const loadCircuitFromUrl = () => {
window.onpopstate = () => loadCircuitFromUrl(false);
loadCircuitFromUrl();
-haveLoaded = true;
-redrawNow();
// If the webgl initialization is going to fail, don't fail during the module loading phase.
+haveLoaded = true;
setTimeout(() => {
initializedWglContext().onContextRestored = () => redrawThrottle.trigger();
+ redrawNow();
+ document.getElementById("loading-div").style.display = 'none';
}, 0);
diff --git a/src/ui/Gates.js b/src/ui/Gates.js
index fb30fc76..94054ded 100644
--- a/src/ui/Gates.js
+++ b/src/ui/Gates.js
@@ -319,7 +319,7 @@ const CountingGateMaker = span => new Gate(
t => Matrix.generate(1<
((r-Math.floor(t*(1<