Closed hugleo closed 4 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?
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?).
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?
@hugleo: IIRC you know how to fix it (it was part of another PR). Is that right?
Feel free to submit a PR :)
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
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
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.
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
If we go to the android floating apps we see koreader and we enter Koreader from there:
The bottom area is cutted because the wrong framebuffer resolution
We have to close and reopen to get right:
Log from first install:
Log from subsquents runs after close: