kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

Build Bloom Player reproducibly from upstream source

Open rtibbles opened this issue 4 months ago • 1 comments

❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.

Overview

  • Bloom Player is vendored as a hand-built binary from a fork with no update path.
  • Replace it with a reproducible in-tree build from upstream at a pinned tag.
  • Track our modifications on top of that pin.
  • Automate upstream updates, mirroring the update-h5p job in .github/workflows/dependency_updates.yml.
  • Fix large-file URL handling so URLs that already carry a scheme pass through unmodified.

Complexity: High Target branch: develop

Context

  • The player ships as a checked-in binary, kolibri/plugins/bloompub_viewer/static/bloom/bloomPlayer-02a77592459cdf0b1bd7.min.js.
  • There is no build step in the tree.
  • There is no recorded upstream ref.
  • Producing it is manual, and documented only in packages/kolibri-sandbox/README.md:
    • Clone learningequality/bloom-player.
    • Build its patched default branch.
    • Copy dist in by hand.
  • The player resolves book assets through fullUrl, which passes through blob: URLs and concatenates everything else onto urlPrefix:
    e.prototype.fullUrl = function (t) {
      return (t?.startsWith('blob:')) && t ? t : this.urlPrefix + '/' + t;
    };
    
  • Kolibri's sourceUrl is a blob URL with no .htm suffix, so urlPrefix is the entire blob URL.
  • Files over kolibri-zip's 500 KB largeMediaThreshold are served from an absolute zipcontent URL rather than a blob.
  • fullUrl therefore mangles them: a 14.7 MB video in a .bloompub requests blob:http://…/<uuid>/http://…/content/zipcontent/….mp4 and fails with ERR_FILE_NOT_FOUND.
  • git tag --contains 41dde53dc2c2f6d6c80f9c4d7ac70eb1345230a9 puts the absolute-URL change in v0.19.4 and v0.19.5, so released versions are affected.

The Change

  • Build the player in-tree from BloomBooks/bloom-player at a pinned upstream tag.
  • Mirror the h5p_build pattern:
    • A file recording the pinned upstream ref.
    • A download-and-build script in the plugin.
    • The built output committed under static/.
  • Re-derive Kolibri's modifications against current upstream rather than porting them forward. This is the bulk of the work, not a mechanical rebase.
    • learningequality:patched is 10 commits ahead of BloomBooks/bloom-player@master.
    • It is 266 commits behind.
    • The fork was last pushed 2025-05-12; upstream on 2026-07-18.
    • The latest upstream release is v2.20.1.
  • Triage each of the seven non-merge modifications for whether it is still needed:
    • 7c35899b — Kolibri compatibility: blob URLs, fullUrl, audio rehydration.
    • 29a3e541 — message namespace.
    • c942fc4d — questionsJsonUrl support.
    • Four cosmetic navigation and loading-text tweaks that upstream may have since superseded.
  • Carry whatever survives so each modification stays individually identifiable and reviewable.
  • Make conflicts surface when the pin moves. The mechanism is the implementer's call.
  • Retire learningequality/bloom-player as the source of truth.
  • Add an upstream-watch job to .github/workflows/dependency_updates.yml alongside update-h5p:
    • Detect a new upstream tag.
    • Bump the pin.
    • Rebuild.
    • Open a PR.
  • Fix fullUrl so any URL that already carries a scheme passes through unchanged.

How to Get There

  • Import the Kolibri QA Channel, 95a52b386f2c485cb97dd60901674a98. It is not public, so it does not appear in the public channel API.
  • Open the "Los colores" resource, e09797d2c6bd4a78af53a8340165ec1e, whose videos are 5–15 MB.
  • The console shows a failed request to blob:<origin>/<uuid>/http://<origin>/content/zipcontent/a468d2372371726750b6c60aa1c3e8ab.bloompub/video/<name>.mp4.
  • The video does not play.
  • Reproduces on released Kolibri as well as develop, so kolibri-demo works as a comparison point.

Out of Scope

  • The Basic Book.css console error.
    • The stylesheet is absent from the .bloompub itself, so there is nothing to substitute.
    • No fallback endpoint could serve it, since zipcontent reads the same archive.
  • The host/fonts/Andika 404.
    • It is one entry in a @font-face fallback chain.
    • Browsers log each failed entry before falling through to the next.
  • Changes to the sandbox handler architecture in kolibri/plugins/bloompub_viewer/frontend/sandbox_handler/.

