Mozilla foundation - devtools WebAudio

BrandonFL | Aug 1, 2019

Goal

Migrate Web Audio Tool to an extension web extension

  • Analyse the codebase (server) (client) (I will send the deletion patch for you to look at in order to determine all of the pieces you need)
  • Create a web extension (pure frontend application) which can achieve the same result as the old API. (This is made possible by weakRefs)

Documentation

Challenges

  • Two parts of its implementation to be addressed:
    • CallWatcher usage
      • observes connections between nodes
      • changes to settings/properties of nodes
    • ChromeOnly finalization API
      • Used to know when nodes are GC’d and can be removed from the graph
      • On allocation, each node is assigned an ID that is accessible via a ChromeOnly property
      • When a node is reclaimed, a ChromeOnly event is fired that says the ID of the reclaimed node

Technical Solutions

  • CallWatcher can be reimplemented in a content script
    • Tom (see Mozilla Support Staff) is working on formalizing this sort of thing in a new web extension API
  • Finalization
    • Use TC39 WeakRef and Finalizer API
    • Native implementation maybe not ready by the time we want to remove the Web Audio tool
    • But there is a working polyfill! Till Schneidereit has it
    • In a content script:
      • assign each newly allocated audio node an ID
      • set a finalizer for that node that uses this ID as its holdings
      • when the node is reclaimed, the finalizer runs with the ID holdings, which we postMessage (or whatever messaging API content scripts have) the ID up to the web extension itself, so it can clean up

Credits

  • Referent : Michel Buffa
  • Mentors :
    • Luca Greco
    • Paul Arduino
    • Nick Fitzgerald
    • Yulia Startsev