Keep WHM animation smooth and reduce per-frame sync work

This commit is contained in:
waozi committed 2026-10-09 10:41:28 -03:00
1 parent dd6c79d5ed
commit e8ee1cf6ed
28 files changed
+410 -90

No files matched your search

+6
View File
@@ -1,4 +1,10 @@
# Changelog
## [2.1.25] - 2026-10-09
### Fixed
- Animate the Wim Hof breathing circle smoothly between timer ticks, including its Customize preview.
- Keep Wim Hof timing accurate when the display frame rate varies.
- Avoid repeating account activity and sync queue checks on unchanged animation frames.
## [2.1.24] - 2026-10-09
### Fixed
- Open the breathing animation, background music and other menus reliably again.
+5
View File
@@ -423,6 +423,11 @@ session-window-ui-test: $(TARGET)
env -u DISPLAY -u WAYLAND_DISPLAY -u XAUTHORITY -u DBUS_SESSION_BUS_ADDRESS \
python3 tests/session_window_ui_test.py $(abspath $(TARGET))
.PHONY: whm-frame-performance-test
whm-frame-performance-test: $(TARGET)
env -u DISPLAY -u WAYLAND_DISPLAY -u XAUTHORITY -u DBUS_SESSION_BUS_ADDRESS \
python3 tests/whm_frame_performance_test.py $(abspath $(TARGET))
$(CELL_BUNDLES) $(INBE_BUNDLE) $(INBE_FULL_BUNDLE) &: $(CELL_SOURCES) $(CELL_RESOURCES) ziran.lock apps/versions.json scripts/check-package-versions.py scripts/generate-package-versions.py scripts/prepare-package-assets.py scripts/animation_inventory.py scripts/build-cells.sh src/practices/sun_salutation/sun_salutation_assets.zi src/practices/sun_salutation/sun_salutation_inventory.zi $(IMAGE_FILES) $(SOUND_FILES) $(FONT_FILES) $(STYLE_FILES) $(LOCALE_FILES) $(ZIRAN_BIN)
sh scripts/build-cells.sh $(ZIRAN_BIN)
+2 -2
View File
@@ -56,8 +56,8 @@ android {
minSdk 21
targetSdk 36
testInstrumentationRunner "android.test.InstrumentationTestRunner"
versionCode 161
versionName "2.1.24"
versionCode 162
versionName "2.1.25"
manifestPlaceholders = [
inbeAppLabel: "Inner Breeze",
inbeUsesCleartextTraffic: "false"
@@ -0,0 +1,5 @@
Fixed
---
- Animate the Wim Hof breathing circle smoothly between timer ticks, including its Customize preview.
- Keep Wim Hof timing accurate when the display frame rate varies.
- Avoid repeating account activity and sync queue checks on unchanged animation frames.
+1 -1
View File
@@ -1,5 +1,5 @@
Package: inbe.waozi
Version: 2.1.24
Version: 2.1.25
Architecture: arm64
Maintainer: Waozi <[email protected]>
Click-Version: 0.4
+1 -1
View File
@@ -28,7 +28,7 @@
<binary>inbe</binary>
</provides>
<releases>
<release version="2.1.24" date="2026-10-09"/>
<release version="2.1.25" date="2026-10-09"/>
</releases>
<content_rating type="oars-1.1"/>
</component>
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "inbe",
"title": "Inner Breeze",
"version": "2.1.24",
"version": "2.1.25",
"architecture": "arm64",
"framework": "ubuntu-sdk-20.04",
"description": "Syncable breathing, meditation, and habit practice app.",
+1 -1
View File
@@ -2,7 +2,7 @@
"manifest_version": 3,
"name": "Inner Breeze",
"short_name": "Inbe",
"version": "2.1.24",
"version": "2.1.25",
"description": "Breathing, meditation, habit tracking, and encrypted sync.",
"permissions": [
"contextMenus"
+1 -1
View File
@@ -22,7 +22,7 @@
<binary>inbe</binary>
</provides>
<releases>
<release version="2.1.24" date="2026-10-09"/>
<release version="2.1.25" date="2026-10-09"/>
</releases>
<content_rating type="oars-1.1"/>
</component>
+1 -1
View File
@@ -22,7 +22,7 @@
<binary>inbe</binary>
</provides>
<releases>
<release version="2.1.24" date="2026-10-09"/>
<release version="2.1.25" date="2026-10-09"/>
</releases>
<content_rating type="oars-1.1"/>
</component>
+1 -1
View File
@@ -6,7 +6,7 @@ description: |
meditation, and habit tracking with visual and audio cues, meditation
timers, habit counters, session history, and optional sync.
version: '2.1.24'
version: '2.1.25'
license: BSD-3-Clause
base: core22
confinement: strict
+34 -7
View File
@@ -45,6 +45,12 @@ ActivityState :: struct {
}
account_activity: ActivityState;
activity_availability_revision: s64 = -1;
activity_availability_delegate_generation: s64 = -1;
activity_availability_checked: float64 = -1.0;
activity_availability: bool;
activity_availability_delegated: bool;
ActivityCurrentTime :: () -> s64 {
return ActivityNow(null)
}
@@ -61,9 +67,27 @@ ActivityRandomID :: (output: []u8, byte_count: s32) -> bool {
}
ActivityAvailable :: () -> bool {
return PreviewMode() == 0 && !DataTemporary() && storage_sync_enabled() != 0 &&
if PreviewMode() != 0 || DataTemporary() {
return false
}
revision := storage_data_revision()
generation := StoredDelegateGeneration()
clock := ActivityFrameTime()
if revision == activity_availability_revision && generation == activity_availability_delegate_generation &&
clock >= activity_availability_checked && clock - activity_availability_checked < 0.25 {
// Delegate expiry and identity checks remain live even when the
// owner's unchanged settings can be reused between frames.
return activity_availability &&
(!activity_availability_delegated || StoredDelegateAvailable() != 0)
}
activity_availability_revision = revision
activity_availability_delegate_generation = generation
activity_availability_checked = clock
activity_availability_delegated = StoredAccountMode() == AccountModeDelegate
activity_availability = storage_sync_enabled() != 0 &&
storage_has_sync_account() != 0 &&
(StoredAccountMode() != AccountModeDelegate || StoredDelegateAvailable() != 0)
(!activity_availability_delegated || StoredDelegateAvailable() != 0)
return activity_availability
}
ActivityInitialize :: () -> bool {
@@ -173,14 +197,17 @@ ActivityApplyControl :: (app: *InnerBreeze, now: s64) -> bool {
ActivityPump :: (app: *InnerBreeze) {
activity_start_check = ActivityCanStart
if app == null || !ActivityInitialize() {
if app == null {
return
}
clock := ActivityFrameTime()
if clock >= account_activity.last_poll && clock - account_activity.last_poll < 0.25 {
return
}
if !ActivityInitialize() {
return
}
state := *account_activity
clock := ActivityFrameTime()
if clock >= state.last_poll && clock - state.last_poll < 0.25 {
return
}
state.last_poll = clock
now := ActivityNow(null)
// Read the shared record only after stored data changed, such as a sync
+27 -5
View File
@@ -7,6 +7,11 @@ c :: #system_library "c";
ProfileGetEnv :: (name: *u8) -> *u8 #foreign c "app_getenv_bytes";
ProfileClock :: () -> float64 #foreign c "app_monotonic_seconds";
ProfileLogInfo :: (line: *u8) #foreign c "app_log_line";
#if #defined(ANDROID_DEBUG) {
android_log :: #system_library "log";
ProfileLogAndroid :: (priority: s32, tag: *u8, line: *u8) -> s32
#foreign android_log "__android_log_write";
}
#scope_export
#program_export
@@ -16,6 +21,9 @@ app_profile_env_enabled :: () -> bool {
return false
}
value: *u8 = ProfileGetEnv(*name[0])
#if #defined(ANDROID_DEBUG) {
if value == null { return true }
}
return value != null && value[0] != cast(u8)0 && value[0] != cast(u8)48
}
@@ -76,7 +84,7 @@ ProfileAppendTwoDecimals :: (output: []u8, used: *s32, number: float64) -> bool
app_profile_report :: (frame_avg: float64, frame_max: float64,
update_avg: float64, update_max: float64,
habits_avg: float64, habits_max: float64,
sync_avg: float64, sync_max: float64) {
sync_avg: float64, sync_max: float64, fps: float64) {
line: [256]u8
used: s32 = 0
if !ProfileAppend(line[:], *used, "PROFILE: frame avg=") ||
@@ -94,17 +102,27 @@ app_profile_report :: (frame_avg: float64, frame_max: float64,
!ProfileAppend(line[:], *used, " sync avg=") ||
!ProfileAppendTwoDecimals(line[:], *used, sync_avg) ||
!ProfileAppend(line[:], *used, " max=") ||
!ProfileAppendTwoDecimals(line[:], *used, sync_max) {
!ProfileAppendTwoDecimals(line[:], *used, sync_max) ||
!ProfileAppend(line[:], *used, " fps=") ||
!ProfileAppendTwoDecimals(line[:], *used, fps) {
return
}
line[used] = cast(u8)0
ProfileLogInfo(*line[0])
#if #defined(ANDROID_DEBUG) {
tag: [16]u8
if CopyCString("InbePerformance", tag[:]) {
unused ProfileLogAndroid(4, *tag[0], *line[0])
}
} else {
ProfileLogInfo(*line[0])
}
}
ProfileStats :: struct {
initialized: s32
enabled: s32
frames: s32
report_started: float64
frame_total: float64
frame_max: float64
update_total: float64
@@ -168,17 +186,21 @@ app_profile_record_sync :: (start: float64) {
#program_export
app_profile_frame_end :: (start: float64) {
if !enabled() || start <= 0.0 { return }
elapsed := (ProfileClock() - start) * 1000.0
now := ProfileClock()
if stats.report_started <= 0.0 { stats.report_started = start }
elapsed := (now - start) * 1000.0
stats.frame_total += elapsed
if elapsed > stats.frame_max { stats.frame_max = elapsed }
stats.frames += 1
if stats.frames < 120 { return }
count := cast(float64)stats.frames
fps: float64 = 0.0
if now > stats.report_started { fps = count / (now - stats.report_started) }
app_profile_report(stats.frame_total / count, stats.frame_max,
stats.update_total / count, stats.update_max,
stats.habits_total / count, stats.habits_max,
stats.sync_total / count, stats.sync_max)
stats.sync_total / count, stats.sync_max, fps)
stats = ProfileStats.{0 }
stats.initialized = 1
stats.enabled = 1
+21 -1
View File
@@ -1113,6 +1113,26 @@ app_sync_review_pending :: () -> s32 {
return sync_review_cache
}
sync_queue_cache: SyncStatus;
sync_queue_cache_valid: bool;
sync_queue_cache_revision: s64 = -1;
sync_queue_cache_checked: float64 = -1.0;
// The queue changes with stored data, not the render rate. A bounded
// fallback also picks up metadata changed outside the writing connection.
app_sync_queue_status :: (status: *SyncStatus, now: float64) -> bool {
if status == null { return false }
revision := storage_data_revision()
if revision != sync_queue_cache_revision || now < sync_queue_cache_checked ||
now - sync_queue_cache_checked >= 0.25 {
sync_queue_cache_revision = revision
sync_queue_cache_checked = now
sync_queue_cache_valid = SyncStatusRead(*sync_queue_cache)
}
status.* = sync_queue_cache
return sync_queue_cache_valid
}
app_sync_pump :: (app: *InnerBreeze) {
now: float64
should_sync: s32 = 0
@@ -1160,7 +1180,7 @@ app_sync_pump :: (app: *InnerBreeze) {
should_sync = 1
dirty_due = 1
}
if SyncStatusRead(*sync_status) && sync_status.has_account != 0 && sync_status.enabled != 0 && (sync_status.queued_changes > 0 || sync_status.full_upload_done == 0 || sync_status.repair_pending != 0) && (g_sync.dirty_sync_at <= 0.0 || now >= g_sync.dirty_sync_at) {
if app_sync_queue_status(*sync_status, now) && sync_status.has_account != 0 && sync_status.enabled != 0 && (sync_status.queued_changes > 0 || sync_status.full_upload_done == 0 || sync_status.repair_pending != 0) && (g_sync.dirty_sync_at <= 0.0 || now >= g_sync.dirty_sync_at) {
should_sync = 1
if sync_status.repair_pending != 0 {
repair_due = 1
+52 -1
View File
@@ -153,7 +153,58 @@ BreathAnimatedSpan :: (session: BreathSession, span: s32,
#program_export
BreathDrawRadius :: (session: BreathSession) -> float32 {
return cast(float32)session.r
return BreathDrawRadiusAt(session, 0.0)
}
// Keep the portable session's integer fields, but paint its continuous
// curve rather than snapping the radius to whole layout units.
#program_export
BreathDrawRadiusAt :: (session: BreathSession, fraction: float32) -> float32 {
span := session.rmax - session.rmin
half_ticks := session.breath_half_ticks
shrinking := session.phase == BreathPhaseNext
if session.phase == BreathPhaseBreathe {
half_ticks = BreathEffectiveHalfTicks(session)
shrinking = session.dir != 0
} else if session.phase != BreathPhaseNext &&
(session.phase != BreathPhaseRecover || session.r >= session.rmax) {
return cast(float32)session.r
}
if span <= 0 || half_ticks <= 0 {
return cast(float32)session.r
}
if !(fraction >= 0.0) { fraction = 0.0 }
if fraction > 1.0 { fraction = 1.0 }
amount := (cast(float32)session.breath_frame + fraction) /
cast(float32)half_ticks
if amount < 0.0 { amount = 0.0 }
if amount > 1.0 { amount = 1.0 }
if session.breath_animation != BreathAnimationLinear {
amount = BreathSmoothstep(amount)
}
if shrinking { amount = 1.0 - amount }
return cast(float32)session.rmin + cast(float32)span * amount
}
BreathClockStep :: struct {
ticks: s32
remainder: float64
}
// Carry fractional ticks directly. Converting each 60 Hz tick back to a
// truncated number of milliseconds makes the clock run too fast.
#program_export
BreathClockAdvance :: (seconds: float64, remainder: float64) -> BreathClockStep {
result: BreathClockStep
if !(remainder >= 0.0) || remainder >= 1.0 { remainder = 0.0 }
result.remainder = remainder
if !(seconds > 0.0) { return result }
if seconds > 300.0 { seconds = 300.0 }
ticks := seconds * 60.0 + remainder
result.ticks = cast(s32)(ticks + 0.000000001)
result.remainder = ticks - cast(float64)result.ticks
if result.remainder < 0.0 { result.remainder = 0.0 }
return result
}
#program_export
+2 -2
View File
@@ -3,7 +3,7 @@
#define APP_VERSION_MAJOR 2
#define APP_VERSION_MINOR 1
#define APP_VERSION_PATCH 24
#define APP_VERSION_STRING "2.1.24"
#define APP_VERSION_PATCH 25
#define APP_VERSION_STRING "2.1.25"
#endif
+2 -2
View File
@@ -1,5 +1,5 @@
// Generated by update_version.sh from CHANGELOG.md. Do not edit by hand.
VersionMajor :: 2
VersionMinor :: 1
VersionPatch :: 24
VersionString :: "2.1.24"
VersionPatch :: 25
VersionString :: "2.1.25"
+16 -33
View File
@@ -51,8 +51,8 @@ using TextWrap;
using ButtonTone;
using ButtonEmphasis;
whm_config_preview_remainder: s32 = 0;
whm_start_speed_preview_remainder: s32 = 0;
whm_config_preview_remainder: float64 = 0.0;
whm_start_speed_preview_remainder: float64 = 0.0;
WhmAnimationOptionCount :: 2
WhmConfigClamp :: (value: s32, minimum: s32, maximum: s32) -> s32 {
@@ -83,7 +83,7 @@ whm_preview_needs_reset :: (preview: *BreathSession, speed: s32, max_rounds: s32
whm_preview_reset :: (preview: *BreathSession, speed: s32, max_rounds: s32,
max_breaths: s32, pause_seconds: s32,
animation: s32, content_w: s32, content_h: s32,
remainder: *s32) {
remainder: *float64) {
if preview == null {
return
}
@@ -99,39 +99,20 @@ whm_preview_reset :: (preview: *BreathSession, speed: s32, max_rounds: s32,
}
}
whm_preview_step_elapsed :: (preview: *BreathSession, remainder: *s32) {
elapsed_ms := cast(s32)(GetFrameTime() * 1000.0f + 0.5f)
total: s32
frames: s32
whm_preview_step_elapsed :: (preview: *BreathSession, remainder: *float64) {
if preview == null {
return
}
if elapsed_ms < 1 {
elapsed_ms = 17
}
if elapsed_ms > 120 {
elapsed_ms = 120
}
if remainder == null {
preview.* = BreathSessionStep(preview.*)
return
}
total = elapsed_ms * 60 + remainder.*
frames = total / 1000
remainder.* = total % 1000
if frames < 1 {
frames = 1
}
if frames > 8 {
frames = 8
}
seconds := cast(float64)GetFrameTime()
if seconds > 0.12 { seconds = 0.12 }
fraction: float64 = 0.0
if remainder != null { fraction = remainder.* }
clock := BreathClockAdvance(seconds, fraction)
if remainder != null { remainder.* = clock.remainder }
{
i: s32 = 0
while i < frames {
while i < clock.ticks {
preview.* = BreathSessionStep(preview.*)
if preview.phase != BreathPhaseBreathe {
return
@@ -146,7 +127,7 @@ whm_draw_exact_speed_preview :: (preview: *BreathSession, preview_speed: *s32,
pause_seconds: s32, animation: s32,
content_w: s32, content_h: s32,
center_x: s32, center_y: s32,
remainder: *s32) {
remainder: *float64) {
if preview == null || preview_speed == null {
return
}
@@ -162,7 +143,9 @@ whm_draw_exact_speed_preview :: (preview: *BreathSession, preview_speed: *s32,
}
whm_preview_step_elapsed(preview, remainder)
draw_breath_preview(preview, center_x, center_y)
fraction: float32 = 0.0
if remainder != null { fraction = cast(float32)remainder.* }
draw_breath_preview(preview, center_x, center_y, fraction)
}
whm_draw_progressive_start_speed_editor :: (app: *InnerBreeze) {
@@ -328,7 +311,7 @@ whm_config_draw_breath_card :: (app: *InnerBreeze, content_x: s32, content_w: s3
}
draw_breath_preview(*app.settings_preview,
inner_x + inner_w / 2,
inner_y + preview_h / 2)
inner_y + preview_h / 2, cast(float32)whm_config_preview_remainder)
inner_y += preview_h + AppScale(20)
if commit_slider_row(app, 1, inner_x, inner_w, *inner_y, AppScale(78),
+1 -1
View File
@@ -18,6 +18,6 @@ void update_session_sounds(InnerBreeze*app);
void session_background_start(InnerBreeze*app);
void session_advance_elapsed(InnerBreeze*app, int elapsed_ms);
void update_preview_bounds(BreathSession *breathing, int content_w, int max_h);
void draw_breath_preview(BreathSession *breathing, int center_x, int center_y);
void draw_breath_preview(BreathSession *breathing, int center_x, int center_y, float fraction);
#endif
+17 -21
View File
@@ -98,7 +98,7 @@ whm_log :: (level: s32, message: string) {
}
}
whm_background_remainder_ms: s32 = 0;
whm_elapsed_remainder: float64 = 0.0;
whm_last_notification_text: [96] u8;
text_color_for_background :: (background: Color) -> Color {
luma: s32 = cast(s32)background.r * 299 + cast(s32)background.g * 587 + cast(s32)background.b * 114
@@ -384,33 +384,30 @@ session_background_start :: (app: *InnerBreeze) {
if app == null {
return
}
whm_background_remainder_ms = 0
whm_elapsed_remainder = 0.0
whm_last_notification_text[0] = cast(u8)0
remember_sound_state(app)
}
session_advance_elapsed :: (app: *InnerBreeze, elapsed_ms: s32) {
elapsed_total: s32
frame_count: s32
session_advance_seconds(app, cast(float64)elapsed_ms / 1000.0)
}
if app == null || elapsed_ms <= 0 {
session_advance_seconds :: (app: *InnerBreeze, seconds: float64) {
if app == null || !(seconds > 0.0) {
return
}
if app_session_screen(app) != ScreenSession || app.session_paused != 0 {
return
}
elapsed_total = elapsed_ms + whm_background_remainder_ms
if elapsed_total > 5 * 60 * 1000 {
elapsed_total = 5 * 60 * 1000
}
frame_count = (elapsed_total * 60) / 1000
whm_background_remainder_ms = elapsed_total - (frame_count * 1000) / 60
clock := BreathClockAdvance(seconds, whm_elapsed_remainder)
whm_elapsed_remainder = clock.remainder
{
i: s32 = 0
while i < frame_count && app_session_screen(app) == ScreenSession {
while i < clock.ticks && app_session_screen(app) == ScreenSession {
step := PracticeRun(PracticeStepFor(app, PRACTICE_BREATH_STEP))
if !step.succeeded {
app.request_quit = 1
@@ -435,11 +432,7 @@ session_advance_visible_frame :: (app: *InnerBreeze) {
return
}
elapsed_ms: s32 = cast(s32)(GetFrameTime() * 1000.0f + 0.5f)
if elapsed_ms < 1 {
elapsed_ms = 1
}
session_advance_elapsed(app, elapsed_ms)
session_advance_seconds(app, cast(float64)GetFrameTime())
}
#program_export
@@ -455,6 +448,7 @@ session_start :: (app: *InnerBreeze) {
// A fresh session keeps every choice made in Customize.
app.breathing = BreathSessionInit()
whm_elapsed_remainder = 0.0
app.breathing.progressive_speed = progressive_speed
app.breathing.progressive_start_speed = progressive_start_speed
app.breathing.play_in_background = play_in_background
@@ -943,7 +937,8 @@ draw_session_progress_circle :: (app: *InnerBreeze, center_x: s32, center_y: s32
}
session_draw_inbe :: (app: *InnerBreeze, center_x: s32, center_y: s32) {
radius: float32 = BreathDrawRadius(app.breathing)
radius: float32 = BreathDrawRadiusAt(app.breathing,
cast(float32)whm_elapsed_remainder)
draw_session_progress_circle(app, center_x, center_y, radius)
draw_session_counter(app, center_x, center_y)
@@ -1013,10 +1008,11 @@ session_draw_round_title_bar :: (app: *InnerBreeze, title: string, height: s32)
#program_export
// Painted into the current widget scope, so the preview stays above a modal
// panel and inside a scrolled page's clip.
draw_breath_preview :: (breathing: *BreathSession, center_x: s32, center_y: s32) {
draw_breath_preview :: (breathing: *BreathSession, center_x: s32, center_y: s32,
fraction: float32) {
r: float32 = 0.0f
if breathing != null {
r = BreathDrawRadius(breathing.*) * 0.72f
r = BreathDrawRadiusAt(breathing.*, fraction) * 0.72f
}
if r <= 0.0f {
return
+10
View File
@@ -24,6 +24,8 @@
c :: #system_library "c";
FixtureAdvance :: (seconds: s64) #foreign c;
FixtureSchedules :: () -> s32 #foreign c;
FixtureFrame :: () #foreign c;
FixtureQueries :: () -> s32 #foreign c;
fixture_app: InnerBreeze;
WriteControl :: (activity: AccountActivity, id: string, revision: s64, now: s64) {
@@ -78,6 +80,14 @@ Check :: () -> s32 {
check_true("fresh activity", ActivityFresh(first, ActivityCurrentTime()))
check_true("stale activity is not fresh", !ActivityFresh(first, first.time + ActivityFreshSeconds + 1))
check_true("future activity is not fresh", !ActivityFresh(first, first.time - 6))
queries_before := FixtureQueries()
for frame: cast(s32)0..cast(s32)11 {
FixtureFrame()
ActivityPump(*fixture_app)
unused ActivityRemoteVisible()
}
check_true("unchanged animation frames perform no activity SQL queries",
FixtureQueries() == queries_before)
fixture_app.breathing.screen = ScreenSunSalutation
fixture_app.sun_salutation.repetitions = 3
FixtureAdvance(1)
+16 -3
View File
@@ -23,14 +23,26 @@ cat > "$work/generated/main.c" <<'C'
#include <stdint.h>
#include <stdio.h>
#include <time.h>
typedef struct sqlite3 sqlite3;
typedef struct sqlite3_stmt sqlite3_stmt;
static int64_t fixture_now = 1791540000;
static double fixture_clock = 10.0;
static int schedules;
static int queries;
time_t __wrap_time(time_t *output) {
if (output) *output = fixture_now;
return fixture_now;
}
double GetTime(void) { return (double)(fixture_now - 1791539990); }
void FixtureAdvance(int64_t seconds) { fixture_now += seconds; }
double GetTime(void) { return fixture_clock; }
void FixtureAdvance(int64_t seconds) { fixture_now += seconds; fixture_clock += seconds; }
void FixtureFrame(void) { fixture_clock += 1.0 / 60.0; }
int32_t FixtureQueries(void) { return queries; }
int __real_sqlite3_prepare_v2(sqlite3 *, const char *, int, sqlite3_stmt **, const char **);
int __wrap_sqlite3_prepare_v2(sqlite3 *db, const char *sql, int length,
sqlite3_stmt **statement, const char **tail) {
queries++;
return __real_sqlite3_prepare_v2(db, sql, length, statement, tail);
}
int32_t FixtureSchedules(void) { return schedules; }
int32_t app_auto_sync(void *app) { (void)app; schedules++; return 1; }
int main(void) {
@@ -46,6 +58,7 @@ monocypher=$root/build/packages/monocypher/src
-I"$monocypher" -I"$monocypher/optional" \
"$work/generated"/*.c "$root/vendor-builds/sqlite/sqlite3.c" \
"$monocypher/monocypher.c" "$monocypher/optional/monocypher-ed25519.c" "$liboqs" \
-Wl,--gc-sections -Wl,--wrap=time -ldl -lpthread -lz -lm -o "$work/test"
-Wl,--gc-sections -Wl,--wrap=time -Wl,--wrap=sqlite3_prepare_v2 \
-ldl -lpthread -lz -lm -o "$work/test"
APP_DATA_ROOT="$data" "$work/test"
printf '%s\n' 'Account activity, private outbox, controls, freshness and account switching passed'
+62
View File
@@ -145,5 +145,67 @@ Answer :: () -> s32 {
if state.completed != 0 {
return -18
}
// Every render can move by a fraction of a layout unit, including
// between simulation ticks and on both sides of a breath boundary.
smooth := BreathSessionInit()
smooth.phase = BreathPhaseBreathe
smooth.progressive_speed = 0
smooth.speed_level = 3
smooth.rmin = 80
smooth.rmax = 160
smooth.breath_frame = 1
first_radius := BreathDrawRadius(smooth)
second_radius := BreathDrawRadiusAt(smooth, 0.5)
if !(first_radius > 80.5 && first_radius < 80.6 &&
second_radius > first_radius && second_radius < 81.0) { return -25 }
smooth.dir = 1
if !(BreathDrawRadiusAt(smooth, 0.5) < BreathDrawRadius(smooth)) { return -26 }
smooth.breath_frame = 0
if BreathDrawRadius(smooth) != 160.0 { return -27 }
smooth.dir = 0
smooth.breath_animation = BreathAnimationInOut
smooth.breath_frame = 36
if BreathDrawRadius(smooth) != 92.5 { return -28 }
smooth.phase = BreathPhaseHold
smooth.r = 80
if BreathDrawRadiusAt(smooth, 0.9) != 80.0 { return -29 }
smooth.phase = BreathPhaseRecover
smooth.breath_half_ticks = 120
smooth.breath_frame = 60
if BreathDrawRadiusAt(smooth, 0.0) != 120.0 { return -30 }
smooth.r = 160
smooth.breath_frame = 0
if BreathDrawRadiusAt(smooth, 0.5) != 160.0 { return -31 }
smooth.phase = BreathPhaseNext
smooth.breath_frame = 60
if BreathDrawRadius(smooth) != 120.0 { return -32 }
// Equal elapsed time must produce equal ticks at high, low and
// irregular rendering rates. The old millisecond carry ran too fast.
clock: BreathClockStep
total_ticks: s32 = 0
for index: cast(s32)0..cast(s32)599 {
clock = BreathClockAdvance(0.016, clock.remainder)
total_ticks += clock.ticks
}
if total_ticks != 576 || clock.remainder > 0.000001 { return -33 }
total_ticks = 0
clock = BreathClockStep.{}
for index: cast(s32)0..cast(s32)599 {
clock = BreathClockAdvance(0.017, clock.remainder)
total_ticks += clock.ticks
}
if total_ticks != 612 || clock.remainder > 0.000001 { return -34 }
total_ticks = 0
clock = BreathClockStep.{}
for index: cast(s32)0..cast(s32)1439 {
clock = BreathClockAdvance(1.0 / 144.0, clock.remainder)
total_ticks += clock.ticks
}
if total_ticks != 600 || clock.remainder > 0.000001 { return -35 }
clock = BreathClockAdvance(0.0, 0.5)
if clock.ticks != 0 || clock.remainder != 0.5 { return -36 }
clock = BreathClockAdvance(301.0, 0.0)
if clock.ticks != 18000 || clock.remainder != 0.0 { return -37 }
return 42
}
+1 -1
View File
@@ -64,7 +64,7 @@ int main(int argc, char **argv)
app_profile_frame_end(10.0);
if(log_count != 1 ||
strcmp(log_text,
"PROFILE: frame avg=10.00 max=10.00 update avg=0.08 max=10.00 habits avg=0.08 max=10.00 sync avg=0.08 max=10.00"))
"PROFILE: frame avg=10.00 max=10.00 update avg=0.08 max=10.00 habits avg=0.08 max=10.00 sync avg=0.08 max=10.00 fps=12000.00"))
return 6;
app_profile_frame_end(10.0);
if(log_count != 1)
+18
View File
@@ -3,6 +3,7 @@
#import, file "../src/app/sync_safety.zi";
#import, file "../src/app/sync_retry.zi";
#import, file "../src/app/app_types.zi";
#import, file "../src/storage/sync_status.zi";
// Host state the C side provides: the clock, the account switch, and the
// queue the status key reads.
@@ -10,6 +11,7 @@ recovery_c :: #system_library "c";
recovery_set_time :: (seconds: float64) #foreign recovery_c;
recovery_set_enabled :: (enabled: s32) #foreign recovery_c;
recovery_set_queue :: (queued: s64, repair: s32, full_upload: s32) #foreign recovery_c;
recovery_status_reads :: () -> s32 #foreign recovery_c;
Retry :: (attempt: s32) -> bool {
return SettingsStoreInt("sync_retry_attempt", attempt)
@@ -130,5 +132,21 @@ Answer :: () -> s32 {
g_sync.retry_requested = false
recovery_set_enabled(0)
if app_request_sync(*app) != 0 || g_sync.retry_requested { return 40 }
recovery_set_enabled(1)
recovery_set_queue(1, 0, 1)
status: SyncStatus
if !app_sync_queue_status(*status, now) || status.queued_changes != 1 { return 41 }
reads := recovery_status_reads()
for frame: cast(s32)0..cast(s32)119 {
if !app_sync_queue_status(*status, now) { return 42 }
}
if recovery_status_reads() != reads { return 43 }
recovery_set_queue(2, 0, 1)
if !app_sync_queue_status(*status, now + 0.26) || status.queued_changes != 2 ||
recovery_status_reads() != reads + 1 { return 44 }
// A data revision, including disconnect, invalidates immediately.
recovery_set_enabled(0)
if !app_sync_queue_status(*status, now + 0.27) || status.enabled != 0 ||
recovery_status_reads() != reads + 2 { return 45 }
return 0
}
+4
View File
@@ -13,6 +13,7 @@ static int enabled = 1;
static int64_t queued;
static int repair;
static int full_upload;
static int status_reads;
bool storage_sync_node_failover(void) { return false; }
int32_t app_preview_mode(void) { return 0; }
@@ -60,6 +61,7 @@ storage_sync_enabled(void)
int32_t
storage_sync_status(StorageSyncStatus *status)
{
status_reads++;
memset(status, 0, sizeof(*status));
status->has_account = 1;
status->enabled = enabled;
@@ -69,6 +71,8 @@ storage_sync_status(StorageSyncStatus *status)
return 1;
}
int32_t recovery_status_reads(void) { return status_reads; }
void
recovery_set_time(double seconds)
{
+98
View File
@@ -0,0 +1,98 @@
"""Exercise WHM rendering with a synthetic profile and an owned private display."""
import ast
import contextlib
import json
import os
from pathlib import Path
import re
import subprocess
import sys
import tempfile
import time
ROOT = Path(__file__).resolve().parents[1]
OUTPUT = ROOT / "build/whm-animation-test"
OUTPUT.mkdir(parents=True, exist_ok=True)
DISPLAY_KEYS = ("DISPLAY", "WAYLAND_DISPLAY", "XAUTHORITY", "DBUS_SESSION_BUS_ADDRESS")
assert all(not os.environ.get(key) for key in DISPLAY_KEYS)
BINARY = Path(sys.argv[1]).resolve()
def stop(process):
if process.poll() is None:
process.terminate()
try:
process.wait(timeout=5)
except subprocess.TimeoutExpired:
process.kill()
process.wait(timeout=5)
with tempfile.TemporaryDirectory(prefix="inbe-whm-frames-") as temporary, contextlib.ExitStack() as stack:
env = {key: value for key, value in os.environ.items() if key not in DISPLAY_KEYS}
env.update(APP_DATA_ROOT=temporary, APP_NO_TRAY="1", APP_PROFILE="1",
SDL_AUDIODRIVER="dummy", SDL_VIDEODRIVER="x11", LIBGL_ALWAYS_SOFTWARE="1",
YUE_DESKTOP_RECOVERY="0", INBE_DEBUG_ROUTE="1")
log_path = OUTPUT / "frames.log"
log = stack.enter_context(log_path.open("w"))
display = subprocess.Popen(["Xvfb", "-displayfd", "1", "-screen", "0", "1080x1000x24",
"-nolisten", "tcp"], env=env, stdout=subprocess.PIPE, stderr=log)
stack.callback(stop, display)
number = display.stdout.readline().decode().strip()
display.stdout.close()
assert number.isdecimal(), "Private display did not start"
env["DISPLAY"] = ":" + number
app = subprocess.Popen([str(BINARY), "--bundle", str(ROOT / "build/inbe-full.zib")],
cwd=ROOT, env=env, stdout=log, stderr=log)
stack.callback(stop, app)
def command(*arguments):
return subprocess.check_output(arguments, env=env, text=True, timeout=5).strip()
def wait(read, predicate, label):
deadline = time.monotonic() + 20
while time.monotonic() < deadline:
assert app.poll() is None, log_path.read_text()[-2000:]
try:
value = read()
if predicate(value):
return value
except (subprocess.CalledProcessError, ValueError, SyntaxError, IndexError):
pass
time.sleep(0.05)
raise AssertionError(label)
window = wait(lambda: command("xdotool", "search", "--onlyvisible", "--pid", str(app.pid))
.splitlines()[0], bool, "Owned app window")
command("xdotool", "windowsize", window, "390", "844")
command("xdotool", "windowfocus", window)
def state():
prop = command("xprop", "-id", window, "_HARMONY_APP_STATE")
return json.loads(ast.literal_eval(prop.split(" = ", 1)[1]))
wait(state, lambda value: value.get("interface") == "harmony.app-state.v1", "App state")
command("xprop", "-id", window, "-f", "_HARMONY_APP_ACTION", "8s", "-set",
"_HARMONY_APP_ACTION", json.dumps({"control": "practice.whm.start", "request_id": "whm-frames"}))
started = wait(state, lambda value: value.get("last_request_id") == "whm-frames" and
value.get("last_request_ok") and value.get("practice_running"), "WHM start")
initial_reports = len(re.findall(r"PROFILE: frame", log_path.read_text()))
deadline = time.monotonic() + 14
while time.monotonic() < deadline:
assert app.poll() is None, "Owned test app exited"
time.sleep(0.1)
progressed = state()
assert progressed["practice_running"] and not progressed["paused"]
assert (progressed["round"], progressed["breath"]) > (started["round"], started["breath"])
reports = re.findall(r"PROFILE: frame avg=([\d.]+) max=([\d.]+).*?sync avg=([\d.]+) "
r"max=([\d.]+) fps=([\d.]+)", log_path.read_text())[initial_reports + 1:]
assert len(reports) >= 4, "Not enough measured animation frames"
measurements = [{"cpuAverageMs": float(cpu), "cpuMaxMs": float(peak),
"syncAverageMs": float(sync), "syncMaxMs": float(sync_peak), "fps": float(fps)}
for cpu, peak, sync, sync_peak, fps in reports]
assert min(row["fps"] for row in measurements) >= 55, measurements
assert max(row["cpuAverageMs"] for row in measurements) < 8, measurements
result = {"passed": True, "privateDisplay": True, "syntheticProfile": True,
"screenshots": False, "practiceContinued": True, "measurements": measurements}
(OUTPUT / "frames.json").write_text(json.dumps(result, indent=2) + "\n")
print(json.dumps(result))
+4 -4
View File
@@ -6,8 +6,8 @@ IDI_APP_ICON ICON "inbe.ico"
IDI_NOTIFICATION_ICON ICON "inbe.ico"
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,1,24,0
PRODUCTVERSION 2,1,24,0
FILEVERSION 2,1,25,0
PRODUCTVERSION 2,1,25,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -24,11 +24,11 @@ BEGIN
BEGIN
VALUE "CompanyName", "waozi"
VALUE "FileDescription", "Inner Breeze"
VALUE "FileVersion", "2.1.24"
VALUE "FileVersion", "2.1.25"
VALUE "InternalName", "inbe"
VALUE "OriginalFilename", "inbe-windows-x86_64.exe"
VALUE "ProductName", "Inner Breeze"
VALUE "ProductVersion", "2.1.24"
VALUE "ProductVersion", "2.1.25"
END
END
BLOCK "VarFileInfo"