Trying to make it to the finish line…
well, we need to keep the pattern anyway.
music: whatever YouTube Music recommended to me from The 91’s Conundrum by Tanger (again on YouTube.)
this was mostly behind-the-scenes maintenance. we support subtitle tracks now, I guess? and the console log is a bit nicer?
OH
RIGHT
This devlog is about network requests.
look at this STINKY NETWORK REQUEST LOG: (attachment)
that’s the SAME FILES. requested 400 times. No good!!
This runs into a limitation of Web Workers - they have to load from a standalone JavaScript file. That means the easiest way to initialize one (i.e. naming a file path) involves hitting the network. And then if that file happens to, say, import two other files, now you’re suddenly making three requests every time you want to start a worker.
Object URLs let you turn any chunk of data you want into a unique URL that refers to that data! Said URLs look something like this: blob:http://localhost:5776/7c686f43-7750-4eb2-ab71-c5292922f015
Now, the neat thing is you can just tell JS to use one of these things as the source code for a Web Worker, and suddenly you’re not hitting the network any more! … wellll … not quite yet. let’s look at that worker file:
/// <reference no-default-lib="true" />
/// <reference lib="esnext" />
/// <reference lib="webworker" />
import { CORE_URL, FFMessageType } from "./const.js";
import { ERROR_UNKNOWN_MESSAGE_TYPE, ERROR_NOT_LOADED, ERROR_IMPORT_FAILURE, } from "./errors.js";
let ffmpeg;
Right. import. Our problems are not magically fixed by using an Object URL (in fact, they’re worse now - the module just will not load because it’s trying to make a relative path based off an Object URL.)
Obviously, the solution is even more Object URLs. Write a script to patch the imports, too:
/// <reference no-default-lib="true" />
/// <reference lib="esnext" />
/// <reference lib="webworker" />
import { CORE_URL, FFMessageType }
from "blob:http://localhost:5776/b7123137-85ed-480f-a4ed-0ba7c365ba9e";
import { ERROR_UNKNOWN_MESSAGE_TYPE, ERROR_NOT_LOADED, ERROR_IMPORT_FAILURE, }
from "blob:http://localhost:5776/b3307384-5616-41f2-8114-63a947f92626";
let ffmpeg;
and you’re off!