Acceptance Criteria

General

  • [ ] The player is built from BloomBooks/bloom-player at an upstream ref recorded in-tree.
  • [ ] No build input comes from learningequality/bloom-player.
  • [ ] Rebuilding from the same recorded ref on a clean checkout produces an identical bundle.
  • [ ] Each Kolibri modification carried on top of upstream is individually identifiable and reviewable.
  • [ ] A job in .github/workflows/dependency_updates.yml opens a PR when upstream publishes a new tag.
  • [ ] That PR bumps the pinned ref.
  • [ ] That PR contains the rebuilt bundle.
  • [ ] fullUrl returns URLs that already carry a scheme unchanged.
  • [ ] The build is documented in kolibri/plugins/bloompub_viewer/, alongside the code it builds.

Testing

  • [ ] Videos over the 500 KB largeMediaThreshold play in "Los colores" (Kolibri QA Channel).
  • [ ] Audio-sentence playback works.
  • [ ] Quiz pages generated from questions.json render.
  • [ ] Page navigation works.

References

  • Upstream: https://github.com/BloomBooks/bloom-player, latest release v2.20.1.
  • Current fork: https://github.com/learningequality/bloom-player, default branch patched.
  • Divergence: https://github.com/BloomBooks/bloom-player/compare/master...learningequality:patched
  • Pattern to mirror: kolibri/plugins/h5p_viewer/h5p_build/.
  • That pattern's pin lives in .h5p-commit-sha.
  • That pattern's automation is the update-h5p job in .github/workflows/dependency_updates.yml.
  • Large-file handling: largeMediaThreshold and largeFileUrlGenerator in packages/kolibri-zip/src/index.js.
  • Their consumer is kolibri/plugins/bloompub_viewer/frontend/sandbox_handler/BloomRunner.js.

AI usage

I used Claude Code to diagnose the Bloom console errors against a running dev instance, and to draft this issue section by section. It traced the broken video URL to fullUrl in the vendored bundle, and pulled the fork divergence figures from the GitHub API. I reviewed each section before it went in.

rtibbles avatar Jul 20 '26 03:07 rtibbles

Plan: Build Bloom Player in-tree from BloomBooks/bloom-player at a pinned commit, with Kolibri's modifications carried as a patch series, and an automated upstream-watch job.

  • [ ] Two-stage reproducible build pipeline
  • [ ] Book-loading patches
  • [ ] Re-derive audio resolution
  • [ ] Namespaced host messages
  • [ ] Navigation button styling
  • [ ] Upstream-watch job
  • [ ] Rebuild and QA
  • [ ] Self-review the produced code

Assumptions — the issue did not settle these; say so if one is wrong.

  • Babel transpiles the bundle to browserslist-config-kolibri, as for H5P; if upstream's targets are fine, drop babel-loader and the polyfill plugin from stage 2.
  • The whole build runs on upstream's exact volta.node; if Kolibri's Node 20 must work locally, stage 1 must fetch its own Node.
  • BloomRunner writes resolved URLs into data-audio-src/data-backgroundaudio, not _<uuid> ids; if that is out of scope, port the fork hack and keep its https/large-audio bugs.
  • Answer sounds are inlined (~112 KB base64); if bundle size matters, use a relative base and have webpack emit the files.
  • Pass-through tests for an RFC 3986 scheme, so data: passes too; if only blob:/http(s): should pass, narrow the regex.
  • A conflicting bump only fails the scheduled job; if maintainers want notice, add a failure step that opens an issue.
  • No CI job re-checks the committed bundle against a rebuild; if wanted, add a path-filtered build-bloom + git diff --exit-code job.
  • Archiving learningequality/bloom-player is left to a maintainer after merge; this branch only drops references to it.
  • Kolibri's template replaces upstream's bloomplayer.htm; if upstream adds required markup there, the template needs updating.
  • The build uses translations committed at the tag, not the Crowdin download upstream's release adds; if those are needed, CI needs a Crowdin token.
  • Both cosmetic tweaks are kept; if upstream's defaults are preferred, drop patches 0008/0009.

Written by rtibblesbot, an LLM-based coding agent.

rtibblesbot avatar Oct 22 '26 04:10 rtibblesbot