Seed legacy platform storage explicitly and drop Android app handles

This commit is contained in:
2026-06-17 01:34:05 +02:00
parent 3ce365fc15
commit fd462dc406
9 changed files with 72 additions and 29 deletions

View File

@@ -582,10 +582,10 @@ NSString* keyCodeToString(NSUInteger keyCode, NSUInteger mods)
{ {
LOG("error creating rec path: %s", [[err localizedDescription] cStringUsingEncoding:NSASCIIStringEncoding]); LOG("error creating rec path: %s", [[err localizedDescription] cStringUsingEncoding:NSASCIIStringEncoding]);
} }
App::I->data_path = [docpath cStringUsingEncoding:NSASCIIStringEncoding]; const std::string data_path = [docpath cStringUsingEncoding:NSASCIIStringEncoding];
NSString* recpath = [docpath stringByAppendingString:@"/rec"]; NSString* recpath = [docpath stringByAppendingString:@"/rec"];
App::I->rec_path = [recpath cStringUsingEncoding:NSASCIIStringEncoding]; const std::string recording_path = [recpath cStringUsingEncoding:NSASCIIStringEncoding];
if (![[NSFileManager defaultManager] createDirectoryAtPath:recpath withIntermediateDirectories:YES attributes:nil error:&err]) if (![[NSFileManager defaultManager] createDirectoryAtPath:recpath withIntermediateDirectories:YES attributes:nil error:&err])
{ {
LOG("error creating rec path: %s", [[err localizedDescription] cStringUsingEncoding:NSASCIIStringEncoding]); LOG("error creating rec path: %s", [[err localizedDescription] cStringUsingEncoding:NSASCIIStringEncoding]);
@@ -613,6 +613,13 @@ NSString* keyCodeToString(NSUInteger keyCode, NSUInteger mods)
{ {
LOG("error creating settings path: %s", [[err localizedDescription] cStringUsingEncoding:NSASCIIStringEncoding]); LOG("error creating settings path: %s", [[err localizedDescription] cStringUsingEncoding:NSASCIIStringEncoding]);
} }
pp::platform::legacy::set_legacy_storage_paths({
data_path,
data_path,
recording_path,
{},
});
} }
@end @end

View File

