Remove Wasm preload; instead, actually load it sooner
This commit is contained in:
1
ui.html
1
ui.html
@@ -6,7 +6,6 @@
|
|||||||
href="https://unpkg.com/purecss@2.0.6/build/pure-min.css"
|
href="https://unpkg.com/purecss@2.0.6/build/pure-min.css"
|
||||||
crossorigin="anonymous"
|
crossorigin="anonymous"
|
||||||
/>
|
/>
|
||||||
<link rel="preload" href="libapi.wasm" as="fetch" />
|
|
||||||
<style>
|
<style>
|
||||||
.center-parent {
|
.center-parent {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
16
ui.js
16
ui.js
@@ -12,15 +12,17 @@ if (isDebug) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** This function should be called once user has selected the camera and other operations can begin. */
|
/** This function should be called once user has selected the camera and other operations can begin. */
|
||||||
let prepareContext;
|
let start;
|
||||||
|
|
||||||
|
let started = new Promise(resolve => {
|
||||||
|
start = resolve;
|
||||||
|
});
|
||||||
|
|
||||||
/** Schedules an exclusive async operation on the global context. */
|
/** Schedules an exclusive async operation on the global context. */
|
||||||
const scheduleOp = (() => {
|
const scheduleOp = (() => {
|
||||||
let queue = (async () => {
|
let queue = (async () => {
|
||||||
await new Promise(resolve => {
|
|
||||||
prepareContext = resolve;
|
|
||||||
});
|
|
||||||
let { Context } = await initModule();
|
let { Context } = await initModule();
|
||||||
|
await started;
|
||||||
let ctx = await new Context();
|
let ctx = await new Context();
|
||||||
addEventListener('beforeunload', e => {
|
addEventListener('beforeunload', e => {
|
||||||
ctx.delete();
|
ctx.delete();
|
||||||
@@ -281,12 +283,12 @@ class App extends Component {
|
|||||||
}
|
}
|
||||||
this.setState({ type: 'CameraPicker' });
|
this.setState({ type: 'CameraPicker' });
|
||||||
});
|
});
|
||||||
window.onerror = message => {
|
addEventListener('error', ({ message }) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
type: 'Status',
|
type: 'Status',
|
||||||
message: `⚠ ${message}`
|
message: `⚠ ${message}`
|
||||||
});
|
});
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
selectDevice = async () => {
|
selectDevice = async () => {
|
||||||
@@ -303,7 +305,7 @@ class App extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
connectToCamera() {
|
connectToCamera() {
|
||||||
prepareContext();
|
start();
|
||||||
this.setState({ type: 'Status', message: 'Connecting...' });
|
this.setState({ type: 'Status', message: 'Connecting...' });
|
||||||
(async () => {
|
(async () => {
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|||||||
Reference in New Issue
Block a user