Reduce Android startup work and show progress until the first frame

This commit is contained in:
waozi committed 2026-10-07 20:42:28 -03:00
1 parent 1fa6d9c8f0
commit b308b573cb
39 files changed
+496 -67

No files matched your search

+8
View File
@@ -1,4 +1,12 @@
# Changelog
## [2.1.16] - 2026-10-07
### Changed
- Open faster by keeping feature packages loaded and loading language fonts only when needed.
- Use Android's installed fonts with automatic character fallback where available.
- Prepare Android audio when first used so it no longer delays opening the app.
### Added
- Show a loading indicator on Android until the first app screen is ready.
## [2.1.15] - 2026-10-07
### Fixed
- Open Telegram sync links on Android when the installed chat app is hidden from app availability checks.
+2 -2
View File
@@ -53,8 +53,8 @@ android {
applicationId "xyz.waozi.inbe"
minSdk 21
targetSdk 36
versionCode 152
versionName "2.1.15"
versionCode 153
versionName "2.1.16"
manifestPlaceholders = [
inbeAppLabel: "Inner Breeze",
inbeUsesCleartextTraffic: "false"
+1 -1
View File
@@ -29,7 +29,7 @@
android:configChanges="keyboardHidden|orientation|screenSize|smallestScreenSize|uiMode"
android:exported="true"
android:launchMode="singleTask"
android:theme="@android:style/Theme.DeviceDefault.NoActionBar"
android:theme="@style/InbeTheme"
android:windowSoftInputMode="stateAlwaysHidden|adjustNothing"
android:windowLayoutInDisplayCutoutMode="never">
<meta-data
@@ -16,17 +16,23 @@ import android.graphics.Insets;
import android.graphics.Rect;
import android.net.Uri;
import android.widget.Toast;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ProgressBar;
import java.io.File;
import java.io.FileOutputStream;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.SystemClock;
import android.util.Log;
import android.webkit.MimeTypeMap;
import android.view.DisplayCutout;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.Gravity;
import android.view.ViewTreeObserver;
import android.util.DisplayMetrics;
import android.view.WindowInsets;
@@ -45,6 +51,48 @@ import java.util.Arrays;
public class MainActivity extends NativeActivity {
private final HttpTransport httpTransport = new HttpTransport();
private FrameLayout startupView;
private boolean firstFrameReady;
private long startupStarted;
private void showStartup() {
startupView = new FrameLayout(this);
startupView.setBackgroundColor(getResources().getColor(R.color.startup_background));
startupView.setClickable(true);
int iconSize = Math.round(144 * getResources().getDisplayMetrics().density);
ImageView icon = new ImageView(this);
icon.setImageResource(R.drawable.ic_launcher_foreground);
icon.setContentDescription(getString(R.string.widget_breathe_app));
FrameLayout.LayoutParams iconLayout = new FrameLayout.LayoutParams(iconSize, iconSize, Gravity.CENTER);
startupView.addView(icon, iconLayout);
ProgressBar progress = new ProgressBar(this);
progress.setIndeterminate(true);
int progressSize = Math.round(28 * getResources().getDisplayMetrics().density);
FrameLayout.LayoutParams progressLayout = new FrameLayout.LayoutParams(progressSize, progressSize, Gravity.CENTER);
progressLayout.topMargin = iconSize + progressSize;
startupView.addView(progress, progressLayout);
addContentView(startupView, new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
}
public void onNativeFirstFrame() {
runOnUiThread(() -> {
if (firstFrameReady || isFinishing() || isDestroyed()) {
return;
}
firstFrameReady = true;
if (startupView != null) {
ViewGroup parent = (ViewGroup)startupView.getParent();
if (parent != null) {
parent.removeView(startupView);
}
startupView = null;
}
reportFullyDrawn();
Log.i("InbeStartup", "First native frame ready in "
+ (SystemClock.elapsedRealtime() - startupStarted) + " ms");
});
}
public int httpCreate(byte[] method, byte[] url, int capacity, int timeout) {
return httpTransport.create(method, url, capacity, timeout);
@@ -809,9 +857,11 @@ public class MainActivity extends NativeActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
startupStarted = SystemClock.elapsedRealtime();
configureSystemBars();
super.onCreate(savedInstanceState);
configureSystemBars();
showStartup();
synchronized (cachedInsets) {
for (int i = 0; i < cachedInsets.length; i++) {
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/startup_background" />
<item android:width="144dp" android:height="144dp" android:gravity="center">
<bitmap android:src="@drawable/ic_launcher_foreground" android:gravity="fill" />
</item>
</layer-list>
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="startup_background">#182838</color>
</resources>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="InbeTheme" parent="android:style/Theme.DeviceDefault.NoActionBar">
<item name="android:windowBackground">@drawable/startup_background</item>
<item name="android:windowSplashScreenBackground">@color/startup_background</item>
<item name="android:windowSplashScreenAnimatedIcon">@drawable/ic_launcher_foreground</item>
</style>
</resources>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="startup_background">#F5F0E8</color>
<style name="InbeTheme" parent="android:style/Theme.DeviceDefault.NoActionBar">
<item name="android:windowBackground">@drawable/startup_background</item>
</style>
</resources>
@@ -0,0 +1,8 @@
Changed
---
- Open faster by keeping feature packages loaded and loading language fonts only when needed.
- Use Android's installed fonts with automatic character fallback where available.
- Prepare Android audio when first used so it no longer delays opening the app.
Added
---
- Show a loading indicator on Android until the first app screen is ready.
+1 -1
View File
@@ -1,5 +1,5 @@
Package: inbe.waozi
Version: 2.1.15
Version: 2.1.16
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.15" date="2026-10-07"/>
<release version="2.1.16" date="2026-10-07"/>
</releases>
<content_rating type="oars-1.1"/>
</component>
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "inbe",
"title": "Inner Breeze",
"version": "2.1.15",
"version": "2.1.16",
"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.15",
"version": "2.1.16",
"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.15" date="2026-10-07"/>
<release version="2.1.16" date="2026-10-07"/>
</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.15" date="2026-10-07"/>
<release version="2.1.16" date="2026-10-07"/>
</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.13'
version: '2.1.16'
license: BSD-3-Clause
base: core22
confinement: strict
+2 -2
View File
@@ -741,12 +741,12 @@ app_init :: (vapp: *void) {
app_apply_initial_screen(app)
practice_update_circle_bounds(app, app_content_top_reserved(app),
app_content_bottom_reserved(app))
#if !#defined(PLATFORM_WEB) {
#if !#defined(PLATFORM_WEB) && !#defined(ANDROID_BUILD) {
if PreviewMode() == 0 {
init_audio(app)
}
}
TraceLog(LOG_INFO, "APP PROBE: audio initialized")
TraceLog(LOG_INFO, "APP PROBE: audio setup complete")
{
i: s32 = 0
while i < practice_count() {
+2
View File
@@ -165,6 +165,7 @@ app_play_breath_cue :: (app: *InnerBreeze, dir: s32) {
if app == null {
return
}
app_audio_ensure_ready(app)
sound = app.breath_out_sound
if dir == 0 {
sound = app.breath_in_sound
@@ -177,6 +178,7 @@ app_play_bell_cue :: (app: *InnerBreeze, scale: float32) {
if app == null {
return
}
app_audio_ensure_ready(app)
app_play_sound(app, app.bell_sound, scale)
}
+15 -16
View File
@@ -6,6 +6,8 @@
language_seed: [96]s32;
language_seed_ready: bool;
language_fonts_ready: bool;
system_fonts_ready: bool;
FontExtensionFor :: (path: string) -> string {
if path == FONT_SC || path == FONT_JP || path == FONT_KR || path == FONT_TC {
@@ -27,15 +29,6 @@ RegisterFontAsset :: (name: string, path: string,
return false
}
RegisterAndroidFontFallbacks :: () {
RegisterTypefaceFile("sys-sc", "/system/fonts/NotoSansSC-Regular.otf", null, 0)
RegisterTypefaceFile("sys-jp", "/system/fonts/NotoSansJP-Regular.otf", null, 0)
RegisterTypefaceFile("sys-kr", "/system/fonts/NotoSansKR-Regular.otf", null, 0)
RegisterTypefaceFile("sys-tc", "/system/fonts/NotoSansTC-Regular.otf", null, 0)
RegisterTypefaceFile("sys-latin", "/system/fonts/NotoSans-Regular.ttf", null, 0)
RegisterTypefaceFile("sys-roboto", "/system/fonts/Roboto-Regular.ttf", null, 0)
}
LanguageSeed :: () -> *s32 {
if !language_seed_ready {
codepoint: s32 = 0x20
@@ -52,6 +45,10 @@ LanguageSeed :: () -> *s32 {
}
RegisterLanguagePickerFonts :: () {
if language_fonts_ready || (AndroidPlatform() != 0 && system_fonts_ready) {
return
}
language_fonts_ready = true
seed := LanguageSeed()
RegisterFontAsset("ui-lang-latin", FONT_LATIN, null, 0)
RegisterFontAsset("ui-lang-ja", FONT_JP, seed, 96)
@@ -106,21 +103,21 @@ LoadLocaleFont :: (app: *InnerBreeze) -> bool {
if PreviewMode() == 0 {
ClearTypefaces()
}
language_fonts_ready = false
system_fonts_ready = false
system_font: bool = false
if DesktopPlatform() != 0 && WindowsPlatform() == 0 && Plan9Platform() == 0 {
if AndroidPlatform() != 0 ||
(DesktopPlatform() != 0 && WindowsPlatform() == 0 && Plan9Platform() == 0) {
system_font = RegisterSystemTypeface("ui")
}
if system_font {
system_fonts_ready = system_font
if system_font && AndroidPlatform() == 0 {
RegisterFontAsset("ui-locale", path, null, 0)
} else if !RegisterFontAsset("ui", path, null, 0) {
} else if !system_font && !RegisterFontAsset("ui", path, null, 0) {
return false
}
if AndroidPlatform() != 0 {
RegisterAndroidFontFallbacks()
}
RegisterLanguagePickerFonts()
if !UseTypeface("ui") {
if PreviewMode() == 0 {
ClearTypefaces()
@@ -138,4 +135,6 @@ ReleaseLocaleFont :: (app: *InnerBreeze) {
if PreviewMode() == 0 {
ClearTypefaces()
}
language_fonts_ready = false
system_fonts_ready = false
}
+2
View File
@@ -7,9 +7,11 @@
#import "locale_policy"
#import "session"
#import, file "locale.zi";
#import, file "fonts.zi";
#program_export
LocaleDropdown :: (session: Session, props: DropdownProps) -> DropdownResult {
RegisterLanguagePickerFonts()
options: [64]DropdownOption
count := LocaleLanguageCount()
if count > 64 {
+53 -13
View File
@@ -616,7 +616,7 @@ CellsOpen :: () -> bool {
}
if ready {
PackageMarkRootActive(downloaded_root)
ready = CellsReloadFeatures(CellsInstalledMask())
CellsOpenInstalledFeatures()
}
if ready && local_bundle_index > 0 {
bytes := PackageRead(TextFromCString(*local_bundle_path[0]), PackageMaximumBytes)
@@ -636,6 +636,35 @@ CellsOpen :: () -> bool {
return ready
}
// Keep already checked bundled instances. Only installed overrides require
// another open, and an invalid override must leave the bundled app usable.
CellsOpenInstalledFeatures :: () {
previous := identifying
identifying = true
defer {
identifying = previous
}
for index: cast(s32)1..PackageCount - 1 {
bytes := PackageInstalledBytes(index)
if bytes.count > 0 {
replacement: ModuleSlot
kind := ModuleKindForPackage(index)
if ModuleOpen(*replacement, bytes, kind) &&
ModuleFeatureAssetsValid(replacement.bundle, kind) {
slot := ModuleSlotForPackage(index)
CloseBundleInstance(slots[slot].instance)
CloseBundle(slots[slot].bundle)
slots[slot] = replacement
} else {
CloseBundleInstance(replacement.instance)
CloseBundle(replacement.bundle)
}
}
PackageFree(bytes)
}
enabled_apps = CellsInstalledMask()
}
PackageFeature :: (index: s32) -> string {
name: string = "cells/practices.zib"
if index == 0 {
@@ -716,7 +745,7 @@ CellsOpenPackage :: (bytes: string) -> bool {
identifying = true
ready := ModuleOpen(*slots[3], bytes, MODULE_INBE)
if ready {
ready = ModulePackageAssetsValid(slots[3].bundle)
ready = ModulePackageAssetsValid(slots[3].bundle, false)
}
if ready {
index: s32 = 0
@@ -730,7 +759,8 @@ CellsOpenPackage :: (bytes: string) -> bool {
slot := ModuleSlotForPackage(index + 1)
kind := ModuleKindForPackage(index + 1)
ready = ModuleOpen(*slots[slot], feature, kind)
ready = ModuleOpen(*slots[slot], feature, kind) &&
ModuleFeatureAssetsValid(slots[slot].bundle, kind)
}
index += 1
}
@@ -853,15 +883,9 @@ CellsValidatePackage :: (index: s32, bytes: string) -> bool {
ok := ModuleOpen(*test, bytes, kind)
if ok {
if index == 0 {
ok = ModulePackageAssetsValid(test.bundle)
ok = ModulePackageAssetsValid(test.bundle, true)
} else {
ok = BundleAssets(test.bundle) <= cast(u64)8192
asset: u64 = 0
while ok && asset < BundleAssets(test.bundle) {
ok = PackageResourceValid(TextFromCString(BundleAssetPath(test.bundle, asset)), kind)
asset += 1
}
ok = ModuleFeatureAssetsValid(test.bundle, kind)
}
}
identifying = previous
@@ -870,7 +894,23 @@ CellsValidatePackage :: (index: s32, bytes: string) -> bool {
return ok
}
ModulePackageAssetsValid :: (bundle: *void) -> bool {
ModuleFeatureAssetsValid :: (bundle: *void, kind: s32) -> bool {
count := BundleAssets(bundle)
if count > cast(u64)8192 {
return false
}
if count == 0 {
return true
}
for asset: cast(u64)0..count - cast(u64)1 {
if !PackageResourceValid(TextFromCString(BundleAssetPath(bundle, asset)), kind) {
return false
}
}
return true
}
ModulePackageAssetsValid :: (bundle: *void, validate_features: bool) -> bool {
count := BundleAssets(bundle)
if count < cast(u64)2 || count > cast(u64)8192 {
return false
@@ -882,7 +922,7 @@ ModulePackageAssetsValid :: (bundle: *void) -> bool {
for feature: cast(s32)0..cast(s32)4 {
if CellBundlePath(TextFromCString(BundleAssetPath(bundle, asset))) == names[feature] && !found[feature] {
bytes := TextFromBytes(BytesFromPointer(BundleAssetBytes(bundle, asset), BundleAssetLength(bundle, asset)))
if !CellsValidatePackage(feature + 1, bytes) {
if validate_features && !CellsValidatePackage(feature + 1, bytes) {
return false
}
found[feature] = true
+2 -2
View File
@@ -3,7 +3,7 @@
#define APP_VERSION_MAJOR 2
#define APP_VERSION_MINOR 1
#define APP_VERSION_PATCH 15
#define APP_VERSION_STRING "2.1.15"
#define APP_VERSION_PATCH 16
#define APP_VERSION_STRING "2.1.16"
#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 :: 15
VersionString :: "2.1.15"
VersionPatch :: 16
VersionString :: "2.1.16"
+13
View File
@@ -0,0 +1,13 @@
#import, file "activity_jni.zi";
// Notify the activity only after the native renderer submits its first frame.
AndroidStartupComplete :: () {
session: ActivityJniSession
if activity_jni_attach(*session) == 0 {
return
}
defer {
activity_jni_detach(*session)
}
unused JniCallVoid(*session, "onNativeFirstFrame", null)
}
+5
View File
@@ -18,6 +18,7 @@ app_getenv_bytes :: (name: *u8) -> *u8 #foreign c;
#import, file "../app/metrics.zi";
#import, file "../app/dpi_state.zi";
#import, file "environment.zi";
#import, file "android/android_startup.zi";
#import, file "raylib_host.zi";
#if #defined(PLATFORM_WEB) == false {
#import, file "../../build/packages/kryon/src/backend/raylib_runtime.zi";
@@ -125,6 +126,7 @@ native_update_apply_at_exit :: () -> s32 #foreign c;
}
Prepare :: (argc: s32, argv: **u8) {
app_frame_probe_count = 0
native_limit_allocators()
screenshot := current_screenshot_request()
args: [128]string
@@ -449,6 +451,9 @@ app_frame :: (app: *InnerBreeze) {
}
if first_frame {
TraceLog(LOG_INFO, "APP PROBE: drawing ended")
#if #defined(ANDROID_BUILD) {
AndroidStartupComplete()
}
}
PumpSecondaryWindows()
if app.ui.frame_target_changed {
+13 -1
View File
@@ -69,6 +69,7 @@ OpenStream :: (path: *u8, mode: *u8) -> *void #foreign c "fopen";
}
#if #defined(ANDROID_BUILD) {
android_log :: #system_library "log";
AndroidWrite :: (priority: s32, tag: *u8, text: *u8) -> s32 #foreign android_log "__android_log_write";
#if TRACE_STRUCT_ARGUMENTS {
AndroidPrint :: (priority: s32, tag: *u8, format: *u8,
arguments: TraceArguments) -> s32 #foreign android_log "__android_log_vprint";
@@ -131,6 +132,17 @@ FilteredTrace :: (level: s32, format: *u8, arguments: TraceArguments) {
return
}
#if #defined(ANDROID_BUILD) {
if level == 3 {
message: [1024]u8
FormatArguments(*message[0], 1024, format, arguments)
message[1023] = 0
if TraceStartsWith(*message[0], "APP PROBE:") {
tag: [16]u8
unused CopyCString("InbeStartup", tag[:])
unused AndroidWrite(4, *tag[0], *message[0])
}
return
}
if level >= 4 {
tag: [16]u8
if CopyCString("InnerBreeze", tag[:]) {
@@ -208,7 +220,7 @@ native_install_trace_log_filter :: () {
#if #defined(KRYON_BACKEND_TERMI) {
name: [32]u8
if CopyCString("APP_TERMI_LOG", name[:]) &&
GetEnvironment(*name[0]) == null {
GetEnvironment(*name[0]) == null {
SetLogLevel(7)
return
}
+7
View File
@@ -9,6 +9,7 @@
#import, file "../src/platform/android/android_runtime_assets_host.zi";
#import, file "../src/platform/android/android_insets.zi";
#import, file "../src/platform/android/android_network.zi";
#import, file "../src/platform/android/android_startup.zi";
#import, file "../src/app/host_services.zi";
#import "net_http"
#import "async_client"
@@ -566,7 +567,13 @@ main :: () -> s32 {
transport.cancel(transport.context)
Require(transfer.handle == 0 && transfer.output.count == 0 &&
network_cancelled == 4 && frame_count == 0, 101)
before_startup_calls := void_calls
AndroidStartupComplete()
Require(void_calls == before_startup_calls + 1 &&
CStringEquals(*method_name[0], "onNativeFirstFrame") && frame_count == 0, 102)
activity_ready = false
AndroidStartupComplete()
Require(void_calls == before_startup_calls + 1 && frame_count == 0, 103)
Require(!health_connect_send_host(*path[0]), 82)
Require(frame_count == 0, 83)
return 0
+1 -1
View File
@@ -19,7 +19,7 @@ MODULES = [
"activity_jni", "android_mutex", "android_health_host",
"android_wakelock_host", "android_share", "android_import_host",
"android_push_host", "android_push_types", "android_device",
"android_runtime_assets_host", "android_insets", "android_network",
"android_runtime_assets_host", "android_insets", "android_network", "android_startup",
]
SOURCES = [ROOT / f"src/platform/android/{name}.zi" for name in MODULES]
SOURCES.append(ROOT / "src/platform/uri_host.zi")
+165
View File
@@ -0,0 +1,165 @@
#include "audio_runtime.h"
#include <assert.h>
#include <stdio.h>
#include <string.h>
static bool ready;
static int initialized;
static int played;
static unsigned int played_frames;
void InitAudioDevice(void)
{
assert(!ready);
ready = true;
initialized++;
}
bool IsAudioDeviceReady(void)
{
return ready;
}
void CloseAudioDevice(void)
{
ready = false;
}
NativeWave LoadWaveFromMemory(unsigned char *extension, unsigned char *bytes, int size)
{
assert(ready && extension && bytes && size > 0);
NativeWave wave = {0};
wave.frame_count = 128;
wave.data = bytes;
return wave;
}
NativeWave LoadWave(unsigned char *path)
{
(void)path;
assert(0);
return (NativeWave){0};
}
void WaveFormat(NativeWave *wave, int rate, int bits, int channels)
{
(void)rate;
(void)bits;
(void)channels;
assert(wave->frame_count);
}
void UnloadWave(NativeWave wave)
{
assert(wave.frame_count);
}
NativeSound LoadSoundFromWave(NativeWave wave)
{
NativeSound sound = {0};
sound.frame_count = wave.frame_count;
return sound;
}
bool IsSoundValid(NativeSound sound)
{
return sound.frame_count > 0;
}
void UnloadSound(NativeSound sound)
{
assert(sound.frame_count);
}
void StopSound(NativeSound sound)
{
assert(sound.frame_count);
}
void PlaySound(NativeSound sound)
{
assert(ready && sound.frame_count);
played++;
played_frames = sound.frame_count;
}
bool IsSoundPlaying(NativeSound sound)
{
return ready && sound.frame_count == played_frames;
}
void SetSoundVolume(NativeSound sound, float volume)
{
assert(sound.frame_count && volume > 0);
}
void SetSoundPitch(NativeSound sound, float pitch)
{
assert(sound.frame_count && pitch > 0);
}
void AttachAudioMixedProcessor(void (*callback)(void *, unsigned int))
{
assert(callback);
}
void DetachAudioMixedProcessor(void (*callback)(void *, unsigned int))
{
assert(callback);
}
int app_preview_mode(void)
{
return 0;
}
int app_plan9_platform(void)
{
return 0;
}
void app_audio_trace(int level, String message)
{
if(level >= 5) {
fprintf(stderr, "%.*s\n", (int)message.length, message.data);
}
assert(level < 5);
}
void app_audio_trace_frames(int level, String message, int frames)
{
(void)message;
assert(level < 5 && frames > 0);
}
void app_audio_meter_raise(int value)
{
(void)value;
}
unsigned char *app_audio_decoder_data(String bytes)
{
return (unsigned char *)bytes.data;
}
String app_audio_cstring_view(Slice bytes)
{
return StringView((char *)bytes.data, strlen((char *)bytes.data));
}
String app_audio_cstring_pointer(unsigned char *bytes, int capacity)
{
(void)capacity;
return StringView((char *)bytes, strlen((char *)bytes));
}
bool app_audio_file_readable(Slice path)
{
(void)path;
return false;
}
int CheckSound(SoundHandle sound)
{
return sound.frame_count > 0 && played == initialized && played_frames == sound.frame_count;
}
+21
View File
@@ -0,0 +1,21 @@
#!/bin/sh
set -eu
root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
bin=${1:-"$root/build/ziran-toolchain/bin"}
work=$root/build/audio-first-cue
generated=$work/generated
mkdir -p "$generated"
"$bin/ziran" build --target=c --define PLATFORM_DESKTOP --root "$root/tests" \
--module-path "$root/src" --module-path "$root/build/packages/kryon/src/ui" \
--module-path "$root/build/packages/kryon/src/backend" --module-path "$root/build/packages/ziran/std" \
--module-path "$root/build/packages/daochi-client" --module-path "$root/build/packages/kss/src" \
--module-path "$root/build/packages/game2d/src" --module-path "kryon=$root/build/packages/kryon/src/ui" \
--module-path "oqs=$root/build/packages/oqs/src" -o "$generated" "$root/tests/audio_first_cue_test.zi"
python3 "$root/scripts/embed-app-assets.py" "$work/assets.c" \
"$root/assets/sounds/bell.ogg" "$root/assets/sounds/breath-in.ogg" "$root/assets/sounds/breath-out.ogg"
"${CC:-cc}" -std=c11 -O0 -ffunction-sections -fdata-sections \
-I"$root/build/packages/ziran/include" -I"$generated" -I"$root/src/app" \
"$generated"/*.c "$work/assets.c" "$root/tests/audio_first_cue_host.c" \
-Wl,--gc-sections -lm -o "$work/test"
env -u DISPLAY -u WAYLAND_DISPLAY -u XAUTHORITY -u DBUS_SESSION_BUS_ADDRESS "$work/test"
echo 'First bell and breath cues initialize audio and play on the first request'
+19
View File
@@ -0,0 +1,19 @@
#import, file "../src/app/audio.zi";
#import, file "../src/app/app_types.zi";
#import, file "../src/platform/media_types.zi";
#import, file "../src/core/breath_timing.zi";
c :: #system_library "c";
CheckSound :: (sound: SoundHandle) -> s32 #foreign c;
#program_export
main :: () -> s32 {
app: InnerBreeze
app.sound_volume = 100
app.breathing.speed_level = 1
app_play_bell_cue(*app, 1.0)
if app.audio_ready == 0 || CheckSound(app.bell_sound) == 0 { return 1 }
app_audio_shutdown(*app)
app_play_breath_cue(*app, 0)
if app.audio_ready == 0 || CheckSound(app.breath_in_sound) == 0 { return 2 }
app_audio_shutdown(*app)
return 0
}
+1
View File
@@ -22,3 +22,4 @@ trap 'rm -rf "$work"' EXIT HUP INT TERM
"$root/tests/audio_runtime_zi_test.c" "$work/audio_runtime.o" \
-o "$work/test"
"$work/test"
sh "$root/tests/audio_first_cue_test.sh" "$bin"
+13
View File
@@ -6,6 +6,8 @@
c_cache :: #system_library "c";
ModuleTestUseCache :: (enabled: bool) #foreign c_cache;
ModuleTestCachedReads :: (index: s32) -> s32 #foreign c_cache;
ModuleTestBundleOpens :: () -> s32 #foreign c_cache;
ModuleTestCorruptCachedLists :: (enabled: bool) #foreign c_cache;
ModuleTestFailInstantiate :: () #foreign c_cache;
#import, file "../src/cells/shared_state.zi";
#import, file "../src/cells/lists_types.zi";
@@ -447,12 +449,23 @@ CheckModules :: () -> s32 {
storage_close()
CellsClose()
ModuleTestUseCache(true)
cached_opens := ModuleTestBundleOpens()
Expect(CellsOpen(), 96)
Expect(ModuleTestBundleOpens() - cached_opens == 11, 103)
for index: cast(s32)1..cast(s32)5 {
Expect(ModuleTestCachedReads(index) > 0, 97)
}
Expect(CellsInstalledMask() == APP_ALL, 98)
CellsClose()
ModuleTestCorruptCachedLists(true)
Expect(CellsOpen() && CellsInstalledMask() == APP_ALL, 104)
Expect(ListsRun(ListsMessage.{.action = LISTS_ROUTE, .screen = ScreenEList}).succeeded, 105)
CellsClose()
ModuleTestCorruptCachedLists(false)
ModuleTestUseCache(false)
before_opens := ModuleTestBundleOpens()
Expect(CellsOpenPackage(ModuleTestText("inbe")), 101)
Expect(ModuleTestBundleOpens() - before_opens == 6, 102)
CellsClose()
return failures
}
+20
View File
@@ -11,9 +11,28 @@ static size_t sizes[10];
static int32_t module_runs;
static bool use_cached_bundles;
static int32_t cached_reads[6];
static int32_t bundle_opens;
static bool corrupt_cached_lists;
static bool fail_next_instance;
static bool fail_next_run;
Bundle *__real_BundleOpenBytes(const unsigned char *data, size_t count);
Bundle *__wrap_BundleOpenBytes(const unsigned char *data, size_t count)
{
bundle_opens++;
return __real_BundleOpenBytes(data, count);
}
int32_t ModuleTestBundleOpens(void)
{
return bundle_opens;
}
void ModuleTestCorruptCachedLists(bool enabled)
{
corrupt_cached_lists = enabled;
}
BundleInstance *__real_BundleInstantiate(const Bundle *bundle,
const HostBinding *bindings, size_t count);
@@ -107,6 +126,7 @@ String __wrap_package_manager_PackageInstalledBytes(int32_t index)
cached_reads[index]++;
const int fixture[] = {5, 0, 1, 2, 8, 9};
int source = fixture[index];
if(index == 1 && corrupt_cached_lists) source = 7;
char *copy = malloc(sizes[source]);
assert(copy);
memcpy(copy, payloads[source], sizes[source]);
+1 -1
View File
@@ -63,7 +63,7 @@ cp "$root/build/cells/habits.zib" "$root/build/cells/practices.zib" "$work/inval
"$root/build/packages/monocypher/src/monocypher.c" \
"$root/build/packages/monocypher/src/optional/monocypher-ed25519.c" \
"$root/vendor-builds/sqlite/sqlite3.c" "$liboqs" "$root/build/ziran-toolchain/libziran.a" \
-Wl,--wrap=tmpfile -Wl,--wrap=BundleInstanceRun -Wl,--wrap=BundleInstantiate \
-Wl,--wrap=tmpfile -Wl,--wrap=BundleInstanceRun -Wl,--wrap=BundleInstantiate -Wl,--wrap=BundleOpenBytes \
-Wl,--wrap=package_manager_PackageInstalledBytes -Wl,--gc-sections -ldl -lpthread -lz -lm -o "$work/test"
# All data and fixture upgrade paths are disposable. No owner profile is used.
data=$(mktemp -d)
+19 -3
View File
@@ -9,6 +9,7 @@ fixture_file_count :: () -> s32 #foreign c "fixture_file_count";
fixture_clear_count :: () -> s32 #foreign c "fixture_clear_count";
fixture_main_otf :: () -> s32 #foreign c "fixture_main_otf";
fixture_system_count :: () -> s32 #foreign c "fixture_system_count";
fixture_system_available :: (available: s32) #foreign c "fixture_system_available";
#program_export
Answer :: () -> s32 {
@@ -23,9 +24,14 @@ Answer :: () -> s32 {
if !LoadLocaleFont(*app) {
return 2
}
if fixture_data_count() != 5 || fixture_main_otf() == 0 {
if fixture_data_count() != 1 || fixture_main_otf() == 0 {
return 3
}
RegisterLanguagePickerFonts()
RegisterLanguagePickerFonts()
if fixture_data_count() != 5 {
return 14
}
if fixture_clear_count() != 1 {
return 4
}
@@ -39,7 +45,7 @@ Answer :: () -> s32 {
if fixture_system_count() != 1 {
return 6
}
if fixture_data_count() != 10 {
if fixture_data_count() != 6 {
return 7
}
@@ -47,10 +53,12 @@ Answer :: () -> s32 {
if !LoadLocaleFont(*app) {
return 8
}
if fixture_file_count() != 6 {
RegisterLanguagePickerFonts()
if fixture_system_count() != 2 || fixture_file_count() != 0 || fixture_data_count() != 6 {
return 9
}
fixture_system_available(0)
fixture_preview(1)
if !LoadLocaleFont(*app) {
return 10
@@ -58,6 +66,14 @@ Answer :: () -> s32 {
if fixture_clear_count() != 3 {
return 11
}
if fixture_data_count() != 7 {
return 15
}
RegisterLanguagePickerFonts()
RegisterLanguagePickerFonts()
if fixture_data_count() != 11 {
return 16
}
ReleaseLocaleFont(*app)
if fixture_clear_count() != 3 {
return 12
+3 -1
View File
@@ -11,6 +11,7 @@ static int file_count;
static int clear_count;
static int system_count;
static int main_otf;
static int system_available = 1;
void fixture_platform(int value) { platform = value; }
void fixture_preview(int value) { preview = value; }
@@ -19,6 +20,7 @@ int fixture_file_count(void) { return file_count; }
int fixture_clear_count(void) { return clear_count; }
int fixture_main_otf(void) { return main_otf; }
int fixture_system_count(void) { return system_count; }
void fixture_system_available(int value) { system_available = value; }
int app_preview_mode(void) { return preview; }
int app_desktop_platform(void) { return platform == 1; }
@@ -56,7 +58,7 @@ bool LoadSystemTypeface(String name)
{
assert(name.length == 2 && memcmp(name.data, "ui", 2) == 0);
system_count++;
return true;
return system_available != 0;
}
bool SelectTypeface(String name)
+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,15,0
PRODUCTVERSION 2,1,15,0
FILEVERSION 2,1,16,0
PRODUCTVERSION 2,1,16,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -24,11 +24,11 @@ BEGIN
BEGIN
VALUE "CompanyName", "waozi"
VALUE "FileDescription", "Inner Breeze"
VALUE "FileVersion", "2.1.15"
VALUE "FileVersion", "2.1.16"
VALUE "InternalName", "inbe"
VALUE "OriginalFilename", "inbe-windows-x86_64.exe"
VALUE "ProductName", "Inner Breeze"
VALUE "ProductVersion", "2.1.15"
VALUE "ProductVersion", "2.1.16"
END
END
BLOCK "VarFileInfo"
+11 -11
View File
@@ -38,20 +38,12 @@
},
{
"commit": "396f1efedb702b1aacdd724a7b611302d95a0adc",
"dependencies": {"kryon": "p99a7d913a522175f"},
"dependencies": {"kryon": "pf5f4da0800f55578"},
"id": "p7b9204ab0ad2089f",
"name": "Game2D",
"ref": "master",
"url": "https://github.com/kryonlabs/game2d.git"
},
{
"commit": "ebb15b7ecfcccfb939ec17a505e46fcc33d3af54",
"dependencies": {"raylib": "p5a77c9c35110e925"},
"id": "p99a7d913a522175f",
"name": "kryon",
"ref": "master",
"url": "https://github.com/kryonlabs/kryon.git"
},
{
"commit": "e6b9e783747536f34700aab4bd10718c2fecab3f",
"dependencies": {},
@@ -79,6 +71,14 @@
"source": true,
"url": "https://github.com/LoupVaillant/Monocypher.git"
},
{
"commit": "ae3e8deb548440e6b55ae6d3baa9c7b54aa58d6e",
"dependencies": {"raylib": "p5a77c9c35110e925"},
"id": "pf5f4da0800f55578",
"name": "kryon",
"ref": "master",
"url": "https://github.com/kryonlabs/kryon.git"
},
{
"commit": "9490329ca73baf6a00ade5e037c706631d90b26e",
"dependencies": {"oqs": "p55635fc8976895a9"},
@@ -89,7 +89,7 @@
},
{
"commit": "e1f07e615e9255a513dbb6d66e5e6e9d335ef690",
"dependencies": {"kryon": "p99a7d913a522175f"},
"dependencies": {"kryon": "pf5f4da0800f55578"},
"id": "pfdf70946e0505dfe",
"name": "Kss",
"ref": "master",
@@ -97,7 +97,7 @@
}
],
"root": {
"dependencies": {"curl": "pc4b263336680098b", "daochi_client": "pf6b43abf57c5519f", "game2d": "p7b9204ab0ad2089f", "kryon": "p99a7d913a522175f", "kss": "pfdf70946e0505dfe", "liboqs": "pb34994bf01670ac3", "monocypher": "pccdfe79ccaafde45", "oqs": "p55635fc8976895a9", "rini": "p09fa77e94b0dfc6c", "sqlite": "p151b83a361c86f2d"},
"dependencies": {"curl": "pc4b263336680098b", "daochi_client": "pf6b43abf57c5519f", "game2d": "p7b9204ab0ad2089f", "kryon": "pf5f4da0800f55578", "kss": "pfdf70946e0505dfe", "liboqs": "pb34994bf01670ac3", "monocypher": "pccdfe79ccaafde45", "oqs": "p55635fc8976895a9", "rini": "p09fa77e94b0dfc6c", "sqlite": "p151b83a361c86f2d"},
"name": "Inbe"
},
"toolchain": {