@@ -112,19 +112,19 @@ std::recursive_mutex lock_mutex;
{ {
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString* docpath = (NSString*)[paths objectAtIndex:0]; NSString* docpath = (NSString*)[paths objectAtIndex:0];
App::I->data_path = [docpath cStringUsingEncoding:NSASCIIStringEncoding]; const std::string data_path = [docpath cStringUsingEncoding:NSASCIIStringEncoding];
NSError* err = nil; NSError* err = nil;
NSString* recpath = [docpath stringByAppendingString:@"/rec"]; NSString* recpath = [docpath stringByAppendingString:@"/rec"];
App::I->rec_path = [recpath cStringUsingEncoding:NSASCIIStringEncoding]; const std::string recording_path = [recpath cStringUsingEncoding:NSASCIIStringEncoding];
if (![[NSFileManager defaultManager] createDirectoryAtPath:recpath withIntermediateDirectories:YES attributes:nil error:&err]) if (![[NSFileManager defaultManager] createDirectoryAtPath:recpath withIntermediateDirectories:YES attributes:nil error:&err])
{ {
LOG("error creating rec path: %s", [[err localizedDescription] cStringUsingEncoding:NSASCIIStringEncoding]); LOG("error creating rec path: %s", [[err localizedDescription] cStringUsingEncoding:NSASCIIStringEncoding]);
} }
// tmp // tmp
NSString* tmppath = [docpath stringByAppendingString:@"/tmp"]; NSString* tmppath = [docpath stringByAppendingString:@"/tmp"];
App::I->tmp_path = [tmppath cStringUsingEncoding:NSASCIIStringEncoding]; const std::string temporary_path = [tmppath cStringUsingEncoding:NSASCIIStringEncoding];
if (![[NSFileManager defaultManager] createDirectoryAtPath:tmppath withIntermediateDirectories:YES attributes:nil error:&err]) if (![[NSFileManager defaultManager] createDirectoryAtPath:tmppath withIntermediateDirectories:YES attributes:nil error:&err])
{ {
LOG("error creating rec path: %s", [[err localizedDescription] cStringUsingEncoding:NSASCIIStringEncoding]); LOG("error creating rec path: %s", [[err localizedDescription] cStringUsingEncoding:NSASCIIStringEncoding]);
@@ -152,6 +152,13 @@ std::recursive_mutex lock_mutex;
{ {
LOG("error creating settings path: %s", [[err localizedDescription] cStringUsingEncoding:NSASCIIStringEncoding]); LOG("error creating settings path: %s", [[err localizedDescription] cStringUsingEncoding:NSASCIIStringEncoding]);
} }
pp::platform::legacy::set_legacy_storage_paths({
data_path,
data_path,
recording_path,
temporary_path,
});
} }
- (void)pick_photo:(std::function<void(std::string)>) callback - (void)pick_photo:(std::function<void(std::string)>) callback

View File

@@ -31,6 +31,7 @@
#include "pch.h" #include "pch.h"
#include "app.h" #include "app.h"
#include "platform_legacy/legacy_platform_state.h"
#include "asset.h" #include "asset.h"
#include "keymap.h" #include "keymap.h"
#include "main.h" #include "main.h"
@@ -274,6 +275,12 @@ JNIEXPORT void JNICALL Java_com_omixlab_panopainter_MainActivity_pickExternalCal
App::I->data_path = file_path; App::I->data_path = file_path;
App::I->work_path = file_path; App::I->work_path = file_path;
App::I->rec_path = file_path + "/frames"; App::I->rec_path = file_path + "/frames";
pp::platform::legacy::set_legacy_storage_paths({
App::I->data_path,
App::I->work_path,
App::I->rec_path,
App::I->tmp_path,
});
App::I->initLog(); App::I->initLog();
} }
@@ -605,7 +612,6 @@ static int engine_init_display(struct engine* engine) {
if (resuming_context) if (resuming_context)
{ {
LOG("RESUME APP"); LOG("RESUME APP");
App::I->and_app = engine->app;
LOG("release egl context"); LOG("release egl context");
eglMakeCurrent(engine->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglMakeCurrent(engine->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
mutex.unlock(); mutex.unlock();
@@ -703,14 +709,18 @@ static int engine_init_display(struct engine* engine) {
LOG("PROP Mode: %s", os_props["ro.product.model"].c_str()); LOG("PROP Mode: %s", os_props["ro.product.model"].c_str());
Asset::set_android_asset_manager(engine->app->activity->assetManager); Asset::set_android_asset_manager(engine->app->activity->assetManager);
App::I->and_app = engine->app;
App::I->and_engine = engine;
//std::string base_path = engine->app->activity->externalDataPath ? //std::string base_path = engine->app->activity->externalDataPath ?
// engine->app->activity->externalDataPath : get_data_path(engine->app); // engine->app->activity->externalDataPath : get_data_path(engine->app);
if (App::I->data_path.empty() || App::I->data_path == ".") if (App::I->data_path.empty() || App::I->data_path == ".")
App::I->data_path = get_data_path(); App::I->data_path = get_data_path();
LOG("data_path %s", App::I->data_path.c_str()); LOG("data_path %s", App::I->data_path.c_str());
pp::platform::legacy::set_legacy_storage_paths({
App::I->data_path,
App::I->work_path.empty() ? App::I->data_path : App::I->work_path,
App::I->rec_path,
App::I->tmp_path,
});
#ifdef __QUEST__ #ifdef __QUEST__

View File

@@ -92,6 +92,14 @@ Current hotspot files:
Latest slice: Latest slice:
- `App` no longer owns `and_app` or `and_engine`; the retained Android
entrypoint now seeds only the explicit legacy platform storage snapshot
needed by touched platform services instead of storing Android-native
handles on the app singleton.
- `active_legacy_storage_paths()` no longer snapshots `App::I` lazily inside
`src/platform_legacy/legacy_platform_state.*`; storage roots are now seeded
explicitly from app startup plus the iOS, macOS, and Android entrypoints
through `set_legacy_storage_paths(...)`.
- `pp_platform_api` no longer compiles - `pp_platform_api` no longer compiles
`src/platform_linux/linux_platform_services.*`; Linux concrete platform code `src/platform_linux/linux_platform_services.*`; Linux concrete platform code
now lives in `pp_platform_linux`, which `pp_legacy_app` and now lives in `pp_platform_linux`, which `pp_legacy_app` and
@@ -215,9 +223,11 @@ Current architecture mismatches that must be treated as real blockers:
the retained GLFW window hooks, Apple handle snapshots, and fallback the retained GLFW window hooks, Apple handle snapshots, and fallback
storage-path return now also using local retained-state helpers instead of storage-path return now also using local retained-state helpers instead of
direct method-body reads, while Windows VR session snapshot state now also direct method-body reads, while Windows VR session snapshot state now also
lives behind platform-owned helpers instead of on `App`, and the lives behind platform-owned helpers instead of on `App`, the
`platform_legacy`-mirrored Apple/GLFW handle cluster is now seeded `platform_legacy`-mirrored Apple/GLFW handle cluster is now seeded
explicitly from platform entrypoints instead of being copied out of `App`. explicitly from platform entrypoints instead of being copied out of `App`,
and retained storage roots are now also seeded explicitly instead of being
lazily copied from `App::I` inside `active_legacy_storage_paths()`.
- `src/platform_legacy/legacy_platform_services.*` is still part of the live - `src/platform_legacy/legacy_platform_services.*` is still part of the live
app shell. app shell.
- `pp_panopainter_ui` still depends on `pp_legacy_app`. - `pp_panopainter_ui` still depends on `pp_legacy_app`.

View File

@@ -1147,6 +1147,9 @@ Current slice:
- retained storage-path state now also lives in - retained storage-path state now also lives in
`src/platform_legacy/legacy_platform_state.*` instead of staying inline in `src/platform_legacy/legacy_platform_state.*` instead of staying inline in
`src/platform_legacy/legacy_platform_services.cpp` `src/platform_legacy/legacy_platform_services.cpp`
- `active_legacy_storage_paths()` now consumes storage roots seeded explicitly
through `set_legacy_storage_paths(...)` from app startup plus the iOS,
macOS, and Android entrypoints instead of lazily snapshotting `App::I`
- retained GLFW window hooks/state and retained Apple UI/app handle state now - retained GLFW window hooks/state and retained Apple UI/app handle state now
also live in `src/platform_legacy/legacy_platform_state.*`, and also live in `src/platform_legacy/legacy_platform_state.*`, and
`src/platform_legacy/legacy_platform_services.cpp` now consumes those `src/platform_legacy/legacy_platform_services.cpp` now consumes those
@@ -1204,8 +1207,11 @@ Current slice:
lives on `App`; retained Apple/GLFW platform state is now seeded explicitly lives on `App`; retained Apple/GLFW platform state is now seeded explicitly
from the iOS, macOS, Linux, and WebGL entrypoints through from the iOS, macOS, Linux, and WebGL entrypoints through
`src/platform_legacy/legacy_platform_state.*`. `src/platform_legacy/legacy_platform_state.*`.
- `App` still owns Android-native handles plus broader retained legacy - `App` also no longer owns `and_app` or `and_engine`; the retained Android
platform state, so this remains a live ownership task. entrypoint now seeds only the explicit legacy platform storage snapshot
needed by touched platform services.
- `App` still owns broader retained legacy platform state, so this remains a
live ownership task.
Write scope: Write scope:
- `src/platform_legacy/legacy_platform_services.*` - `src/platform_legacy/legacy_platform_services.*`

View File

@@ -155,10 +155,6 @@ public:
int idle_ms = 100; int idle_ms = 100;
pp::platform::PlatformServices* platform_services_ = nullptr; pp::platform::PlatformServices* platform_services_ = nullptr;
#ifdef __ANDROID__
struct android_app* and_app;
struct engine* and_engine;
#endif
std::string clipboard_get_text(); std::string clipboard_get_text();
bool clipboard_set_text(const std::string& s); bool clipboard_set_text(const std::string& s);
void pick_image(std::function<void(std::string path)> callback); void pick_image(std::function<void(std::string path)> callback);

View File

@@ -7,6 +7,7 @@
#include "legacy_gl_runtime_dispatch.h" #include "legacy_gl_runtime_dispatch.h"
#include "legacy_preference_storage.h" #include "legacy_preference_storage.h"
#include "legacy_ui_gl_dispatch.h" #include "legacy_ui_gl_dispatch.h"
#include "platform_legacy/legacy_platform_state.h"
#include "platform_api/platform_services.h" #include "platform_api/platform_services.h"
#include "renderer_gl/opengl_capabilities.h" #include "renderer_gl/opengl_capabilities.h"
@@ -134,6 +135,12 @@ void execute_legacy_app_init_log(App& app)
// TODO: save this path somewhere in the settings, don't overwrite every start // TODO: save this path somewhere in the settings, don't overwrite every start
app.work_path = paths.work_path.empty() ? app.data_path : paths.work_path; app.work_path = paths.work_path.empty() ? app.data_path : paths.work_path;
pp::platform::legacy::set_legacy_storage_paths({
app.data_path,
app.work_path,
app.rec_path,
app.tmp_path,
});
//LogRemote::I.start(); //LogRemote::I.start();
LogRemote::I.file_init(); LogRemote::I.file_init();

View File

@@ -1,8 +1,6 @@
#include "pch.h" #include "pch.h"
#include "platform_legacy/legacy_platform_state.h" #include "platform_legacy/legacy_platform_state.h"
#include "app.h"
#if defined(__LINUX__) || defined(__WEB__) #if defined(__LINUX__) || defined(__WEB__)
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#endif #endif
@@ -14,6 +12,12 @@ struct RetainedLegacyStoragePaths final {
pp::platform::PlatformStoragePaths storage_paths; pp::platform::PlatformStoragePaths storage_paths;
}; };
[[nodiscard]] RetainedLegacyStoragePaths& retained_legacy_storage_paths()
{
static RetainedLegacyStoragePaths state;
return state;
}
} }
#if defined(__LINUX__) || defined(__WEB__) #if defined(__LINUX__) || defined(__WEB__)
@@ -78,17 +82,12 @@ void set_legacy_apple_state(
[[nodiscard]] const pp::platform::PlatformStoragePaths& active_legacy_storage_paths() [[nodiscard]] const pp::platform::PlatformStoragePaths& active_legacy_storage_paths()
{ {
static RetainedLegacyStoragePaths state = [] { return retained_legacy_storage_paths().storage_paths;
RetainedLegacyStoragePaths retained; }
retained.storage_paths = {
App::I->data_path, void set_legacy_storage_paths(pp::platform::PlatformStoragePaths paths)
App::I->work_path, {
App::I->rec_path, retained_legacy_storage_paths().storage_paths = std::move(paths);
App::I->tmp_path,
};
return retained;
}();
return state.storage_paths;
} }
} }

View File

@@ -59,5 +59,6 @@ void set_legacy_apple_state(
#endif #endif
[[nodiscard]] const pp::platform::PlatformStoragePaths& active_legacy_storage_paths(); [[nodiscard]] const pp::platform::PlatformStoragePaths& active_legacy_storage_paths();
void set_legacy_storage_paths(pp::platform::PlatformStoragePaths paths);
} }