animebook / animebook.github.io

In-browser video player for learning Japanese with subtitles
https://animebook.github.io
MIT License
273 stars 29 forks source link

Update extension to manifest V3 #39

Closed soamsy closed 2 years ago

soamsy commented 2 years ago

Manifest V3 is google's new spec for the manifest.json that extensions have, and I want to update. My main reason is that it supports specifying cross-origin isolation, which if I don't opt into, will cause the extension to stop working due to Chrome's eventual ban on SharedArrayBuffer. https://developer.chrome.com/docs/extensions/mv3/cross-origin-isolation/

I tested what would happen if I updated to V3, and there's issues:

Even if an extension opts into cross-origin isolation, not all extension contexts will be cross-origin isolated. For example, cross-origin isolation is not fully implemented) for service and shared workers currently. Similarly, a cross-origin isolated extension's web-accessible subframe on a regular web page is not considered cross-origin isolated currently.

This sounds like what I'm running into, since all the SharedArrayBuffer magic is happening on a WebWorker which was loaded from an iframe. It's not clear if Google intends to fix this later, but if they don't AND ban SharedArrayBuffer for me, I may have to look into getting rid of SharedArrayBuffer. It's only used by ffmpeg for multi-threaded speed improvements, but I don't know if I really need it since I'm just recording a slice of audio and taking a screenshot, which shouldn't be that slow on a single thread.

soamsy commented 2 years ago

Getting rid of multi-threading makes recording up to 3x longer depending on the flashcard you're creating. I'm going to try to avoid this if at all possible.

soamsy commented 2 years ago

Decided to try again at this from scratch, and the problems I was running into appear to be resolved in the more recent versions of Chromium. I get no warnings that I'm not opting into cross-origin isolation, and Manifest V3 supports a 'wasm-unsafe-eval' option now. I had to work around some unsafe-eval problems with Vue.js, but now that those instances are gone, it'll hopefully be easier to audit the extension whenever I submit it to the Chrome Web Store.