fix: Android event handler lost after restart — g_event_handler now preserved

Root cause: instance_lite_restart was creating new thread without
re-setting g_event_handler, causing all chat events (CHANNEL_UPDATED,
CONNECT_RESULT, etc.) to be silently dropped after app restart.

Fixes:
- instance_lite_restart: save/restore g_event_handler across hard restart
- instance_thread restart loop: re-call chat_event_set_handler after uasync_create
- utun_bridge_restart: call instance_lite_set_event_handler before restart
- AppEventHandler SharedFlow replay: 1 → 16 to not lose early init events
- ViewModel: added diagnostic logging for channel/connect events
- Keep diagnostic logs in instance_lite (set_handler, chat_event_forward NULL check)
- instance_event_handler: removed static for cross-block forward declaration
This commit is contained in:
evgeny committed 2026-08-06 00:06:28 +03:00
1 parent ef637d33a6
commit 38eb51c679
5 files changed
+37 -9

No files matched your search

+8
View File
@@ -8,9 +8,17 @@
#include "chat_event.h"
#include "../lib/debug_config.h"
#ifdef __ANDROID__
#include <android/log.h>
#endif
static chat_event_handler_fn g_handler = NULL;
void chat_event_set_handler(chat_event_handler_fn handler) {
#ifdef __ANDROID__
__android_log_print(ANDROID_LOG_INFO, "utun-evt", "chat_event_set_handler: handler=%p old=%p",
(void*)handler, (void*)g_handler);
#endif
g_handler = handler;
}