On Android and the web a sync runs on the frame thread, and every one stopped the breathing circle for about 0.3 s on a Pixel 3a while a practice was running. A practice on screen, also in its small window, now holds back starting a sync and finishing one that began before it; Lumi and package requests, which use the frame thread everywhere, wait too. Scheduled work runs when the practice ends. In the background nothing is drawn, so background practice sync continues.
46 lines
1.6 KiB
C
46 lines
1.6 KiB
C
#include "app/sync_safety.h"
|
|
|
|
#include <assert.h>
|
|
|
|
static InnerBreeze app;
|
|
|
|
int
|
|
main(void)
|
|
{
|
|
assert(app_background_sync_safe(NULL) == 0);
|
|
app.breathing.screen = ScreenHabits;
|
|
assert(app_background_sync_safe(&app) == 1);
|
|
assert(sync_safety_SyncUiUpdateSafe(&app, 2.5, 1.0, false));
|
|
app.breathing.screen = ScreenLumi;
|
|
app.ui.text_input_active = true;
|
|
assert(!sync_safety_SyncUiUpdateSafe(&app, 20.0, 1.0, false));
|
|
app.ui.text_input_active = false;
|
|
assert(sync_safety_SyncUiUpdateSafe(&app, 20.0, 1.0, false));
|
|
|
|
/* This native build runs sync on a worker thread, so a running
|
|
practice does not hold it back. */
|
|
app.breathing.screen = ScreenSession;
|
|
assert(app_background_sync_safe(&app) == 1);
|
|
app.breathing.screen = ScreenLumi;
|
|
|
|
/* A visible practice, also in its small window, holds frame-thread
|
|
work; in the background nothing is drawn. */
|
|
assert(!sync_safety_app_practice_holds_frame_work(&app));
|
|
app.breathing.screen = ScreenSession;
|
|
assert(sync_safety_app_practice_holds_frame_work(&app));
|
|
app.breathing.screen = ScreenHabits;
|
|
app.session_window.screen = ScreenMeditation;
|
|
assert(sync_safety_app_practice_holds_frame_work(&app));
|
|
app.backgrounded = 1;
|
|
assert(!sync_safety_app_practice_holds_frame_work(&app));
|
|
app.backgrounded = 0;
|
|
app.session_window.screen = ScreenStart;
|
|
app.breathing.screen = ScreenLumi;
|
|
|
|
app.modal.active = 1;
|
|
assert(app_background_sync_safe(&app) == 0);
|
|
app.sync_alias_focused = 1;
|
|
assert(app_background_sync_safe(&app) == 0);
|
|
return 0;
|
|
}
|