Files
breeze/tests/practice_downloads_behavior.zi
waoziandClaude Opus 5.5 17a0cfd9e6 Keep the first frame's pictures when the practice catalog loads
The Practices app opens after the first frame. Loading its catalog closed
the previous practice packs and always reported assets/practices as
changed, so every practice picture already on screen loaded again: the
2048x1024 Wim Hof banner decoded twice in each start, about 760 ms each
in a debug build on a Pixel 4a. Closing the packs now reloads pictures
only when a closing pack served some, as installing or removing one pack
already did; readers still look again either way.

Local tests: practice-downloads-test, with a new check that the first
catalog leaves pictures alone (it fails on the old code), and
desktop-window-test on a private Xvfb.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 17:30:57 -03:00

665 lines
25 KiB
Ziran

#import, file "../src/practices/practice_downloads.zi";
#import, file "../src/app/assets.zi";
#import, file "../src/app/locale.zi";
#import, file "../src/storage/temporary_data.zi";
#import, file "../src/app/text_buffers.zi";
#import, file "../src/apps/package_files.zi";
#import, file "../src/apps/download_recovery.zi";
c :: #system_library "c";
FixtureCatalog :: () -> string #foreign c;
FixtureAsset :: (path: string) -> AssetView #foreign c;
FixtureMode :: (mode: s32) #foreign c;
FixtureCatalogMode :: (mode: s32) #foreign c;
FixtureShipped :: (value: s32) #foreign c;
FixtureGrantedStarts :: () -> s32 #foreign c;
FixtureStarts :: () -> s32 #foreign c;
FixtureTaiChiSaved :: () -> bool #foreign c;
FixtureBlockContent :: (blocked: bool) #foreign c;
FixtureContentStarted :: () -> bool #foreign c;
FixtureContentNow :: () -> u64 #foreign c;
FixtureProvider :: (path: string) -> AssetView {
return FixtureAsset(path)
}
// The transport fixture completes immediately; content verification does not.
// Wait in the test driver while production pumps continue to return promptly.
FixtureContentYield :: () #foreign c;
FixturePracticePump :: (selected: s32, narration: bool, guide: bool, idle: bool) {
for index: cast(s32)0..practice_pack_count - 1 {
practice_packs[index].retry_at = 0
}
PracticeDownloadsPump(selected, narration, guide, idle)
attempts: s32 = 0
while practice_content_jobs > 0 && attempts < 5000 {
if !idle && practice_transfer_index >= 0 && practice_packs[practice_transfer_index].language[0] == cast(u8)0 {
return
}
FixtureContentYield()
PracticeDownloadsPump(selected, narration, guide, idle)
attempts += 1
}
}
FixturePracticeReview :: () {
PracticeContentReviewNext()
attempts: s32 = 0
while practice_content_jobs > 0 && attempts < 5000 {
FixtureContentYield()
PracticeContentReviewNext()
attempts += 1
}
}
// 1 grants Tai Chi's packs, 0 keeps the grant pending, -1 refuses it.
fixture_grant_mode: s32 = 1;
FixtureGrant :: (product: string, output: []u8) -> s32 {
if product != "inbe.practice.taichi" || fixture_grant_mode < 0 {
return -1
}
if fixture_grant_mode == 0 {
return 0
}
return ifx AppCopyText("fixture-grant", output) then 1 else -1
}
fixture_owned: bool = true;
FixtureOwned :: (product: string) -> bool {
return product == "inbe.practice.taichi" && fixture_owned
}
#program_export
CheckPracticeDownloads :: () -> s32 {
if PracticeCatalogValid("{\"schema\":1,\"packs\":[]}") ||
PracticeCatalogValid("{\"schema\":2,\"packs\":[]}") {
return 15
}
AssetBindProvider(FixtureProvider)
practice_grant = FixtureGrant
practice_owned = FixtureOwned
unused AssetTakeChanges()
FixturePracticePump(0, false, false, true)
if practice_pack_count != 11 || PracticeContentReady(0) {
return 1
}
// The first catalog closes no pack, so the pictures already on screen
// stay: the practice banners decoded once, not again when it loaded.
first_catalog := AssetTakeChanges()
if first_catalog.all || first_catalog.folders.count != 0 {
return 132
}
PracticeContentRequest(0)
FixturePracticePump(0, false, false, true)
// Repeated requests while transferring must not enqueue the pack twice.
PracticeContentRequest(0)
FixturePracticePump(0, false, false, true)
if !PracticeContentReady(0) || PracticeContentStatus(0) != 2 {
return 2
}
// A pack with pictures reports images under the practices as changed.
installed := AssetTakeChanges()
pictures_changed := installed.all
for folder: installed.folders {
if folder == PRACTICE_ASSET_FOLDER {
pictures_changed = true
}
}
if !pictures_changed {
return 130
}
FixturePracticePump(0, false, false, true)
if FixtureStarts() != 1 {
return 16
}
if !PracticeDownloadsAsset("assets/practices/whm/1.webp").found {
return 3
}
if PracticeDownloadsAsset("locales/en.txt").found ||
PracticeDownloadsAsset("assets/practices/whm/../taichi/pack.json").found {
return 4
}
// An invalid replacement cannot discard working, verified content.
FixtureCatalogMode(1)
AssetNotifyChanged()
FixturePracticePump(0, false, false, true)
if !PracticeContentReady(0) || !PracticeDownloadsAsset("assets/practices/whm/1.webp").found {
return 18
}
FixtureCatalogMode(0)
AssetNotifyChanged()
FixturePracticePump(0, false, false, true)
// Moving away keeps recent verified content mounted within the cache budget.
before := FixtureStarts()
FixturePracticePump(4, false, false, true)
PracticeContentRequest(0)
FixturePracticePump(0, false, false, true)
if !PracticeContentReady(0) || FixtureStarts() != before {
return 5
}
// A corrupt download never becomes ready. It is tried again by itself,
// with a fresh grant, and reported as failed only after the last try.
FixturePracticePump(4, false, false, true)
FixtureMode(1)
corrupt_before := FixtureStarts()
PracticeContentRequest(4)
FixturePracticePump(4, false, false, true)
FixturePracticePump(4, false, false, true)
retry_starts := FixtureStarts()
for frame: cast(s32)0..cast(s32)99 {
PracticeDownloadsPump(4, false, false, true)
}
if FixtureStarts() != retry_starts || PracticeContentStatus(4) != 1 ||
practice_packs[PracticePackFind(4, "")].retry_at <= DownloadRecoveryNow() { return 67 }
for step: cast(s32)0..cast(s32)11 {
FixturePracticePump(4, false, false, true)
}
if PracticeContentReady(4) || PracticeContentStatus(4) != 3 ||
FixtureStarts() != corrupt_before + 1 + PracticeDownloadRetries {
return 6
}
// One bad transfer recovers on its own when the next try succeeds.
PracticeContentRequest(4)
FixturePracticePump(4, false, false, true)
FixturePracticePump(4, false, false, true)
FixtureMode(0)
for step: cast(s32)0..cast(s32)5 {
FixturePracticePump(4, false, false, true)
}
if !PracticeContentReady(4) || PracticeContentStatus(4) != 2 {
return 38
}
PracticeContentRemove(4)
FixtureMode(0)
PracticeContentRequest(4)
FixturePracticePump(4, false, false, true)
FixturePracticePump(4, false, false, true)
if !PracticeContentReady(4) {
return 7
}
base_bundle := practice_packs[PracticePackFind(4, "")].bundle
english := PracticeNarrationPack(4, "en", "")
spanish := PracticeNarrationPack(4, "es", "")
guide := PracticeNarrationPack(PracticeGuide, "en", "")
// With narration off, nothing downloads it.
before = FixtureStarts()
FixturePracticePump(4, false, false, true)
FixturePracticePump(4, false, false, true)
if FixtureStarts() != before || english < 0 || spanish < 0 || guide < 0 ||
PracticeNarrationState(english) != 0 || PracticeNarrationState(guide) != 0 {
return 8
}
before = FixtureStarts()
unused AssetTakeChanges()
generation := AssetGeneration()
// A session can start while its voice is queued. Its voice finishes and
// mounts during the session without replacing the borrowed base pack.
FixturePracticePump(4, true, false, true)
base_during_session := practice_packs[PracticePackFind(4, "")].bundle
for step: cast(s32)0..cast(s32)4 {
FixturePracticePump(4, true, false, false)
}
if FixtureStarts() != before + 1 || PracticeNarrationState(english) != 2 ||
PracticeNarrationState(guide) != 0 ||
practice_packs[PracticePackFind(4, "")].bundle != base_during_session {
return 91
}
// Guide voice is independent: it can download and play with practice voice off.
for step: cast(s32)0..cast(s32)4 {
FixturePracticePump(4, false, true, true)
}
if FixtureStarts() != before + 2 || PracticeNarrationState(guide) != 2 ||
!PracticeDownloadsAsset("assets/practices/guide/voice/en/test.ogg").found ||
PracticeDownloadsAsset("assets/practices/taichi/voice/en/test.ogg").found {
return 92
}
// Narration packs hold no pictures: readers find the recordings, and
// every image on screen stays as it is.
narrated := AssetTakeChanges()
if narrated.all || narrated.folders.count != 0 || AssetGeneration() == generation {
return 131
}
// Both choices mount only their selected-language narration.
for step: cast(s32)0..cast(s32)7 {
FixturePracticePump(4, true, true, true)
}
if FixtureStarts() != before + 2 || PracticeNarrationState(english) != 2 ||
PracticeNarrationState(spanish) != 0 || PracticeNarrationState(guide) != 2 ||
!PracticeDownloadsAsset("assets/practices/taichi/voice/en/test.ogg").found ||
!PracticeDownloadsAsset("assets/practices/guide/voice/en/test.ogg").found {
return 42
}
before = FixtureStarts()
active_locale_index = 1
// A running practice retains its borrowed course and audio bytes.
FixturePracticePump(4, true, true, false)
if FixtureStarts() != before {
return 9
}
// In another app language the practice downloads and speaks that one;
// Lumi's guide stays silent when its selected language is unavailable.
for step: cast(s32)0..cast(s32)5 {
FixturePracticePump(4, true, true, true)
}
if FixtureStarts() != before + 1 || PracticeNarrationState(spanish) != 2 ||
PracticeNarrationLanguage(4, "") != "es" || PracticeNarrationLanguage(PracticeGuide, "").count != 0 ||
PracticeDownloadsAsset("assets/practices/taichi/voice/en/test.ogg").found ||
!PracticeDownloadsAsset("assets/practices/taichi/voice/es/test.ogg").found {
return 10
}
// Back in English, the copy on this device speaks without a download.
before = FixtureStarts()
active_locale_index = 0
FixturePracticePump(4, true, true, true)
FixturePracticePump(4, true, true, true)
if FixtureStarts() != before || PracticeNarrationLanguage(4, "") != "en" ||
!PracticeDownloadsAsset("assets/practices/taichi/voice/en/test.ogg").found {
return 11
}
// A language chosen in Customize speaks instead of the app's.
PracticeNarrationPrefer(4, "es")
FixturePracticePump(4, true, true, true)
FixturePracticePump(4, true, true, true)
if FixtureStarts() != before || PracticeNarrationLanguage(4, "") != "es" ||
!PracticeDownloadsAsset("assets/practices/taichi/voice/es/test.ogg").found {
return 12
}
PracticeNarrationPrefer(4, "")
// Removing a language frees only that one and keeps it from coming back
// by itself; another downloaded language speaks.
PracticeNarrationDecline(english)
for step: cast(s32)0..cast(s32)3 {
FixturePracticePump(4, true, true, true)
}
if FixtureStarts() != before || PracticeNarrationState(english) != 0 ||
PracticeNarrationState(spanish) != 2 || PracticeNarrationLanguage(4, "") != "es" ||
PracticeDownloadsAsset("assets/practices/taichi/voice/en/test.ogg").found {
return 43
}
if practice_packs[PracticePackFind(4, "")].bundle != base_bundle {
return 17
}
// It stays removed when the catalog loads again, until it is downloaded.
PracticeDownloadsClose()
for step: cast(s32)0..cast(s32)3 {
FixturePracticePump(4, true, true, true)
}
if FixtureStarts() != before || PracticeNarrationState(english) != 0 {
return 49
}
PracticeNarrationDownload(english)
for step: cast(s32)0..cast(s32)5 {
FixturePracticePump(4, true, true, true)
}
if FixtureStarts() != before + 1 || PracticeNarrationState(english) != 2 ||
PracticeNarrationLanguage(4, "") != "en" {
return 50
}
// The male voice has its own packs, which follow the app's language too,
// while the default voice's languages stay on this device.
male := PracticeNarrationPack(4, "en", "male")
before = FixtureStarts()
PracticeVoiceSelect(4, "male")
for step: cast(s32)0..cast(s32)5 {
FixturePracticePump(4, true, true, true)
}
if FixtureStarts() != before + 1 || PracticeNarrationState(male) != 2 ||
!PracticeDownloadsAsset("assets/practices/taichi/voice-male/en/test.ogg").found ||
PracticeDownloadsAsset("assets/practices/taichi/voice/en/test.ogg").found {
return 44
}
before = FixtureStarts()
PracticeVoiceSelect(4, "")
FixturePracticePump(4, true, true, true)
FixturePracticePump(4, true, true, true)
if FixtureStarts() != before || PracticeNarrationState(spanish) != 2 ||
!PracticeDownloadsAsset("assets/practices/taichi/voice/en/test.ogg").found {
return 37
}
// A download in progress can be stopped, and does not start again by itself.
PracticeNarrationDecline(english)
PracticeNarrationDownload(english)
FixturePracticePump(4, true, true, true)
PracticeNarrationDecline(english)
for step: cast(s32)0..cast(s32)3 {
FixturePracticePump(4, true, true, true)
}
if PracticeNarrationState(english) != 0 || FixtureStarts() != before + 1 {
return 45
}
// Lumi's guide narration is mounted only while narration is on, and once
// removed it stays off this device.
if !PracticeDownloadsAsset("assets/practices/guide/voice/en/test.ogg").found {
return 46
}
FixturePracticePump(4, false, false, true)
if PracticeDownloadsAsset("assets/practices/guide/voice/en/test.ogg").found {
return 47
}
PracticeNarrationDecline(guide)
for step: cast(s32)0..cast(s32)3 {
FixturePracticePump(4, true, true, true)
}
if PracticeNarrationState(guide) != 0 || PracticeNarrationLanguage(PracticeGuide, "").count != 0 ||
FixtureStarts() != before + 1 {
return 48
}
PracticeContentRemove(4)
if PracticeContentReady(4) || PracticeNarrationState(spanish) != 0 || PracticeNarrationState(male) != 0 {
return 13
}
FixturePracticePump(0, false, false, true)
if !PracticeContentReady(0) {
return 14
}
// The manager can queue other practices without mounting them or changing
// the practice currently shown. Their verified files work offline later.
before = FixtureStarts()
PracticeContentRequest(1)
PracticeContentRequest(4)
for turn: cast(s32)0..cast(s32)3 {
FixturePracticePump(0, false, false, true)
}
if FixtureStarts() != before + 2 || PracticeContentStatus(1) != 2 ||
PracticeContentStatus(4) != 2 || PracticeContentReady(1) || PracticeContentReady(4) {
return 21
}
FixturePracticePump(1, false, false, true)
if !PracticeContentReady(1) || FixtureStarts() != before + 2 {
return 22
}
FixturePracticePump(0, false, false, true)
PracticeContentRemove(4)
PracticeDownloadsClose()
FixturePracticePump(0, false, false, true)
for turn: cast(s32)0..cast(s32)6 {
FixturePracticeReview()
}
if PracticeContentStatus(1) != 2 || PracticeContentReady(1) ||
!PracticePackReviewed(1, "") || !PracticeContentReady(0) {
return 23
}
// Remove takes a downloaded practice off Practice and keeps its copy, so
// it comes back without a download; Delete frees the copy.
before = FixtureStarts()
PracticeContentHide(1)
if PracticeInstalled(1) || PracticeContentStatus(1) != 2 ||
!PracticePackStored(PracticePackFind(1, "")) {
return 60
}
PracticeDownloadsClose()
PracticeCatalogLoad()
for turn: cast(s32)0..cast(s32)8 {
FixturePracticeReview()
}
if PracticeInstalled(1) || PracticeContentStatus(1) != 2 {
return 61
}
PracticeContentRequest(1)
FixturePracticePump(1, false, false, true)
if !PracticeInstalled(1) || !PracticeContentReady(1) || FixtureStarts() != before ||
PracticeMarked(1, ".removed") {
return 62
}
FixturePracticePump(0, false, false, true)
PracticeContentHide(1)
PracticeContentRemove(1)
if PracticeInstalled(1) || PracticeContentStatus(1) != 0 ||
PracticePackStored(PracticePackFind(1, "")) || PracticeMarked(1, ".removed") {
return 63
}
// A copy stored before the ZX format cannot run, but it shows the
// practice was installed: it downloads again as ZX and the old copy goes.
before = FixtureStarts()
legacy := PracticePackFile(PracticePackFind(1, ""), PRACTICE_PACK_LEGACY_SUFFIX)
if !PackageWrite(legacy, "ZIB legacy pack") || !PracticePackStored(PracticePackFind(1, "")) {
return 64
}
PracticeDownloadsClose()
PracticeCatalogLoad()
for turn: cast(s32)0..cast(s32)8 {
FixturePracticeReview()
}
FixturePracticePump(1, false, false, true)
FixturePracticePump(1, false, false, true)
if !PracticeInstalled(1) || !PracticeContentReady(1) || FixtureStarts() == before ||
PackageFileSize(legacy) >= 0 {
return 65
}
PackageFree(legacy)
FixturePracticePump(0, false, false, true)
PracticeContentHide(1)
PracticeContentRemove(1)
// Mini sessions reuse public caches, but missing packs stay transient.
DataSetTemporary(true)
FixturePracticePump(4, false, false, true)
PracticeContentRequest(4)
FixturePracticePump(4, false, false, true)
FixturePracticePump(4, false, false, true)
if !PracticeContentReady(4) || FixtureTaiChiSaved() {
return 19
}
FixturePracticePump(0, false, false, true)
before = FixtureStarts()
PracticeContentRemove(0)
DataSetTemporary(false)
FixturePracticePump(4, false, false, true)
FixturePracticePump(0, false, false, true)
if !PracticeContentReady(0) || FixtureStarts() != before || FixtureTaiChiSaved() {
return 20
}
// Wim Hof ships with the app: installed without a download, and it stays
// installed when its own copy is removed or an older version left a
// Remove marker. Others need a download.
PracticeContentRemove(0)
FixtureShipped(1)
PracticeDownloadsClose()
before = FixtureStarts()
if !PracticeInstalled(0) || PracticeInstalled(2) {
return 24
}
FixturePracticePump(0, false, false, true)
if !PracticeContentReady(0) || FixtureStarts() != before {
return 25
}
PracticeContentRemove(0)
PracticeMark(0, ".removed", true)
PracticeDownloadsClose()
FixturePracticePump(0, false, false, true)
if !PracticeInstalled(0) || !PracticeContentReady(0) || FixtureStarts() != before {
return 26
}
PracticeMark(0, ".removed", false)
// Breathing Patterns ships with the app too: installed without a copy of
// its own or a download, and nothing takes it off Practice.
if !PracticeInstalled(3) || !PracticeShipped(3) {
return 39
}
FixturePracticePump(3, false, false, true)
FixturePracticePump(3, false, false, true)
if !PracticeInstalled(3) || !PracticeContentReady(3) || FixtureStarts() != before ||
PracticePackStored(PracticePackFind(3, "")) {
return 40
}
PracticeContentHide(3)
PracticeContentRemove(3)
PracticeDownloadsClose()
if !PracticeInstalled(3) || PracticeMarked(3, ".added") || PracticeMarked(3, ".removed") {
return 41
}
// Paid packs download only with the host's grant in their path; they
// wait while it is requested and fail when it is refused. Google Play,
// without Dew, hides them.
if PracticeProduct(4) != "inbe.practice.taichi" || PracticeProduct(0).count != 0 ||
FixtureGrantedStarts() < 1 {
return 29
}
PracticeContentRemove(4)
fixture_grant_mode = 0
before = FixtureStarts()
PracticeContentRequest(4)
FixturePracticePump(4, false, false, true)
if FixtureStarts() != before || PracticeContentStatus(4) != 1 {
return 30
}
fixture_grant_mode = 1
FixturePracticePump(4, false, false, true)
FixturePracticePump(4, false, false, true)
if FixtureStarts() != before + 1 || !PracticeContentReady(4) {
return 31
}
// A paid pack on this device counts as installed only for an account
// that owns it, such as a pack another account left behind.
fixture_owned = false
if PracticeInstalled(4) || !PracticeInstalled(0) {
return 34
}
fixture_owned = true
if !PracticeInstalled(4) {
return 35
}
PracticeContentRemove(4)
fixture_grant_mode = -1
PracticeContentRequest(4)
// A refused grant is asked for again, then reported; nothing downloads.
for step: cast(s32)0..cast(s32)5 {
FixturePracticePump(4, false, false, true)
}
if FixtureStarts() != before + 1 || PracticeContentStatus(4) != 3 {
return 32
}
practice_paid_allowed = false
if !PracticeHidden(4) || PracticeInstalled(4) || PracticeHidden(0) || !PracticeInstalled(0) {
return 33
}
practice_paid_allowed = true
PracticeDownloadsClose()
// Astral Projection is a separate free download, with its own offline
// guidance. Reopening it uses the verified cache; removal clears it.
FixturePracticePump(5, false, false, true)
if PracticeContentReady(5) || PracticeInstalled(5) || PracticeProduct(5).count != 0 {
return 110
}
PracticeContentRequest(5)
for step: cast(s32)0..cast(s32)5 {
FixturePracticePump(5, false, false, true)
}
if !PracticeContentReady(5) || !PracticeInstalled(5) ||
!PracticeDownloadsAsset("assets/practices/astral_projection/session.json").found ||
!PracticeDownloadsAsset("assets/practices/astral_projection/text/ja.txt").found {
return 111
}
before = FixtureStarts()
PracticeDownloadsClose()
FixturePracticePump(5, false, false, true)
if !PracticeContentReady(5) || FixtureStarts() != before {
return 112
}
PracticeContentRemove(5)
PracticeDownloadsClose()
if PracticeInstalled(5) {
return 113
}
// Sun Salutation downloads, verified, and shows its figures. When an
// update leaves an older copy, it stays installed while the new copy
// downloads, on Practice alike.
sun: s32 = 2
figure := "assets/practices/sunsalutation/characters/01-jade-bun/01-001.png"
FixturePracticePump(sun, false, false, true)
if PracticeInstalled(sun) || PracticeContentReady(sun) {
return 120
}
before = FixtureStarts()
PracticeContentRequest(sun)
for step: cast(s32)0..cast(s32)5 {
FixturePracticePump(sun, false, false, true)
}
if !PracticeContentReady(sun) || !PracticeInstalled(sun) ||
FixtureStarts() != before + 1 || !PracticeDownloadsAsset(figure).found {
return 121
}
PracticeDownloadsClose()
FixturePracticePump(sun, false, false, true)
if !PracticeContentReady(sun) || FixtureStarts() != before + 1 ||
!PracticeDownloadsAsset(figure).found {
return 122
}
stored := PracticePackPath(PracticePackFind(sun, ""), false)
unused PackageWrite(stored, "an older release")
PracticeDownloadsClose()
FixturePracticePump(sun, false, false, true)
if !PracticeInstalled(sun) || PracticeContentStatus(sun) != 1 {
PackageFree(stored)
return 123
}
for step: cast(s32)0..cast(s32)5 {
FixturePracticePump(sun, false, false, true)
}
if !PracticeContentReady(sun) || !PracticeInstalled(sun) ||
FixtureStarts() != before + 2 || !PracticeDownloadsAsset(figure).found {
PackageFree(stored)
return 124
}
unused PackageWrite(stored, "an older release")
PackageFree(stored)
PracticeDownloadsClose()
FixturePracticePump(0, false, false, true)
for step: cast(s32)0..practice_pack_count {
FixturePracticeReview()
}
if !PracticeInstalled(sun) || PracticeContentStatus(sun) != 1 {
return 125
}
for step: cast(s32)0..cast(s32)5 {
FixturePracticePump(0, false, false, true)
}
if !PracticeInstalled(sun) || PracticeContentStatus(sun) != 2 ||
FixtureStarts() != before + 3 {
return 126
}
#if !#defined(PLATFORM_WEB) && !#defined(_WIN32) {
// Hold a real cold-cache hash on its worker. Navigation and removal
// must return while it is held, and its late result cannot remount it.
PracticeDownloadsClose()
FixtureBlockContent(true)
PracticeDownloadsPump(sun, false, false, true)
attempts: s32 = 0
while !FixtureContentStarted() && attempts < 1000 {
FixtureContentYield()
PracticeDownloadsPump(sun, false, false, true)
attempts += 1
}
if !FixtureContentStarted() {
FixtureBlockContent(false)
return 127
}
started := FixtureContentNow()
PracticeContentRemove(sun)
PracticeDownloadsPump(0, false, false, true)
elapsed := FixtureContentNow() - started
FixtureBlockContent(false)
// The hash stays held until this point, so removal that waited for it
// would never return; a second only allows for a busy runner.
if elapsed > cast(u64)1000000000 {
return 128
}
FixturePracticePump(0, false, false, true)
settled: s32 = 0
while practice_content_jobs != 0 && settled < 1000 {
FixtureContentYield()
FixturePracticePump(0, false, false, true)
settled += 1
}
if PracticeContentReady(sun) || PracticeDownloadsAsset(figure).found || practice_content_jobs != 0 {
return 129
}
}
return 0
}