[go: up one dir, main page]

Page MenuHomePhabricator

Call IPA Engine from parser hook
Closed, ResolvedPublic5 Estimated Story Points

Description

Background

There are legal concerns with providing an open API that acts as a proxy to Google's Cloud API. For this reason, along with a few advantages, we want to do all the processing when the page is parsed, similar to how Extension:Score works. Then we wouldn't need an API at all. We're already using the onParserFirstCallInit now, but the HTML is completely rebuilt client-side and the file is never generated until something is clicked.

In a separate ticket T315482: Generate HTML server side for IPA audio button, we will explore moving the HTML construction to the backend and out of PhonosButton.js, which would then keep it all in one place.

Advantages to bypassing our API and saving the files on parse:

  • Quicker load time for playing the audio, since it's already saved
  • Non-JavaScript users are supported (the button simply links to the file) (after T315482 is resolved)
  • Our cache key still persists even when the page is re-parsed, meaning there are no unnecessary API calls (unless the parameters to the Phonos parser function changed)

Other considerations

  • The rollout to production when the parent IPA template is changed to use Phonos could cause a massive amount of API calls to Google at once (since all pages using that template will get re-parsed). We should be careful to deploy slowly and ensure we aren't hitting any throttling limits or the like.
  • Re-parsing quickly, such as when fiddling with Phonos using Realtime Preview, will cause a unique call to Google each time as well as creating a new file. However if the above bullet is not a concern, this shouldn't be either!
  • There will be a slight performance hit to saving edits when we need to generate new audio.

Acceptance criteria

  • Change the backend and frontend so that deal with URLs, not base64 audio.
  • The Engine should be called from this code, so that we have always have a full URL to give to PhonosButton.js.
  • PhonosButton.js can still be responsible for constructing HTML and playing the audio as it does now.
  • Visual acceptance criteria is basically nil. Nothing should look or act different; only that clicking Play will seem a bit faster and initial previews might be a little slow depending on how much Phonos usage there is on the page.

Event Timeline

MusikAnimal renamed this task from Call IPA Engine from parser hook [tbd] to Call IPA Engine from parser hook.Aug 18 2022, 12:38 AM
MusikAnimal renamed this task from Call IPA Engine from parser hook to Generate HTML and call IPA Engine from parser hook.
MusikAnimal updated the task description. (Show Details)
MusikAnimal renamed this task from Generate HTML and call IPA Engine from parser hook to Call IPA Engine from parser hook.Aug 18 2022, 2:53 PM

Change 825393 had a related patch set uploaded (by MusikAnimal; author: MusikAnimal):

[mediawiki/extensions/Phonos@master] [WIP] Always persist audio data to disk

https://gerrit.wikimedia.org/r/825393

Change 825393 merged by jenkins-bot:

[mediawiki/extensions/Phonos@master] Always persist audio data to disk

https://gerrit.wikimedia.org/r/825393

QA notes: T315483 can be tested along with this, since the original patch was reworked. Let me know if there are any questions! Basically things should look/operate the same as usual, but load times when clicking on play should now be very fast since the storage happens during parsing.

Also note that fatal errors (such as not being able to connect to Google) will currently break parsing/editing of a page. That's being addressed as part of T316700

Other considerations

  • The rollout to production when the parent IPA template is changed to use Phonos could cause a massive amount of API calls to Google at once (since all pages using that template will get re-parsed). We should be careful to deploy slowly and ensure we aren't hitting any throttling limits or the like.

This is one reason for the work in T318979.

I have done some small-scale experiments locally where I update the parent IPA template. This causes all the pages using that template to have their IPA generated as part of a job (whose rate respects whatever is set for $wgJobBackoffThrottling['phonosIPAFilePersist']).

There are plans to simulate this on a larger scale on beta and/or testwiki.

  • Re-parsing quickly, such as when fiddling with Phonos using Realtime Preview, will cause a unique call to Google each time as well as creating a new file. However if the above bullet is not a concern, this shouldn't be either!

Similarly to what was explained in T315483#8328294.

  • There will be a slight performance hit to saving edits when we need to generate new audio.

Saving will not complete until IPA file generation is completed (for # of files < $wgExpensiveParserFunctionLimit).

This will also affect things like previewing a page (incl. RTP) but only the first time you do it (as by the second time the IPA files will have been generated).

Acceptance criteria

  • Change the backend and frontend so that deal with URLs, not base64 audio.

Phonos buttons link to URLs such as: https://upload.wikimedia.beta.wmflabs.org/phonos/m/u/muew86147ndobjntxvu4abbr4hm0o3d.mp3

  • The Engine should be called from this code, so that we have always have a full URL to give to PhonosButton.js.
  • PhonosButton.js can still be responsible for constructing HTML and playing the audio as it does now.
  • Visual acceptance criteria is basically nil. Nothing should look or act different; only that clicking Play will seem a bit faster and initial previews might be a little slow depending on how much Phonos usage there is on the page.

We are still finalising the look of the IPA button. See, for example, T315482.