koreader / android-luajit-launcher

Android NativeActivity based launcher for LuaJIT, implementing the main loop within Lua land via FFI
MIT License
130 stars 83 forks source link

Nitpick - first install wrong notch resolution #463

Closed hugleo closed 4 months ago

hugleo commented 7 months ago

The thing on first install is that framebuffer resolution is getted before the onAttachedToWindow is called (we don't have a windows yet, we have just the permission dialog) so we don't get the notch inset to subtract from resolution.

01-13 18:16:36.459 26129 26516 V dlopen  : dl.dlopen - load_func -> /data/user/0/org.koreader.launcher.debug/files/./libs/libblitbuffer.so
01-13 18:16:36.469 26129 26516 V KOReader: fts: Preferred MONOTONIC clock source is CLOCK_MONOTONIC
01-13 18:16:36.469 26129 26516 V KOReader: fts: Preferred REALTIME clock source is CLOCK_REALTIME
01-13 18:16:36.469 26129 26516 V KOReader: fts: BOOTTIME clock source is supported
01-13 18:16:36.484 26129 26516 I KOReader: Android 13 - S (API 33) - flavor: rocks
01-13 18:16:36.498 26129 26516 W KOReader: cannot blit: no window
01-13 18:16:36.528 26129 26516 I KOReader: initializing for device spes_global
01-13 18:16:36.528 26129 26516 I KOReader: framebuffer resolution: {
01-13 18:16:36.528 26129 26516 I KOReader:   h = 2400,
01-13 18:16:36.528 26129 26516 I KOReader:   w = 1080
01-13 18:16:36.528 26129 26516 I KOReader: } --[[table: 0x789f7fe420]]

And when we resume then the lib is already loaded and we stuck with the wrong framebuffer resolution because the function "initializing for device spes_global" is not executed again.

Details bellow:

When we first install Koreader we got the asking permission message

photo_2024-01-13_18-37-14

If we go to the android floating apps we see koreader and we enter Koreader from there:

photo_2024-01-13_18-48-38

The bottom area is cutted because the wrong framebuffer resolution

photo_2024-01-13_18-49-08

We have to close and reopen to get right:

photo_2024-01-13_18-49-12

Log from first install:

01-13 18:16:30.390 26129 26129 I MainActivity: loading libluajit
01-13 18:16:30.426  1865  2148 I ActivityManager: Start proc 26515:com.google.android.partnersetup/u0a204 for service {com.google.android.partnersetup/com.google.android.partnersetup.InstalledAppJobService} caller=android
01-13 18:16:30.444 26129 26129 D NativeGlue: Creating: 0xb4000078bc6cc540
01-13 18:16:30.445 26129 26516 V NativeGlue: User FIFO already exists at `/data/user/0/org.koreader.launcher.debug/files/alooper.fifo`
01-13 18:16:30.445 26129 26516 D NativeThread: Starting
01-13 18:16:30.445 26129 26516 V NativeThread: waiting for activity
01-13 18:16:30.445 26129 26129 I Assets  : loading lib7z
01-13 18:16:30.446 26129 26129 I Lights  : Using Generic driver
01-13 18:16:30.448 26129 26129 V Surface : Using Native Content implementation
01-13 18:16:30.448 26129 26129 V MainActivity: native orientation: portrait
01-13 18:16:30.449 26129 26129 V EventReceiver: Filtering 3 events: 
01-13 18:16:30.449 26129 26129 V EventReceiver: android.intent.action.ACTION_POWER_CONNECTED
01-13 18:16:30.449 26129 26129 V EventReceiver: android.intent.action.ACTION_POWER_DISCONNECTED
01-13 18:16:30.449 26129 26129 V EventReceiver: android.intent.action.DOWNLOAD_COMPLETE
01-13 18:16:30.458 26129 26129 V NativeGlue: Start: 0xb4000078bc6cc540
01-13 18:16:30.458 26129 26516 D NativeGlue: activityState=10
01-13 18:16:30.461 26129 26516 V NativeThread: Launching LuaJIT assets
01-13 18:16:30.461 26129 26129 V NativeGlue: Resume: 0xb4000078bc6cc540
01-13 18:16:30.477 26129 26516 I Assets  : New install
01-13 18:16:30.479 26129 26516 V Assets  : Uncompressing module/koreader.7z
01-13 18:16:30.610  1865  2148 I ActivityManager: Start proc 26542:com.google.android.apps.turbo:aab/u0a203 for service {com.google.android.apps.turbo/com.google.android.libraries.smartbattery.appusage.library.InferAppBucketsJob} caller=android
01-13 18:16:30.612  1865  6920 I ActivityManager: Killing 26048:com.google.android.webview:webview_service/u0a214 (adj 965): empty #9
01-13 18:16:30.614  1865  6920 I ActivityManager: Killing 25285:com.android.htmlviewer:remote/u0a165 (adj 975): empty #10
01-13 18:16:31.017  1865  6087 I ActivityManager: Killing 25970:com.android.vending:background/u0a201 (adj 975): empty #9
01-13 18:16:34.988 26129 26516 V Assets  : Reading symlinks map from module/map.txt
01-13 18:16:36.343 26129 26516 I Assets  : update installed in 5866 milliseconds
01-13 18:16:36.346 26129 26516 D KOReader: try to load module libs/libkoreader-lfs.so
01-13 18:16:36.354 26129 26516 I dlopen  : dl.dlopen - libs/libkoreader-lfs.so => /data/user/0/org.koreader.launcher.debug/files/libs/libkoreader-lfs.so
01-13 18:16:36.354 26129 26516 V dlopen  :     dl.dlopen - needed => libluajit.so (1 of 2) <= /data/user/0/org.koreader.launcher.debug/files/libs/libkoreader-lfs.so
01-13 18:16:36.354 26129 26516 V dlopen  :     dl.dlopen - libluajit.so => /data/app/~~4TfY6c9EL_zD_5AnhK_c7g==/org.koreader.launcher.debug-MkO0qlSxd08frOj5vmXaPg==/lib/arm64/libluajit.so
01-13 18:16:36.355 26129 26516 V dlopen  :         dl.dlopen - needed => libm.so (1 of 5) <= /data/app/~~4TfY6c9EL_zD_5AnhK_c7g==/org.koreader.launcher.debug-MkO0qlSxd08frOj5vmXaPg==/lib/arm64/libluajit.so
01-13 18:16:36.355 26129 26516 V dlopen  :         dl.dlopen - libm.so => /system/lib64/libm.so
01-13 18:16:36.355 26129 26516 V dlopen  :         dl.dlopen - skipping /system/lib64/libm.so (system lib)
01-13 18:16:36.355 26129 26516 V dlopen  :         dl.dlopen - needed => libdl.so (2 of 5) <= /data/app/~~4TfY6c9EL_zD_5AnhK_c7g==/org.koreader.launcher.debug-MkO0qlSxd08frOj5vmXaPg==/lib/arm64/libluajit.so
01-13 18:16:36.356 26129 26516 V dlopen  :         dl.dlopen - libdl.so => /system/lib64/libdl.so
01-13 18:16:36.356 26129 26516 V dlopen  :         dl.dlopen - skipping /system/lib64/libdl.so (system lib)
01-13 18:16:36.356 26129 26516 V dlopen  :         dl.dlopen - needed => libandroid.so (3 of 5) <= /data/app/~~4TfY6c9EL_zD_5AnhK_c7g==/org.koreader.launcher.debug-MkO0qlSxd08frOj5vmXaPg==/lib/arm64/libluajit.so
01-13 18:16:36.356 26129 26516 V dlopen  :         dl.dlopen - libandroid.so => /system/lib64/libandroid.so
01-13 18:16:36.356 26129 26516 V dlopen  :         dl.dlopen - skipping /system/lib64/libandroid.so (system lib)
01-13 18:16:36.356 26129 26516 V dlopen  :         dl.dlopen - needed => liblog.so (4 of 5) <= /data/app/~~4TfY6c9EL_zD_5AnhK_c7g==/org.koreader.launcher.debug-MkO0qlSxd08frOj5vmXaPg==/lib/arm64/libluajit.so
01-13 18:16:36.357 26129 26516 V dlopen  :         dl.dlopen - liblog.so => /system/lib64/liblog.so
01-13 18:16:36.357 26129 26516 V dlopen  :         dl.dlopen - skipping /system/lib64/liblog.so (system lib)
01-13 18:16:36.357 26129 26516 V dlopen  :         dl.dlopen - needed => libc.so (5 of 5) <= /data/app/~~4TfY6c9EL_zD_5AnhK_c7g==/org.koreader.launcher.debug-MkO0qlSxd08frOj5vmXaPg==/lib/arm64/libluajit.so
01-13 18:16:36.357 26129 26516 V dlopen  :         dl.dlopen - libc.so => /system/lib64/libc.so
01-13 18:16:36.357 26129 26516 V dlopen  :         dl.dlopen - skipping /system/lib64/libc.so (system lib)
01-13 18:16:36.357 26129 26516 V dlopen  :     sys_dlopen - loading library /data/app/~~4TfY6c9EL_zD_5AnhK_c7g==/org.koreader.launcher.debug-MkO0qlSxd08frOj5vmXaPg==/lib/arm64/libluajit.so (in local namespace)
01-13 18:16:36.358 26129 26516 V dlopen  :     dl.dlopen - needed => libc.so (2 of 2) <= /data/user/0/org.koreader.launcher.debug/files/libs/libkoreader-lfs.so
01-13 18:16:36.358 26129 26516 V dlopen  :     dl.dlopen - libc.so => /system/lib64/libc.so
01-13 18:16:36.358 26129 26516 V dlopen  :     dl.dlopen - skipping /system/lib64/libc.so (system lib)
01-13 18:16:36.358 26129 26516 V dlopen  : sys_dlopen - loading library /data/user/0/org.koreader.launcher.debug/files/libs/libkoreader-lfs.so (in local namespace)
01-13 18:16:36.361 26129 26516 D KOReader: ffi.load rt.so.1
01-13 18:16:36.363 26129 26516 W dlopen  : could not find library rt.so.1
01-13 18:16:36.390 26129 26516 D KOReader: ffi.load libs/libutf8proc.so.3
01-13 18:16:36.391 26129 26516 I dlopen  : dl.dlopen - libs/libutf8proc.so.3 => /data/user/0/org.koreader.launcher.debug/files/libs/libutf8proc.so.3
01-13 18:16:36.392 26129 26516 V dlopen  :     dl.dlopen - needed => libc.so (1 of 1) <= /data/user/0/org.koreader.launcher.debug/files/libs/libutf8proc.so.3
01-13 18:16:36.392 26129 26516 V dlopen  :     dl.dlopen - libc.so => /system/lib64/libc.so
01-13 18:16:36.392 26129 26516 V dlopen  :     dl.dlopen - skipping /system/lib64/libc.so (system lib)
01-13 18:16:36.392 26129 26516 V dlopen  : dl.dlopen - load_func -> /data/user/0/org.koreader.launcher.debug/files/libs/libutf8proc.so.3
01-13 18:16:36.454 26129 26516 D KOReader: ffi.load blitbuffer
01-13 18:16:36.457 26129 26516 W dlopen  : could not find library blitbuffer
01-13 18:16:36.457 26129 26516 D KOReader: ffi.load ./libs/libblitbuffer.so
01-13 18:16:36.457 26129 26516 I dlopen  : dl.dlopen - ./libs/libblitbuffer.so => /data/user/0/org.koreader.launcher.debug/files/./libs/libblitbuffer.so
01-13 18:16:36.458 26129 26516 V dlopen  :     dl.dlopen - needed => libc.so (1 of 1) <= /data/user/0/org.koreader.launcher.debug/files/./libs/libblitbuffer.so
01-13 18:16:36.459 26129 26516 V dlopen  :     dl.dlopen - libc.so => /system/lib64/libc.so
01-13 18:16:36.459 26129 26516 V dlopen  :     dl.dlopen - skipping /system/lib64/libc.so (system lib)
01-13 18:16:36.459 26129 26516 V dlopen  : dl.dlopen - load_func -> /data/user/0/org.koreader.launcher.debug/files/./libs/libblitbuffer.so
01-13 18:16:36.469 26129 26516 V KOReader: fts: Preferred MONOTONIC clock source is CLOCK_MONOTONIC
01-13 18:16:36.469 26129 26516 V KOReader: fts: Preferred REALTIME clock source is CLOCK_REALTIME
01-13 18:16:36.469 26129 26516 V KOReader: fts: BOOTTIME clock source is supported
01-13 18:16:36.484 26129 26516 I KOReader: Android 13 - S (API 33) - flavor: rocks
01-13 18:16:36.498 26129 26516 W KOReader: cannot blit: no window
01-13 18:16:36.528 26129 26516 I KOReader: initializing for device spes_global
01-13 18:16:36.528 26129 26516 I KOReader: framebuffer resolution: {
01-13 18:16:36.528 26129 26516 I KOReader:   h = 2400,
01-13 18:16:36.528 26129 26516 I KOReader:   w = 1080
01-13 18:16:36.528 26129 26516 I KOReader: } --[[table: 0x789f7fe420]]
01-13 18:16:36.537 26129 26516 D KOReader: ffi.load libs/libmupdf.so
...

01-13 18:16:37.620 26129 26516 D NativeGlue: Post APP_CMD_RESUME
01-13 18:16:37.621 26129 26516 V KOReader: input event => type: 4 (EV_MSC), code: 11 (nil), value: 1, time: 533021.846452
01-13 18:16:37.621 26129 26516 V KOReader: Android application event 11
01-13 18:16:37.623 26129 26129 V Timeout : onResume: updating system timeout: 1
01-13 18:16:37.623 26129 26129 V Timeout : onResume
01-13 18:16:37.624 26129 26516 V KOReader: InputContainer:setIgnoreTouchInput false
01-13 18:16:37.640 26129 26129 V NativeGlue: InputQueueCreated: 0xb4000078bc6cc540 -- 0xb4000078bc638a00
01-13 18:16:37.641 26129 26516 D NativeGlue:  APP_CMD_INPUT_CHANGED
01-13 18:16:37.641 26129 26516 D NativeGlue: Attaching input queue to looper
01-13 18:16:37.641 26129 26516 V KOReader: input event => type: 4 (EV_MSC), code: 0 (nil), value: 1, time: 533021.866742
01-13 18:16:37.641 26129 26516 V KOReader: Android application event 0
01-13 18:16:37.756 26129 26129 D Surface : onAttachedToWindow()
01-13 18:16:37.757 26129 26129 V Surface : top 93 pixels are not available, reason: window inset
01-13 18:16:37.789 26129 26129 V NativeGlue: NativeWindowCreated: 0xb4000078bc6cc540 -- 0xb4000077e64d4810
01-13 18:16:37.790 26129 26516 D NativeGlue: APP_CMD_INIT_WINDOW
01-13 18:16:37.790 26129 26516 V KOReader: input event => type: 4 (EV_MSC), code: 1 (nil), value: 1, time: 533022.015650
01-13 18:16:37.790 26129 26516 V KOReader: Android application event 1
01-13 18:16:37.791 26129 26129 V Surface : surface changed {
01-13 18:16:37.791 26129 26129 V Surface :   width:  1080
01-13 18:16:37.791 26129 26129 V Surface :   height: 2307
01-13 18:16:37.791 26129 26129 V Surface :  format: RGB_565
01-13 18:16:37.791 26129 26129 V Surface : }
01-13 18:16:37.791 26129 26129 V NativeGlue: NativeWindowResized: 0xb4000078bc6cc540 -- 0xb4000077e64d4810
01-13 18:16:37.795 26129 26129 V NativeGlue: ContentRectChanged: l=0,t=0,r=1080,b=2177
01-13 18:16:37.800 26129 26129 V NativeGlue: NativeWindowRedrawNeeded: 0xb4000078bc6cc540 -- 0xb4000077e64d4810
01-13 18:16:37.824 26129 26129 V NativeGlue: NativeWindowRedrawNeeded: 0xb4000078bc6cc540 -- 0xb4000077e64d4810
01-13 18:16:37.837 26129 26516 V KOReader: input event => type: 4 (EV_MSC), code: 3 (MSC_RAW), value: 1, time: 533022.063417
01-13 18:16:37.838 26129 26516 V KOReader: Android application event 3
01-13 18:16:37.838 26129 26516 V KOReader: input event => type: 4 (EV_MSC), code: 5 (nil), value: 1, time: 533022.063434
01-13 18:16:37.838 26129 26516 V KOReader: Android application event 5
01-13 18:16:37.838 26129 26516 V KOReader: input event => type: 4 (EV_MSC), code: 4 (nil), value: 1, time: 533022.063442
01-13 18:16:37.838 26129 26516 V KOReader: Android application event 4
01-13 18:16:37.857 26129 26129 V NativeGlue: WindowFocusChanged: 0xb4000078bc6cc540 -- 1
01-13 18:16:37.871 26129 26516 V KOReader: input event => type: 4 (EV_MSC), code: 4 (nil), value: 1, time: 533022.063452
01-13 18:16:37.871 26129 26516 V KOReader: Android application event 4
01-13 18:16:37.900 26129 26516 V KOReader: input event => type: 4 (EV_MSC), code: 6 (nil), value: 1, time: 533022.126315
01-13 18:16:37.900 26129 26516 V KOReader: Android application event 6
01-13 18:16:37.928 26129 26129 V NativeGlue: ContentRectChanged: l=0,t=0,r=1080,b=2307
01-13 18:16:37.929 26129 26516 V KOReader: input event => type: 4 (EV_MSC), code: 5 (nil), value: 1, time: 533022.154836
01-13 18:16:37.929 26129 26516 V KOReader: Android application event 5
01-13 18:16:50.620  1865  5608 I ActivityManager: Killing 26180:com.xiaomi.glgm/u0a366 (adj 975): empty #9
01-13 18:17:23.809  1865  2747 W ActivityManager: Sending non-protected broadcast miui.extm.action.mark from system uid 1000 pkg android. Callers=com.android.server.am.ActivityManagerService.broadcastIntentLocked:14940 com.android.server.am.ActivityManagerService.broadcastIntentInPackage:15125 com.android.server.am.ActivityManagerService$LocalService.broadcastIntentInPackage:17694 com.android.server.am.PendingIntentRecord.sendInner:511 com.android.server.am.PendingIntentRecord.sendWithResult:309 
01-13 18:17:30.481  1865  2250 W ActivityManager: Unable to start service Intent { act=miui.action.CAMERA_EMPTY_SERVICE pkg=com.android.camera } U=0: not found
01-13 18:17:30.538 26129 26129 V NativeGlue: Pause: 0xb4000078bc6cc540
01-13 18:17:30.538 26129 26516 D NativeGlue: activityState=13
01-13 18:17:30.539 26129 26516 V KOReader: input event => type: 4 (EV_MSC), code: 13 (nil), value: 1, time: 533074.764542
01-13 18:17:30.540 26129 26516 V KOReader: Android application event 13
01-13 18:17:30.542 26129 26129 V Timeout : onPause
01-13 18:17:30.565 26129 26129 V NativeGlue: NativeWindowDestroyed: 0xb4000078bc6cc540 -- 0xb4000077e64d4810
01-13 18:17:30.592 26129 26516 V KOReader: NetworkListener: onSuspend
01-13 18:17:30.592 26129 26516 V KOReader: NetworkListener: unschedule network activity check
01-13 18:17:30.592 26129 26516 D NativeGlue: APP_CMD_TERM_WINDOW
01-13 18:17:30.592 26129 26516 D NativeGlue: Post APP_CMD_TERM_WINDOW
01-13 18:17:30.593 26129 26516 V KOReader: input event => type: 4 (EV_MSC), code: 2 (nil), value: 1, time: 533074.818228
01-13 18:17:30.594 26129 26516 V KOReader: Android application event 2
01-13 18:17:30.596 26129 26129 V NativeGlue: Stop: 0xb4000078bc6cc540
01-13 18:17:30.596 26129 26516 D NativeGlue: activityState=14
01-13 18:17:30.596 26129 26516 V KOReader: input event => type: 4 (EV_MSC), code: 14 (nil), value: 1, time: 533074.822237
01-13 18:17:30.597 26129 26516 V KOReader: Android application event 14
01-13 18:17:30.597 26129 26129 V NativeGlue: SaveInstanceState: 0xb4000078bc6cc540
01-13 18:17:30.597 26129 26516 D NativeGlue: Post APP_CMD_SAVE_STATE
01-13 18:17:30.598 26129 26516 V KOReader: input event => type: 4 (EV_MSC), code: 12 (nil), value: 1, time: 533074.823360
01-13 18:17:30.598 26129 26516 V KOReader: Android application event 12
01-13 18:17:30.618 26129 26129 V NativeGlue: WindowFocusChanged: 0xb4000078bc6cc540 -- 0
01-13 18:17:30.619 26129 26516 V KOReader: input event => type: 4 (EV_MSC), code: 7 (nil), value: 1, time: 533074.844638
01-13 18:17:30.619 26129 26516 V KOReader: Android application event 7
01-13 18:17:31.044  1865  6113 W ActivityManager: Unable to start service Intent { pkg=com.miui.securitycenter cmp=com.miui.securitycenter/com.miui.apppredict.service.AiService } U=0: not found
01-13 18:17:31.143  1865  2148 I ActivityManager: Start proc 26602:com.miui.msa.global:ui/u0a168 for service {com.miui.msa.global/com.xiaomi.ad.internal.splash.uiprocess.SplashUIService} caller=com.miui.msa.global
01-13 18:17:31.228  1865  6113 I ActivityManager: Killing 26135:com.xiaomi.discover/u0a146 (adj 975): empty #9
01-13 18:18:04.034  1865  2148 I ActivityManager: Start proc 26657:android.process.acore/u0a126 for content provider {com.android.providers.contacts/com.android.providers.contacts.ContactsProvider2} caller=com.google.android.apps.messaging
01-13 18:18:04.605  1865  6113 I ActivityManager: Killing 26281:com.android.camera/u0a117 (adj 600): empty #9
01-13 18:18:06.692  1865  2148 I ActivityManager: Start proc 26686:com.android.camera/u0a117 for FastRestart com.android.camera caller=android
01-13 18:18:07.261  1865  5587 I ActivityManager: Killing 25733:com.google.android.permissioncontroller/u0a261 (adj 965): empty #9
01-13 18:18:08.057  1865  2148 I ActivityManager: Start proc 26729:com.android.htmlviewer:remote/u0a165 for content provider {com.android.htmlviewer/com.android.settings.cloud.CloudSettingsProvider} caller=com.android.camera

Log from subsquents runs after close:

01-13 18:19:36.684  1865  2148 I ActivityManager: Start proc 26910:org.koreader.launcher.debug/u0a524 for next-top-activity {org.koreader.launcher.debug/org.koreader.launcher.MainActivity} caller=com.miui.home
01-13 18:19:36.992 26910 26910 I MainActivity: loading libluajit
01-13 18:19:37.046 26910 26910 D NativeGlue: Creating: 0xb4000078bc6cc540
01-13 18:19:37.047 26910 26947 V NativeGlue: User FIFO already exists at `/data/user/0/org.koreader.launcher.debug/files/alooper.fifo`
01-13 18:19:37.047 26910 26947 D NativeThread: Starting
01-13 18:19:37.047 26910 26947 V NativeThread: waiting for activity
01-13 18:19:37.062 26910 26910 I Assets  : loading lib7z
01-13 18:19:37.070 26910 26910 I Lights  : Using Generic driver
01-13 18:19:37.076 26910 26910 V Surface : Using Native Content implementation
01-13 18:19:37.077 26910 26910 V MainActivity: native orientation: portrait
01-13 18:19:37.086 26910 26910 V EventReceiver: Filtering 3 events: 
01-13 18:19:37.086 26910 26910 V EventReceiver: android.intent.action.ACTION_POWER_CONNECTED
01-13 18:19:37.086 26910 26910 V EventReceiver: android.intent.action.ACTION_POWER_DISCONNECTED
01-13 18:19:37.086 26910 26910 V EventReceiver: android.intent.action.DOWNLOAD_COMPLETE
01-13 18:19:37.092 26910 26910 V NativeGlue: Start: 0xb4000078bc6cc540
01-13 18:19:37.092 26910 26947 D NativeGlue: activityState=10
01-13 18:19:37.096 26910 26910 V NativeGlue: Resume: 0xb4000078bc6cc540
01-13 18:19:37.096 26910 26947 D NativeGlue: activityState=11
01-13 18:19:37.096 26910 26947 D NativeGlue: Post APP_CMD_RESUME
01-13 18:19:37.097 26910 26910 V Timeout : onResume: updating system timeout: 1
01-13 18:19:37.097 26910 26910 V Timeout : onResume
01-13 18:19:37.114 26910 26910 V NativeGlue: InputQueueCreated: 0xb4000078bc6cc540 -- 0xb4000078bc638a00
01-13 18:19:37.114 26910 26947 D NativeGlue:  APP_CMD_INPUT_CHANGED
01-13 18:19:37.114 26910 26947 D NativeGlue: Attaching input queue to looper
01-13 18:19:37.125 26910 26910 D Surface : onAttachedToWindow()
01-13 18:19:37.125 26910 26910 V Surface : top 93 pixels are not available, reason: window inset
01-13 18:19:37.146 26910 26910 V NativeGlue: NativeWindowCreated: 0xb4000078bc6cc540 -- 0xb4000077e64f9810
01-13 18:19:37.147 26910 26947 D NativeGlue: APP_CMD_INIT_WINDOW
01-13 18:19:37.147 26910 26947 V NativeThread: Activity window ready.
01-13 18:19:37.163 26910 26910 V Surface : surface changed {
01-13 18:19:37.163 26910 26910 V Surface :   width:  1080
01-13 18:19:37.163 26910 26910 V Surface :   height: 2307
01-13 18:19:37.163 26910 26910 V Surface :  format: RGB_565
01-13 18:19:37.163 26910 26910 V Surface : }
01-13 18:19:37.163 26910 26910 V NativeGlue: NativeWindowResized: 0xb4000078bc6cc540 -- 0xb4000077e64f9810
01-13 18:19:37.174 26910 26910 V NativeGlue: ContentRectChanged: l=0,t=0,r=1080,b=2177
01-13 18:19:37.176 26910 26910 V NativeGlue: NativeWindowRedrawNeeded: 0xb4000078bc6cc540 -- 0xb4000077e64f9810
01-13 18:19:37.192 26910 26910 V NativeGlue: NativeWindowRedrawNeeded: 0xb4000078bc6cc540 -- 0xb4000077e64f9810
01-13 18:19:37.196 26910 26910 V NativeGlue: WindowFocusChanged: 0xb4000078bc6cc540 -- 1
01-13 18:19:37.196 26910 26947 V NativeThread: Activity gained focus.
01-13 18:19:37.199 26910 26947 V NativeThread: Launching LuaJIT assets
01-13 18:19:37.214 26910 26947 I Assets  : Skip installation for revision v2023.10-83-gccbfbabb2_2024-01-05
01-13 18:19:37.215 26910 26947 D KOReader: try to load module libs/libkoreader-lfs.so
01-13 18:19:37.216 26910 26947 I dlopen  : dl.dlopen - libs/libkoreader-lfs.so => /data/user/0/org.koreader.launcher.debug/files/libs/libkoreader-lfs.so
01-13 18:19:37.216 26910 26947 V dlopen  :     dl.dlopen - needed => libluajit.so (1 of 2) <= /data/user/0/org.koreader.launcher.debug/files/libs/libkoreader-lfs.so
01-13 18:19:37.216 26910 26947 V dlopen  :     dl.dlopen - libluajit.so => /data/app/~~4TfY6c9EL_zD_5AnhK_c7g==/org.koreader.launcher.debug-MkO0qlSxd08frOj5vmXaPg==/lib/arm64/libluajit.so
01-13 18:19:37.217 26910 26947 V dlopen  :         dl.dlopen - needed => libm.so (1 of 5) <= /data/app/~~4TfY6c9EL_zD_5AnhK_c7g==/org.koreader.launcher.debug-MkO0qlSxd08frOj5vmXaPg==/lib/arm64/libluajit.so
01-13 18:19:37.217 26910 26947 V dlopen  :         dl.dlopen - libm.so => /system/lib64/libm.so
01-13 18:19:37.217 26910 26947 V dlopen  :         dl.dlopen - skipping /system/lib64/libm.so (system lib)
01-13 18:19:37.217 26910 26947 V dlopen  :         dl.dlopen - needed => libdl.so (2 of 5) <= /data/app/~~4TfY6c9EL_zD_5AnhK_c7g==/org.koreader.launcher.debug-MkO0qlSxd08frOj5vmXaPg==/lib/arm64/libluajit.so
01-13 18:19:37.218 26910 26947 V dlopen  :         dl.dlopen - libdl.so => /system/lib64/libdl.so
01-13 18:19:37.218 26910 26947 V dlopen  :         dl.dlopen - skipping /system/lib64/libdl.so (system lib)
01-13 18:19:37.218 26910 26947 V dlopen  :         dl.dlopen - needed => libandroid.so (3 of 5) <= /data/app/~~4TfY6c9EL_zD_5AnhK_c7g==/org.koreader.launcher.debug-MkO0qlSxd08frOj5vmXaPg==/lib/arm64/libluajit.so
01-13 18:19:37.218 26910 26947 V dlopen  :         dl.dlopen - libandroid.so => /system/lib64/libandroid.so
01-13 18:19:37.218 26910 26947 V dlopen  :         dl.dlopen - skipping /system/lib64/libandroid.so (system lib)
01-13 18:19:37.218 26910 26947 V dlopen  :         dl.dlopen - needed => liblog.so (4 of 5) <= /data/app/~~4TfY6c9EL_zD_5AnhK_c7g==/org.koreader.launcher.debug-MkO0qlSxd08frOj5vmXaPg==/lib/arm64/libluajit.so
01-13 18:19:37.219 26910 26947 V dlopen  :         dl.dlopen - liblog.so => /system/lib64/liblog.so
01-13 18:19:37.219 26910 26947 V dlopen  :         dl.dlopen - skipping /system/lib64/liblog.so (system lib)
01-13 18:19:37.219 26910 26947 V dlopen  :         dl.dlopen - needed => libc.so (5 of 5) <= /data/app/~~4TfY6c9EL_zD_5AnhK_c7g==/org.koreader.launcher.debug-MkO0qlSxd08frOj5vmXaPg==/lib/arm64/libluajit.so
01-13 18:19:37.219 26910 26947 V dlopen  :         dl.dlopen - libc.so => /system/lib64/libc.so
01-13 18:19:37.219 26910 26947 V dlopen  :         dl.dlopen - skipping /system/lib64/libc.so (system lib)
01-13 18:19:37.219 26910 26947 V dlopen  :     sys_dlopen - loading library /data/app/~~4TfY6c9EL_zD_5AnhK_c7g==/org.koreader.launcher.debug-MkO0qlSxd08frOj5vmXaPg==/lib/arm64/libluajit.so (in local namespace)
01-13 18:19:37.220 26910 26947 V dlopen  :     dl.dlopen - needed => libc.so (2 of 2) <= /data/user/0/org.koreader.launcher.debug/files/libs/libkoreader-lfs.so
01-13 18:19:37.220 26910 26947 V dlopen  :     dl.dlopen - libc.so => /system/lib64/libc.so
01-13 18:19:37.220 26910 26947 V dlopen  :     dl.dlopen - skipping /system/lib64/libc.so (system lib)
01-13 18:19:37.220 26910 26947 V dlopen  : sys_dlopen - loading library /data/user/0/org.koreader.launcher.debug/files/libs/libkoreader-lfs.so (in local namespace)
01-13 18:19:37.223 26910 26947 D KOReader: ffi.load rt.so.1
01-13 18:19:37.225 26910 26947 W dlopen  : could not find library rt.so.1
01-13 18:19:37.233 26910 26910 V NativeGlue: ContentRectChanged: l=0,t=0,r=1080,b=2307
01-13 18:19:37.239 26910 26947 D KOReader: ffi.load libs/libutf8proc.so.3
01-13 18:19:37.239 26910 26947 I dlopen  : dl.dlopen - libs/libutf8proc.so.3 => /data/user/0/org.koreader.launcher.debug/files/libs/libutf8proc.so.3
01-13 18:19:37.240 26910 26947 V dlopen  :     dl.dlopen - needed => libc.so (1 of 1) <= /data/user/0/org.koreader.launcher.debug/files/libs/libutf8proc.so.3
01-13 18:19:37.241 26910 26947 V dlopen  :     dl.dlopen - libc.so => /system/lib64/libc.so
01-13 18:19:37.241 26910 26947 V dlopen  :     dl.dlopen - skipping /system/lib64/libc.so (system lib)
01-13 18:19:37.241 26910 26947 V dlopen  : dl.dlopen - load_func -> /data/user/0/org.koreader.launcher.debug/files/libs/libutf8proc.so.3
01-13 18:19:37.267 26910 26947 D KOReader: ffi.load blitbuffer
01-13 18:19:37.267 26910 26947 W dlopen  : could not find library blitbuffer
01-13 18:19:37.268 26910 26947 D KOReader: ffi.load ./libs/libblitbuffer.so
01-13 18:19:37.268 26910 26947 I dlopen  : dl.dlopen - ./libs/libblitbuffer.so => /data/user/0/org.koreader.launcher.debug/files/./libs/libblitbuffer.so
01-13 18:19:37.268 26910 26947 V dlopen  :     dl.dlopen - needed => libc.so (1 of 1) <= /data/user/0/org.koreader.launcher.debug/files/./libs/libblitbuffer.so
01-13 18:19:37.269 26910 26947 V dlopen  :     dl.dlopen - libc.so => /system/lib64/libc.so
01-13 18:19:37.269 26910 26947 V dlopen  :     dl.dlopen - skipping /system/lib64/libc.so (system lib)
01-13 18:19:37.269 26910 26947 V dlopen  : dl.dlopen - load_func -> /data/user/0/org.koreader.launcher.debug/files/./libs/libblitbuffer.so
01-13 18:19:37.273 26910 26947 V KOReader: fts: Preferred MONOTONIC clock source is CLOCK_MONOTONIC
01-13 18:19:37.273 26910 26947 V KOReader: fts: Preferred REALTIME clock source is CLOCK_REALTIME
01-13 18:19:37.273 26910 26947 V KOReader: fts: BOOTTIME clock source is supported
01-13 18:19:37.282 26910 26947 I KOReader: Android 13 - S (API 33) - flavor: rocks
01-13 18:19:37.320 26910 26947 I KOReader: initializing for device spes_global
01-13 18:19:37.320 26910 26947 I KOReader: framebuffer resolution: {
01-13 18:19:37.320 26910 26947 I KOReader:   h = 2307,
01-13 18:19:37.320 26910 26947 I KOReader:   w = 1080
01-13 18:19:37.320 26910 26947 I KOReader: } --[[table: 0x78a26eba48]]

...

01-13 18:16:37.557 26129 26516 V KOReader: FM loaded plugin wallabag at plugins/wallabag.koplugin
01-13 18:16:37.562 26129 26516 V KOReader: Spinning up new FileManager instance table: 0x7893368c18
01-13 18:16:37.562 26129 26516 V KOReader: show widget: table: 0x7893368c18
01-13 18:16:37.562 26129 26516 V KOReader: setDirty nil from widget table: 0x7893368c18 w/ NO region; dithering: nil
01-13 18:16:37.569 26129 26516 V KOReader: NetworkListener: onNetworkConnected
01-13 18:16:37.572 26129 26516 V KOReader: Found font: DroidSansMono.ttf in ./fonts/droid/DroidSansMono.ttf
01-13 18:16:37.573 26129 26516 V KOReader: Found font: NotoSans-Bold.ttf in ./fonts/noto/NotoSans-Bold.ttf
01-13 18:16:37.576 26129 26516 V KOReader: Found font: NotoSansCJKsc-Regular.otf in ./fonts/noto/NotoSansCJKsc-Regular.otf
01-13 18:16:37.583 26129 26516 V KOReader: Found font: NotoSansArabicUI-Bold.ttf in ./fonts/noto/NotoSansArabicUI-Bold.ttf
01-13 18:16:37.586 26129 26516 V KOReader: _refresh: Enqueued ui update for region 0 0 1080 140 dithering: false
01-13 18:16:37.586 26129 26516 V KOReader: setDirty ui from widget table: 0x7893368c18 w/ region 0 0 1080 139 dithering: nil
01-13 18:16:37.586 26129 26516 V KOReader: setDirty via a func from widget table: 0x7893368c18
01-13 18:16:37.586 26129 26516 V KOReader: FocusManager: Move focus position to: 1 , 4
01-13 18:16:37.586 26129 26516 V KOReader: _refresh: Enqueued ui update for region 0 0 1080 140 dithering: false
01-13 18:16:37.586 26129 26516 V KOReader: setDirty ui from widget nil w/ region 0 0 1080 140 dithering: nil
01-13 18:16:37.586 26129 26516 V KOReader: painting widget: table: 0x7893368c18
01-13 18:16:37.592 26129 26516 V KOReader: Found font: NotoSansCJKsc-Regular.otf in ./fonts/noto/NotoSansCJKsc-Regular.otf
01-13 18:16:37.594 26129 26516 V KOReader: Found font: NotoSansCJKsc-Regular.otf in ./fonts/noto/NotoSansCJKsc-Regular.otf
01-13 18:16:37.598 26129 26516 V KOReader: blitFrom 9 9 0 0 72 72
01-13 18:16:37.599 26129 26516 V KOReader: blitFrom 999 9 0 0 72 72
01-13 18:16:37.608 26129 26516 V KOReader: blitFrom 170 2324 0 0 72 72
01-13 18:16:37.608 26129 26516 V KOReader: blitFrom 308 2324 0 0 72 72
01-13 18:16:37.617 26129 26516 V KOReader: blitFrom 699 2324 0 0 72 72
01-13 18:16:37.617 26129 26516 V KOReader: blitFrom 837 2324 0 0 72 72
01-13 18:16:37.618 26129 26516 V KOReader: _refresh: Enqueued ui update for region 0 0 1080 2400 dithering: false
01-13 18:16:37.618 26129 26516 V KOReader: _refresh: Enqueued ui update for region 0 0 1080 2400 dithering: false
01-13 18:16:37.619 26129 26516 V KOReader: triggering refresh {
01-13 18:16:37.619 26129 26516 V KOReader:   mode = "ui",
01-13 18:16:37.619 26129 26516 V KOReader:   region = "1080x2400+0+0"
01-13 18:16:37.619 26129 26516 V KOReader: } --[[table: 0x7898a2a500]]
01-13 18:16:37.620 26129 26516 W KOReader: cannot blit: no window
01-13 18:16:37.620 26129 26516 D NativeGlue: activityState=11
01-13 18:16:37.620 26129 26516 D NativeGlue: Post APP_CMD_RESUME
01-13 18:16:37.621 26129 26516 V KOReader: input event => type: 4 (EV_MSC), code: 11 (nil), value: 1, time: 533021.846452
01-13 18:16:37.621 26129 26516 V KOReader: Android application event 11
01-13 18:16:37.623 26129 26129 V Timeout : onResume: updating system timeout: 1
01-13 18:16:37.623 26129 26129 V Timeout : onResume
01-13 18:16:37.624 26129 26516 V KOReader: InputContainer:setIgnoreTouchInput false
01-13 18:16:37.640 26129 26129 V NativeGlue: InputQueueCreated: 0xb4000078bc6cc540 -- 0xb4000078bc638a00
01-13 18:16:37.641 26129 26516 D NativeGlue:  APP_CMD_INPUT_CHANGED
01-13 18:16:37.641 26129 26516 D NativeGlue: Attaching input queue to looper
01-13 18:16:37.641 26129 26516 V KOReader: input event => type: 4 (EV_MSC), code: 0 (nil), value: 1, time: 533021.866742
01-13 18:16:37.641 26129 26516 V KOReader: Android application event 0
01-13 18:16:37.756 26129 26129 D Surface : onAttachedToWindow()
01-13 18:16:37.757 26129 26129 V Surface : top 93 pixels are not available, reason: window inset
01-13 18:16:37.789 26129 26129 V NativeGlue: NativeWindowCreated: 0xb4000078bc6cc540 -- 0xb4000077e64d4810
01-13 18:16:37.790 26129 26516 D NativeGlue: APP_CMD_INIT_WINDOW
01-13 18:16:37.790 26129 26516 V KOReader: input event => type: 4 (EV_MSC), code: 1 (nil), value: 1, time: 533022.015650
01-13 18:16:37.790 26129 26516 V KOReader: Android application event 1
01-13 18:16:37.791 26129 26129 V Surface : surface changed {
01-13 18:16:37.791 26129 26129 V Surface :   width:  1080
01-13 18:16:37.791 26129 26129 V Surface :   height: 2307
01-13 18:16:37.791 26129 26129 V Surface :  format: RGB_565
01-13 18:16:37.791 26129 26129 V Surface : }
01-13 18:16:37.791 26129 26129 V NativeGlue: NativeWindowResized: 0xb4000078bc6cc540 -- 0xb4000077e64d4810
01-13 18:16:37.795 26129 26129 V NativeGlue: ContentRectChanged: l=0,t=0,r=1080,b=2177
01-13 18:16:37.800 26129 26129 V NativeGlue: NativeWindowRedrawNeeded: 0xb4000078bc6cc540 -- 0xb4000077e64d4810
01-13 18:16:37.824 26129 26129 V NativeGlue: NativeWindowRedrawNeeded: 0xb4000078bc6cc540 -- 0xb4000077e64d4810
01-13 18:16:37.837 26129 26516 V KOReader: input event => type: 4 (EV_MSC), code: 3 (MSC_RAW), value: 1, time: 533022.063417
01-13 18:16:37.838 26129 26516 V KOReader: Android application event 3
01-13 18:16:37.838 26129 26516 V KOReader: input event => type: 4 (EV_MSC), code: 5 (nil), value: 1, time: 533022.063434
01-13 18:16:37.838 26129 26516 V KOReader: Android application event 5
01-13 18:16:37.838 26129 26516 V KOReader: input event => type: 4 (EV_MSC), code: 4 (nil), value: 1, time: 533022.063442
01-13 18:16:37.838 26129 26516 V KOReader: Android application event 4
01-13 18:16:37.857 26129 26129 V NativeGlue: WindowFocusChanged: 0xb4000078bc6cc540 -- 1
01-13 18:16:37.871 26129 26516 V KOReader: input event => type: 4 (EV_MSC), code: 4 (nil), value: 1, time: 533022.063452
01-13 18:16:37.871 26129 26516 V KOReader: Android application event 4
01-13 18:16:37.900 26129 26516 V KOReader: input event => type: 4 (EV_MSC), code: 6 (nil), value: 1, time: 533022.126315
01-13 18:16:37.900 26129 26516 V KOReader: Android application event 6
01-13 18:16:37.928 26129 26129 V NativeGlue: ContentRectChanged: l=0,t=0,r=1080,b=2307
01-13 18:16:37.929 26129 26516 V KOReader: input event => type: 4 (EV_MSC), code: 5 (nil), value: 1, time: 533022.154836
01-13 18:16:37.929 26129 26516 V KOReader: Android application event 5
01-13 18:16:50.620  1865  5608 I ActivityManager: Killing 26180:com.xiaomi.glgm/u0a366 (adj 975): empty #9
01-13 18:17:23.809  1865  2747 W ActivityManager: Sending non-protected broadcast miui.extm.action.mark from system uid 1000 pkg android. Callers=com.android.server.am.ActivityManagerService.broadcastIntentLocked:14940 com.android.server.am.ActivityManagerService.broadcastIntentInPackage:15125 com.android.server.am.ActivityManagerService$LocalService.broadcastIntentInPackage:17694 com.android.server.am.PendingIntentRecord.sendInner:511 com.android.server.am.PendingIntentRecord.sendWithResult:309 
01-13 18:17:30.481  1865  2250 W ActivityManager: Unable to start service Intent { act=miui.action.CAMERA_EMPTY_SERVICE pkg=com.android.camera } U=0: not found
01-13 18:17:30.538 26129 26129 V NativeGlue: Pause: 0xb4000078bc6cc540
01-13 18:17:30.538 26129 26516 D NativeGlue: activityState=13
01-13 18:17:30.539 26129 26516 V KOReader: input event => type: 4 (EV_MSC), code: 13 (nil), value: 1, time: 533074.764542
01-13 18:17:30.540 26129 26516 V KOReader: Android application event 13
01-13 18:17:30.542 26129 26129 V Timeout : onPause
01-13 18:17:30.565 26129 26129 V NativeGlue: NativeWindowDestroyed: 0xb4000078bc6cc540 -- 0xb4000077e64d4810
01-13 18:17:30.592 26129 26516 V KOReader: NetworkListener: onSuspend
01-13 18:17:30.592 26129 26516 V KOReader: NetworkListener: unschedule network activity check
01-13 18:17:30.592 26129 26516 D NativeGlue: APP_CMD_TERM_WINDOW
01-13 18:17:30.592 26129 26516 D NativeGlue: Post APP_CMD_TERM_WINDOW
01-13 18:17:30.593 26129 26516 V KOReader: input event => type: 4 (EV_MSC), code: 2 (nil), value: 1, time: 533074.818228
01-13 18:17:30.594 26129 26516 V KOReader: Android application event 2
01-13 18:17:30.596 26129 26129 V NativeGlue: Stop: 0xb4000078bc6cc540
01-13 18:17:30.596 26129 26516 D NativeGlue: activityState=14
01-13 18:17:30.596 26129 26516 V KOReader: input event => type: 4 (EV_MSC), code: 14 (nil), value: 1, time: 533074.822237
01-13 18:17:30.597 26129 26516 V KOReader: Android application event 14
01-13 18:17:30.597 26129 26129 V NativeGlue: SaveInstanceState: 0xb4000078bc6cc540
01-13 18:17:30.597 26129 26516 D NativeGlue: Post APP_CMD_SAVE_STATE
01-13 18:17:30.598 26129 26516 V KOReader: input event => type: 4 (EV_MSC), code: 12 (nil), value: 1, time: 533074.823360
01-13 18:17:30.598 26129 26516 V KOReader: Android application event 12
01-13 18:17:30.618 26129 26129 V NativeGlue: WindowFocusChanged: 0xb4000078bc6cc540 -- 0
01-13 18:17:30.619 26129 26516 V KOReader: input event => type: 4 (EV_MSC), code: 7 (nil), value: 1, time: 533074.844638
01-13 18:17:30.619 26129 26516 V KOReader: Android application event 7
01-13 18:19:13.250 26129 26129 V NativeGlue: Start: 0xb4000078bc6cc540
01-13 18:19:13.251 26129 26516 D NativeGlue: activityState=10
01-13 18:19:13.251 26129 26516 V KOReader: input event => type: 4 (EV_MSC), code: 10 (nil), value: 1, time: 533177.476847
01-13 18:19:13.251 26129 26516 V KOReader: Android application event 10
01-13 18:19:13.267 26129 26129 V NativeGlue: Resume: 0xb4000078bc6cc540
01-13 18:19:13.267 26129 26516 D NativeGlue: activityState=11
01-13 18:19:13.267 26129 26516 D NativeGlue: Post APP_CMD_RESUME
01-13 18:19:13.267 26129 26516 V KOReader: input event => type: 4 (EV_MSC), code: 11 (nil), value: 1, time: 533177.493105
01-13 18:19:13.267 26129 26516 V KOReader: Android application event 11
01-13 18:19:13.268 26129 26516 V KOReader: InputContainer:setIgnoreTouchInput false
01-13 18:19:13.273 26129 26129 V Timeout : onResume: updating system timeout: 1
01-13 18:19:13.273 26129 26129 V Timeout : onResume
01-13 18:19:13.311 26129 26129 V NativeGlue: NativeWindowCreated: 0xb4000078bc6cc540 -- 0xb4000077e64d4810
01-13 18:19:13.311 26129 26516 D NativeGlue: APP_CMD_INIT_WINDOW
01-13 18:19:13.311 26129 26516 V KOReader: input event => type: 4 (EV_MSC), code: 1 (nil), value: 1, time: 533177.537422
01-13 18:19:13.312 26129 26516 V KOReader: Android application event 1
01-13 18:19:13.317 26129 26129 V Surface : surface changed {
01-13 18:19:13.317 26129 26129 V Surface :   width:  1080
01-13 18:19:13.317 26129 26129 V Surface :   height: 2307
01-13 18:19:13.317 26129 26129 V Surface :  format: RGB_565
01-13 18:19:13.317 26129 26129 V Surface : }
pazos commented 7 months ago

Just to be clear: this does not affect in app updates when storage permissions are already granted.

And it doesn't affect 1st time installation because the app is killed when we forward users to storage settings.

Am I right or I'm missing something?

NiLuJe commented 7 months ago

I can definitely reproduce something like this when doing uninstalls into adb install sessions when debugging, and that involves setting the storage permission each time.

So, the first § probably holds true, but not the second? (I imagine because we're killed way too early for any of this to be relevant?).

hugleo commented 7 months ago

Just to be clear: this does not affect in app updates when storage permissions are already granted. correct

And it doesn't affect 1st time installation because the app is killed when we forward users to storage settings.

Sometimes affect, others not. I can reproduce easily.

requestSpecialPermission finish() is executed:

01-13 21:12:31.432 26716 26716 I KOReader: finishing here

01-13 21:12:31.446  1865  2148 I ActivityManager: Start proc 26905:com.android.settings/1000 for next-top-activity {com.android.settings/com.android.settings.Settings$AppManageExternalStorageActivity} caller=org.koreader.launcher.debug
01-13 21:12:31.460 26716 26716 V NativeGlue: Pause: 0xb4000078bc6cc400
01-13 21:12:31.461 26716 26788 D NativeGlue: activityState=13
01-13 21:12:31.461 26716 26716 V Timeout : onPause
01-13 21:12:31.492 26716 26716 V NativeGlue: WindowFocusChanged: 0xb4000078bc6cc400 -- 1
01-13 21:12:31.492 26716 26788 V NativeThread: Activity gained focus.
01-13 21:12:31.548 26716 26716 V NativeGlue: ContentRectChanged: l=0,t=0,r=1080,b=2307
01-13 21:12:31.551 26716 26716 V NativeGlue: WindowFocusChanged: 0xb4000078bc6cc400 -- 0
01-13 21:12:31.847  1865  2148 I ActivityManager: Start proc 26953:com.android.htmlviewer/u0a165 for service {com.android.htmlviewer/com.android.settings.services.MemoryOptimizationService} caller=com.android.settings
01-13 21:12:32.150 26716 26716 V NativeGlue: NativeWindowDestroyed: 0xb4000078bc6cc400 -- 0xb40000778fbc2810
01-13 21:12:32.151 26716 26788 D NativeGlue: APP_CMD_TERM_WINDOW
01-13 21:12:32.151 26716 26788 D NativeGlue: Post APP_CMD_TERM_WINDOW
01-13 21:12:32.153 26716 26716 V NativeGlue: Stop: 0xb4000078bc6cc400
01-13 21:12:32.153 26716 26788 D NativeGlue: activityState=14
01-13 21:12:32.155 26716 26716 V MainActivity: onDestroy()
01-13 21:12:32.157 26716 26716 V NativeGlue: InputQueueDestroyed: 0xb4000078bc6cc400 -- 0xb4000077f4a8d000
01-13 21:12:32.157 26716 26788 D NativeGlue:  APP_CMD_INPUT_CHANGED
01-13 21:12:32.157 26716 26716 V NativeGlue: Destroy: 0xb4000078bc6cc400
01-13 21:12:32.162 26716 26788 D NativeGlue: APP_CMD_DESTROY
01-13 21:12:32.165 26716 26788 V NativeThread: onDestroy()
01-13 21:12:32.165 26716 26788 D NativeGlue: android_app_destroy!
01-13 21:12:36.153  1865  2063 W ActivityManager: Sending non-protected broadcast com.miui.fullscreen_state_change from system 1865:system/1000 pkg android. Callers=com.android.server.am.ActivityManagerService.broadcastIntentLocked:14841 com.android.server.am.ActivityManagerService.broadcastIntentLocked:14226 com.android.server.am.ActivityManagerService.broadcastIntentWithFeature:15100 android.app.ContextImpl.sendBroadcastAsUser:1426 com.android.server.policy.BaseMiuiPhoneWindowManager$15.run:2825 
01-13 21:12:36.154  1865  2063 W ActivityManager: Sending non-protected broadcast com.miui.fullscreen_state_change from system 1865:system/1000 pkg android. Callers=com.android.server.am.ActivityManagerService.broadcastIntentLocked:14940 com.android.server.am.ActivityManagerService.broadcastIntentLocked:14226 com.android.server.am.ActivityManagerService.broadcastIntentWithFeature:15100 android.app.ContextImpl.sendBroadcastAsUser:1426 com.android.server.policy.BaseMiuiPhoneWindowManager$15.run:2825 
01-13 21:12:36.827  1865  6130 I ActivityManager: Killing 26025:android.process.acore/u0a126 (adj 800): empty #9

When I reproduce the problem and open again:

01-13 21:12:52.179 26716 26716 I MainActivity: loading libluajit
01-13 21:12:52.233  1865  5608 I ActivityManager: Killing 25808:com.android.htmlviewer:remote/u0a165 (adj 985): empty #9
01-13 21:12:52.238 26716 26716 D NativeGlue: Creating: 0xb4000078bc6cc400
01-13 21:12:52.239 26716 26716 I Assets  : loading lib7z
01-13 21:12:52.239 26716 26716 I Lights  : Using Generic driver
01-13 21:12:52.242 26716 27021 V NativeGlue: User FIFO already exists at `/data/user/0/org.koreader.launcher.debug/files/alooper.fifo`
01-13 21:12:52.242 26716 27021 D NativeThread: Starting
01-13 21:12:52.242 26716 27021 V NativeThread: waiting for activity
01-13 21:12:52.245 26716 26716 V Surface : Using Native Content implementation
01-13 21:12:52.246 26716 26716 V MainActivity: native orientation: portrait
01-13 21:12:52.247 26716 26716 V EventReceiver: Filtering 3 events: 
01-13 21:12:52.247 26716 26716 V EventReceiver: android.intent.action.ACTION_POWER_CONNECTED
01-13 21:12:52.247 26716 26716 V EventReceiver: android.intent.action.ACTION_POWER_DISCONNECTED
01-13 21:12:52.247 26716 26716 V EventReceiver: android.intent.action.DOWNLOAD_COMPLETE
01-13 21:12:52.253 26716 26716 V NativeGlue: Start: 0xb4000078bc6cc400
01-13 21:12:52.253 26716 27021 D NativeGlue: activityState=10
01-13 21:12:52.255 26716 27021 V NativeThread: Launching LuaJIT assets
01-13 21:12:52.256 26716 26716 V NativeGlue: Resume: 0xb4000078bc6cc400
01-13 21:12:52.273 26716 27021 I Assets  : New install
01-13 21:12:52.276 26716 27021 V Assets  : Uncompressing module/koreader.7z
01-13 21:12:56.791 26716 27021 V Assets  : Reading symlinks map from module/map.txt
01-13 21:12:58.150 26716 27021 I Assets  : update installed in 5876 milliseconds
01-13 21:12:58.152 26716 27021 D KOReader: try to load module libs/libkoreader-lfs.so

When the problem doesn't occur

01-13 21:20:38.744 28796 28796 I MainActivity: loading libluajit
01-13 21:20:38.748  1865  2066 I ActivityManager: Killing 28219:com.android.htmlviewer:remote/u0a165 (adj 985): empty #9
01-13 21:20:38.801 28796 28796 D NativeGlue: Creating: 0xb4000078bc6cccc0
01-13 21:20:38.802 28796 29155 V NativeGlue: User FIFO already exists at `/data/user/0/org.koreader.launcher.debug/files/alooper.fifo`
01-13 21:20:38.802 28796 28796 I Assets  : loading lib7z
01-13 21:20:38.802 28796 29155 D NativeThread: Starting
01-13 21:20:38.802 28796 29155 V NativeThread: waiting for activity
01-13 21:20:38.803 28796 28796 I Lights  : Using Generic driver
01-13 21:20:38.805 28796 28796 V Surface : Using Native Content implementation
01-13 21:20:38.806 28796 28796 V MainActivity: native orientation: portrait
01-13 21:20:38.806 28796 28796 V EventReceiver: Filtering 3 events: 
01-13 21:20:38.806 28796 28796 V EventReceiver: android.intent.action.ACTION_POWER_CONNECTED
01-13 21:20:38.806 28796 28796 V EventReceiver: android.intent.action.ACTION_POWER_DISCONNECTED
01-13 21:20:38.806 28796 28796 V EventReceiver: android.intent.action.DOWNLOAD_COMPLETE
01-13 21:20:38.814 28796 28796 V NativeGlue: Start: 0xb4000078bc6cccc0
01-13 21:20:38.814 28796 29155 D NativeGlue: activityState=10
01-13 21:20:38.816 28796 28796 V NativeGlue: Resume: 0xb4000078bc6cccc0
01-13 21:20:38.816 28796 29155 D NativeGlue: activityState=11
01-13 21:20:38.816 28796 29155 D NativeGlue: Post APP_CMD_RESUME
01-13 21:20:38.818 28796 28796 V Timeout : onResume: updating system timeout: 1
01-13 21:20:38.818 28796 28796 V Timeout : onResume
01-13 21:20:38.829 28796 28796 V NativeGlue: InputQueueCreated: 0xb4000078bc6cccc0 -- 0xb4000077ec419800
01-13 21:20:38.830 28796 29155 D NativeGlue:  APP_CMD_INPUT_CHANGED
01-13 21:20:38.830 28796 29155 D NativeGlue: Attaching input queue to looper
01-13 21:20:38.833 28796 28796 D Surface : onAttachedToWindow()
01-13 21:20:38.833 28796 28796 V Surface : top 93 pixels are not available, reason: window inset
01-13 21:20:38.854 28796 28796 V NativeGlue: NativeWindowCreated: 0xb4000078bc6cccc0 -- 0xb4000077e6415810
01-13 21:20:38.854 28796 29155 D NativeGlue: APP_CMD_INIT_WINDOW
01-13 21:20:38.854 28796 29155 V NativeThread: Activity window ready.
01-13 21:20:38.869 28796 28796 V Surface : surface changed {
01-13 21:20:38.869 28796 28796 V Surface :   width:  1080
01-13 21:20:38.869 28796 28796 V Surface :   height: 2307
01-13 21:20:38.869 28796 28796 V Surface :  format: RGB_565
01-13 21:20:38.869 28796 28796 V Surface : }

Am I right or I'm missing something?

pazos commented 7 months ago

@hugleo: IIRC you know how to fix it (it was part of another PR). Is that right?

Feel free to submit a PR :)

hugleo commented 7 months ago

Except that didn't work -.-. I can reproduce now in a way that even using finishAffinity() will fail. This one will require a more elaborate thought :) No desired time for this now :P

hugleo commented 6 months ago

As a starting point, it seems like windowManager.defaultDisplay.cutout as? DisplayCutout can get insets measurements from any place, not needing to be inside onAttachedToWindow. This should fix the nitpick for a big percentage of devices:

--- MainActivity.kt     2024-02-08 00:23:25.411633745 -0300
+++ MainActivity.kt    2024-02-08 00:13:01.642063579 -0300
@@ -137,6 +137,21 @@

         registerReceiver(event, event.filter)

+        val cut = when {
+            Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q -> {
+                windowManager.defaultDisplay.cutout as? DisplayCutout
+            } else -> null
+        }
+
+        if (cut != null) {
+            val cutPixels = cut.safeInsetTop
+            if (topInsetHeight != cutPixels) {
+                Log.v(TAG_SURFACE,
+                    "top $cutPixels pixels are not available, reason: window inset")
+                topInsetHeight = cutPixels
+            }
+        }
+
         if (!hasMandatoryPermissions()) {
             requestMandatoryPermissions()
         }

Sometimes, we don't see the three circles in the updating screen but this is another nitpick :D

othernitpick