Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UninitializedPropertyAccessException caused by accessing imageAdapter #254

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

KoheiMoroi
Copy link

@KoheiMoroi KoheiMoroi commented Oct 24, 2022

Fixes issues #234 #253.

Unfortunately, I could not reproduce the exception that those issues say.
However, there are a few scenarios in which the app crashes.
If the system destroys the activity due to system constraints such as configuration change or memory pressure, you can not access objects which are reclaimed by the System.
Ideally, View objects should belong to call-site's(Such as Activity) lifecycle, but I don't want to apply big changes, so added null-check implementation(in that case we finish the Activity) to avoid the crashes.

This PR changes:
  • Add null-check implementation to avoid crashes caused by accessing imageAdapter when loading images
    • Display a toast on the Activity when imageAdapter is null while loading images
  • Add Japanese string resources
  • Change the signature of constructor of the Adapter class not to accept null of ImageAdapter
Link

Activity state and ejection from memory

Screenshot

Demonstration in the case of null

sample.mp4

…h due to UninitializedPropertyAccessException
@KoheiMoroi KoheiMoroi force-pushed the feature/fix_UninitializedPropertyAccessException_caused_by_accessing_imageAdapter branch from c2c1657 to 86fedd5 Compare October 24, 2022 09:28
@KoheiMoroi KoheiMoroi marked this pull request as ready for review October 24, 2022 09:38
@sangcomz
Copy link
Owner

Thanks for the PR. And sorry for replying so late.
The PR you wrote doesn't seem to open when the adapter is null, is that correct?

- add finishActivity in AlubumContract to finish AlbumActivity with passed code
@KoheiMoroi
Copy link
Author

KoheiMoroi commented Nov 11, 2022

@sangcomz

Thanks for the PR. And sorry for replying so late. The PR you wrote doesn't seem to open when the adapter is null, is that correct?

Yes, we do not open Activity in case of ImageAdapter is null.
Besides, we must return the right result code to the call site.
Temporarily I'm returning a result code as Cancel.
Let me know if there is a suitable code.

I recorded the video for a demonstration by simply passing null.

When pick up image:

sample.mp4

When open album view:

sample3.mp4

@KoheiMoroi
Copy link
Author

@sangcomz
Sorry for the rush.
It's unexpected behavior, and it's tough to address this kind of issue we can not reproduce.
However, the crash surely occurs on production as the issues mentioned.
I will be grateful if you review this in your spare time.

@sangcomz
Copy link
Owner

sangcomz commented Dec 5, 2022

@KoheiMoroi
Yes, thank you for your reply.
I understand PR very well. Could you please provide a full log of the crash?

If PR is applied, crash will not occur, but it is considered an issue that it does not operate without any alert.
So I want to check the error log once to see if there is another way.

There is an error log in the issue, I will check that part.

@sangcomz
Copy link
Owner

sangcomz commented Dec 5, 2022

@KoheiMoroi It would be nice to inform the error situation through toast or message dialog. And I wish that message could be customized too. Could you work on this part too?
Or do you have other opinions on this one?

@KoheiMoroi
Copy link
Author

@KoheiMoroi It would be nice to inform the error situation through toast or message dialog. And I wish that message could be customized too. Could you work on this part too? Or do you have other opinions on this one?

It would be informative if we could have the error message.
Ok, I will work on it.

@KoheiMoroi
Copy link
Author

KoheiMoroi commented Dec 6, 2022

Here is error log(from beginning to the crash):

---------------------------- PROCESS STARTED (29638) for package com.sangcomz.fishbundemo ----------------------------
2022-12-06 10:47:10.062 29638-29638 ziparchive com.sangcomz.fishbundemo W Unable to open '/data/data/com.sangcomz.fishbundemo/code_cache/.overlay/base.apk/classes9.dm': No such file or directory
2022-12-06 10:47:10.068 29638-29638 nativeloader com.sangcomz.fishbundemo D Configuring classloader-namespace for other apk /data/app/~~xna0wBbZIKpOmetdkYrLYw==/com.sangcomz.fishbundemo-pPGWH4EmIkgouW3QXgHpTw==/base.apk. target_sdk_version=33, uses_libraries=, library_path=/data/app/~~xna0wBbZIKpOmetdkYrLYw==/com.sangcomz.fishbundemo-pPGWH4EmIkgouW3QXgHpTw==/lib/arm64, permitted_path=/data:/mnt/expand:/data/user/0/com.sangcomz.fishbundemo
2022-12-06 10:47:10.080 29638-29638 GraphicsEnvironment com.sangcomz.fishbundemo V ANGLE Developer option for 'com.sangcomz.fishbundemo' set to: 'default'
2022-12-06 10:47:10.081 29638-29638 GraphicsEnvironment com.sangcomz.fishbundemo V ANGLE GameManagerService for com.sangcomz.fishbundemo: false
2022-12-06 10:47:10.081 29638-29638 GraphicsEnvironment com.sangcomz.fishbundemo V Updatable production driver is not supported on the device.
2022-12-06 10:47:10.086 29638-29638 NetworkSecurityConfig com.sangcomz.fishbundemo D No Network Security Config specified, using platform default
2022-12-06 10:47:10.086 29638-29638 NetworkSecurityConfig com.sangcomz.fishbundemo D No Network Security Config specified, using platform default
2022-12-06 10:47:10.098 29638-29638 omz.fishbundemo com.sangcomz.fishbundemo W Accessing hidden method Landroid/view/WindowManagerGlobal;->getInstance()Landroid/view/WindowManagerGlobal; (unsupported, reflection, allowed)
2022-12-06 10:47:10.098 29638-29638 omz.fishbundemo com.sangcomz.fishbundemo W Accessing hidden field Landroid/view/WindowManagerGlobal;->mViews:Ljava/util/ArrayList; (unsupported, reflection, allowed)
2022-12-06 10:47:10.098 29638-29638 omz.fishbundemo com.sangcomz.fishbundemo W Accessing hidden field Landroid/app/ActivityThread;->mH:Landroid/app/ActivityThread$H; (unsupported, reflection, allowed)
2022-12-06 10:47:10.098 29638-29638 omz.fishbundemo com.sangcomz.fishbundemo W Accessing hidden method Landroid/app/ActivityThread;->currentActivityThread()Landroid/app/ActivityThread; (unsupported, reflection, allowed)
2022-12-06 10:47:10.099 29638-29638 omz.fishbundemo com.sangcomz.fishbundemo W Accessing hidden field Landroid/os/Handler;->mCallback:Landroid/os/Handler$Callback; (unsupported, reflection, allowed)
2022-12-06 10:47:10.099 29638-29638 omz.fishbundemo com.sangcomz.fishbundemo W Accessing hidden field Landroid/util/Singleton;->mInstance:Ljava/lang/Object; (unsupported, reflection, allowed)
2022-12-06 10:47:10.099 29638-29638 omz.fishbundemo com.sangcomz.fishbundemo W Accessing hidden method Landroid/util/Singleton;->get()Ljava/lang/Object; (unsupported, reflection, allowed)
2022-12-06 10:47:10.099 29638-29638 omz.fishbundemo com.sangcomz.fishbundemo W Accessing hidden field Landroid/app/ActivityManager;->IActivityManagerSingleton:Landroid/util/Singleton; (unsupported, reflection, allowed)
2022-12-06 10:47:10.146 29638-29638 omz.fishbundemo com.sangcomz.fishbundemo W Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (unsupported, reflection, allowed)
2022-12-06 10:47:10.146 29638-29638 omz.fishbundemo com.sangcomz.fishbundemo W Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (unsupported, reflection, allowed)
2022-12-06 10:47:10.147 29638-29638 Compatibil...geReporter com.sangcomz.fishbundemo D Compat change id reported: 210923482; UID 10271; state: ENABLED
2022-12-06 10:47:10.162 29638-29638 omz.fishbundemo com.sangcomz.fishbundemo W Accessing hidden field Lcom/android/internal/policy/DecorView;->mWindow:Lcom/android/internal/policy/PhoneWindow; (unsupported, reflection, allowed)
2022-12-06 10:47:10.175 29638-29658 LeakCanary com.sangcomz.fishbundemo D LeakCanary is running and ready to detect memory leaks.
2022-12-06 10:47:10.189 29638-29660 AdrenoGLES-0 com.sangcomz.fishbundemo I QUALCOMM build : 4783c89, I46ff5fc46f
Build Date : 11/30/20
OpenGL ES Shader Compiler Version: EV031.31.04.01
Local Branch : QPR2
Remote Branch :
Remote Branch :
Reconstruct Branch :
2022-12-06 10:47:10.190 29638-29660 AdrenoGLES-0 com.sangcomz.fishbundemo I Build Config : S P 10.0.4 AArch64
2022-12-06 10:47:10.190 29638-29660 AdrenoGLES-0 com.sangcomz.fishbundemo I Driver Path : /vendor/lib64/egl/libGLESv2_adreno.so
2022-12-06 10:47:10.193 29638-29660 AdrenoGLES-0 com.sangcomz.fishbundemo I PFP: 0x016dd093, ME: 0x00000000
2022-12-06 10:47:10.194 29638-29660 AdrenoUtils com.sangcomz.fishbundemo W <ReadGpuID_from_sysfs:197>: Failed to open /sys/class/kgsl/kgsl-3d0/gpu_model
2022-12-06 10:47:10.194 29638-29660 AdrenoUtils com.sangcomz.fishbundemo W ReadGpuID:221: Failed to read chip ID from gpu_model. Fallback to use the GSL path
2022-12-06 10:47:10.211 29638-29660 Parcel com.sangcomz.fishbundemo W Expecting binder but got null!
2022-12-06 10:47:12.104 29638-29659 LeakCanary com.sangcomz.fishbundemo D Setting up flushing for Thread[LeakCanary-Heap-Dump,5,main]
2022-12-06 10:47:13.079 29638-29660 Parcel com.sangcomz.fishbundemo W Expecting binder but got null!
2022-12-06 10:47:13.583 29638-29660 OpenGLRenderer com.sangcomz.fishbundemo D endAllActiveAnimators on 0xb4000072922dd630 (RippleDrawable) with handle 0xb4000071a22f2200
2022-12-06 10:47:14.427 29638-29647 omz.fishbundemo com.sangcomz.fishbundemo I Compiler allocated 4563KB to compile void android.view.ViewRootImpl.performTraversals()
2022-12-06 10:47:14.442 29638-29638 RecyclerView com.sangcomz.fishbundemo W No adapter attached; skipping layout
2022-12-06 10:47:14.449 29638-29660 Parcel com.sangcomz.fishbundemo W Expecting binder but got null!
2022-12-06 10:47:14.509 29638-29638 AndroidRuntime com.sangcomz.fishbundemo D Shutting down VM
2022-12-06 10:47:14.510 29638-29638 AndroidRuntime com.sangcomz.fishbundemo E FATAL EXCEPTION: main
Process: com.sangcomz.fishbundemo, PID: 29638
kotlin.UninitializedPropertyAccessException: lateinit property imageAdapter has not been initialized
at com.sangcomz.fishbun.Fishton.getImageAdapter(Fishton.kt:15)
at com.sangcomz.fishbun.datasource.FishBunDataSourceImpl.getImageAdapter(FishBunDataSourceImpl.kt:27)
at com.sangcomz.fishbun.ui.album.model.repository.AlbumRepositoryImpl.getImageAdapter(AlbumRepositoryImpl.kt:40)
at com.sangcomz.fishbun.ui.album.mvp.AlbumPresenter$loadAlbumList$1$1$onSuccess$1.invoke(AlbumPresenter.kt:33)
at com.sangcomz.fishbun.ui.album.mvp.AlbumPresenter$loadAlbumList$1$1$onSuccess$1.invoke(AlbumPresenter.kt:28)
at com.sangcomz.fishbun.util.MainUiHandler.run$lambda-0(MainUiHandler.kt:11)
at com.sangcomz.fishbun.util.MainUiHandler.$r8$lambda$ESEsIHm4quKOiXRP0dkG-n5rAMY(Unknown Source:0)
at com.sangcomz.fishbun.util.MainUiHandler$$ExternalSyntheticLambda0.run(Unknown Source:2)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7866)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
2022-12-06 10:47:14.516 29638-29638 Process com.sangcomz.fishbundemo I Sending signal. PID: 29638 SIG: 9
---------------------------- PROCESS ENDED (29638) for package com.sangcomz.fishbundemo ----------------------------
2022-12-06 10:47:14.625 29681-29681 omz.fishbundemo com.sangcomz.fishbundemo W Redefining intrinsic method java.lang.Thread java.lang.Thread.currentThread(). This may cause the unexpected use of the original definition of java.lang.Thread java.lang.Thread.currentThread()in methods that have already been compiled.
2022-12-06 10:47:14.625 29681-29681 omz.fishbundemo com.sangcomz.fishbundemo W Redefining intrinsic method boolean java.lang.Thread.interrupted(). This may cause the unexpected use of the original definition of boolean java.lang.Thread.interrupted()in methods that have already been compiled.
---------------------------- PROCESS STARTED (29681) for package com.sangcomz.fishbundemo ----------------------------
2022-12-06 10:47:14.627 29681-29681 Compatibil...geReporter com.sangcomz.fishbundemo D Compat change id reported: 171979766; UID 10271; state: ENABLED
2022-12-06 10:47:14.638 29681-29681 ziparchive com.sangcomz.fishbundemo W Unable to open '/data/data/com.sangcomz.fishbundemo/code_cache/.overlay/base.apk/classes10.dm': No such file or directory
2022-12-06 10:47:14.639 29681-29681 ziparchive com.sangcomz.fishbundemo W Unable to open '/data/data/com.sangcomz.fishbundemo/code_cache/.overlay/base.apk/classes12.dm': No such file or directory
2022-12-06 10:47:14.639 29681-29681 ziparchive com.sangcomz.fishbundemo W Unable to open '/data/data/com.sangcomz.fishbundemo/code_cache/.overlay/base.apk/classes9.dm': No such file or directory
2022-12-06 10:47:14.645 29681-29681 nativeloader com.sangcomz.fishbundemo D Configuring classloader-namespace for other apk /data/app/~~xna0wBbZIKpOmetdkYrLYw==/com.sangcomz.fishbundemo-pPGWH4EmIkgouW3QXgHpTw==/base.apk. target_sdk_version=33, uses_libraries=, library_path=/data/app/~~xna0wBbZIKpOmetdkYrLYw==/com.sangcomz.fishbundemo-pPGWH4EmIkgouW3QXgHpTw==/lib/arm64, permitted_path=/data:/mnt/expand:/data/user/0/com.sangcomz.fishbundemo
2022-12-06 10:47:14.656 29681-29681 GraphicsEnvironment com.sangcomz.fishbundemo V ANGLE Developer option for 'com.sangcomz.fishbundemo' set to: 'default'
2022-12-06 10:47:14.656 29681-29681 GraphicsEnvironment com.sangcomz.fishbundemo V ANGLE GameManagerService for com.sangcomz.fishbundemo: false
2022-12-06 10:47:14.656 29681-29681 GraphicsEnvironment com.sangcomz.fishbundemo V Updatable production driver is not supported on the device.
2022-12-06 10:47:14.659 29681-29681 NetworkSecurityConfig com.sangcomz.fishbundemo D No Network Security Config specified, using platform default
2022-12-06 10:47:14.660 29681-29681 NetworkSecurityConfig com.sangcomz.fishbundemo D No Network Security Config specified, using platform default
2022-12-06 10:47:14.671 29681-29681 omz.fishbundemo com.sangcomz.fishbundemo W Accessing hidden method Landroid/view/WindowManagerGlobal;->getInstance()Landroid/view/WindowManagerGlobal; (unsupported, reflection, allowed)
2022-12-06 10:47:14.671 29681-29681 omz.fishbundemo com.sangcomz.fishbundemo W Accessing hidden field Landroid/view/WindowManagerGlobal;->mViews:Ljava/util/ArrayList; (unsupported, reflection, allowed)
2022-12-06 10:47:14.671 29681-29681 omz.fishbundemo com.sangcomz.fishbundemo W Accessing hidden field Landroid/app/ActivityThread;->mH:Landroid/app/ActivityThread$H; (unsupported, reflection, allowed)
2022-12-06 10:47:14.671 29681-29681 omz.fishbundemo com.sangcomz.fishbundemo W Accessing hidden method Landroid/app/ActivityThread;->currentActivityThread()Landroid/app/ActivityThread; (unsupported, reflection, allowed)
2022-12-06 10:47:14.671 29681-29681 omz.fishbundemo com.sangcomz.fishbundemo W Accessing hidden field Landroid/os/Handler;->mCallback:Landroid/os/Handler$Callback; (unsupported, reflection, allowed)
2022-12-06 10:47:14.671 29681-29681 omz.fishbundemo com.sangcomz.fishbundemo W Accessing hidden field Landroid/util/Singleton;->mInstance:Ljava/lang/Object; (unsupported, reflection, allowed)
2022-12-06 10:47:14.671 29681-29681 omz.fishbundemo com.sangcomz.fishbundemo W Accessing hidden method Landroid/util/Singleton;->get()Ljava/lang/Object; (unsupported, reflection, allowed)
2022-12-06 10:47:14.671 29681-29681 omz.fishbundemo com.sangcomz.fishbundemo W Accessing hidden field Landroid/app/ActivityManager;->IActivityManagerSingleton:Landroid/util/Singleton; (unsupported, reflection, allowed)
2022-12-06 10:47:14.732 29681-29681 omz.fishbundemo com.sangcomz.fishbundemo W Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (unsupported, reflection, allowed)
2022-12-06 10:47:14.732 29681-29681 omz.fishbundemo com.sangcomz.fishbundemo W Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (unsupported, reflection, allowed)
2022-12-06 10:47:14.734 29681-29681 Compatibil...geReporter com.sangcomz.fishbundemo D Compat change id reported: 210923482; UID 10271; state: ENABLED
2022-12-06 10:47:14.749 29681-29681 omz.fishbundemo com.sangcomz.fishbundemo W Accessing hidden field Lcom/android/internal/policy/DecorView;->mWindow:Lcom/android/internal/policy/PhoneWindow; (unsupported, reflection, allowed)
2022-12-06 10:47:14.765 29681-29701 LeakCanary com.sangcomz.fishbundemo D LeakCanary is running and ready to detect memory leaks.
2022-12-06 10:47:14.777 29681-29703 AdrenoGLES-0 com.sangcomz.fishbundemo I QUALCOMM build : 4783c89, I46ff5fc46f
Build Date : 11/30/20
OpenGL ES Shader Compiler Version: EV031.31.04.01
Local Branch : QPR2
Remote Branch :
Remote Branch :
Reconstruct Branch :
2022-12-06 10:47:14.777 29681-29703 AdrenoGLES-0 com.sangcomz.fishbundemo I Build Config : S P 10.0.4 AArch64
2022-12-06 10:47:14.777 29681-29703 AdrenoGLES-0 com.sangcomz.fishbundemo I Driver Path : /vendor/lib64/egl/libGLESv2_adreno.so
2022-12-06 10:47:14.781 29681-29703 AdrenoGLES-0 com.sangcomz.fishbundemo I PFP: 0x016dd093, ME: 0x00000000
2022-12-06 10:47:14.782 29681-29703 AdrenoUtils com.sangcomz.fishbundemo W <ReadGpuID_from_sysfs:197>: Failed to open /sys/class/kgsl/kgsl-3d0/gpu_model
2022-12-06 10:47:14.782 29681-29703 AdrenoUtils com.sangcomz.fishbundemo W ReadGpuID:221: Failed to read chip ID from gpu_model. Fallback to use the GSL path
2022-12-06 10:47:14.800 29681-29703 Parcel com.sangcomz.fishbundemo W Expecting binder but got null!
2022-12-06 10:47:16.676 29681-29702 LeakCanary com.sangcomz.fishbundemo D Setting up flushing for Thread[LeakCanary-Heap-Dump,5,main]
2022-12-06 10:47:44.237 29681-29693 System com.sangcomz.fishbundemo W A resource failed to call close.

@KoheiMoroi KoheiMoroi force-pushed the feature/fix_UninitializedPropertyAccessException_caused_by_accessing_imageAdapter branch 2 times, most recently from 7b8909a to ac5fe0e Compare December 6, 2022 05:52
@KoheiMoroi
Copy link
Author

KoheiMoroi commented Dec 6, 2022

@sangcomz
We display a Dialog with a localized message when that error occurs in the presenter class.
Plus, I added Japanese string resources.

- add SimpleDialog under the common dir

- display the dialog when error happens while processing image
- change nullable signature of constructor of the adapter
- add japanese resources
@KoheiMoroi KoheiMoroi force-pushed the feature/fix_UninitializedPropertyAccessException_caused_by_accessing_imageAdapter branch from ac5fe0e to a8d49bc Compare December 6, 2022 06:40
@sangcomz
Copy link
Owner

sangcomz commented Dec 7, 2022

@KoheiMoroi
I checked the part you fixed. thanks!

I've been thinking about it additionally, how about changing to using toast instead of dialog?

Because dialog is likely to use a different ui than the app that uses the library. On the other hand, toast seems unlikely, so it would be better to inform them with toast. And, in the case of a dialog, the user has to close the dialog for further interaction, but I don't think this is necessary. Please check once.

Thank you for adding Japanese. 🇯🇵

@KoheiMoroi
Copy link
Author

@KoheiMoroi I checked the part you fixed. thanks!

I've been thinking about it additionally, how about changing to using toast instead of dialog?

Because dialog is likely to use a different ui than the app that uses the library. On the other hand, toast seems unlikely, so it would be better to inform them with toast. And, in the case of a dialog, the user has to close the dialog for further interaction, but I don't think this is necessary. Please check once.

Thank you for adding Japanese. 🇯🇵

The dialog certainly differs from the app's design theme, they don't want it.
I will fix it.
Thank you.

@KoheiMoroi KoheiMoroi force-pushed the feature/fix_UninitializedPropertyAccessException_caused_by_accessing_imageAdapter branch from ddea2f4 to b77dfa4 Compare December 7, 2022 08:01
@KoheiMoroi
Copy link
Author

@sangcomz
I changed to display a toast instead of a dialog.
You can confirm it by this commit.

@KoheiMoroi
Copy link
Author

KoheiMoroi commented Dec 14, 2022

@sangcomz
Thanks to my colleague, we can reproduce the crash consistently by adding androidx.fragment:fragment-ktx:1.5.5 dependency.
I am trying to understand why this causes the crash and is related to the issues. I still don't know why.
However, we should look into it to solve the problem.

Here is the crash log:

2022-12-14 16:19:05.715 14949-14971 Parcel                  com.sangcomz.fishbundemo             W  Expecting binder but got null!
2022-12-14 16:19:06.204 14949-14971 OpenGLRenderer          com.sangcomz.fishbundemo             D  endAllActiveAnimators on 0xb4000072922dc2e0 (RippleDrawable) with handle 0xb4000071a22ee1b0
2022-12-14 16:19:06.401 14949-14970 LeakCanary              com.sangcomz.fishbundemo             D  Setting up flushing for Thread[queued-work-looper,5,main]
2022-12-14 16:19:08.380 14949-14958 omz.fishbundemo         com.sangcomz.fishbundemo             I  Compiler allocated 4563KB to compile void android.view.ViewRootImpl.performTraversals()
2022-12-14 16:19:08.415 14949-14949 RecyclerView            com.sangcomz.fishbundemo             W  No adapter attached; skipping layout
2022-12-14 16:19:08.424 14949-14971 Parcel                  com.sangcomz.fishbundemo             W  Expecting binder but got null!
2022-12-14 16:19:08.906 14949-14971 OpenGLRenderer          com.sangcomz.fishbundemo             D  endAllActiveAnimators on 0xb4000072922e1690 (RippleDrawable) with handle 0xb4000071a230c930
2022-12-14 16:19:10.242 14949-14949 RecyclerView            com.sangcomz.fishbundemo             W  No adapter attached; skipping layout
2022-12-14 16:19:10.246 14949-14971 Parcel                  com.sangcomz.fishbundemo             W  Expecting binder but got null!
2022-12-14 16:19:10.748 14949-14971 OpenGLRenderer          com.sangcomz.fishbundemo             D  endAllActiveAnimators on 0xb400007292308700 (RippleDrawable) with handle 0xb4000071a2319500
2022-12-14 16:19:12.141 14949-14949 AndroidRuntime          com.sangcomz.fishbundemo             D  Shutting down VM
2022-12-14 16:19:12.142 14949-14949 AndroidRuntime          com.sangcomz.fishbundemo             E  FATAL EXCEPTION: main
                  Process: com.sangcomz.fishbundemo, PID: 14949
                  java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sangcomz.fishbundemo/com.sangcomz.fishbun.ui.detail.ui.DetailImageActivity}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
                   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3646)
                   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3783)
                   at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
                   at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
                   at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2308)
                   at android.os.Handler.dispatchMessage(Handler.java:106)
                   at android.os.Looper.loopOnce(Looper.java:201)
                   at android.os.Looper.loop(Looper.java:288)
                   at android.app.ActivityThread.main(ActivityThread.java:7866)
                   at java.lang.reflect.Method.invoke(Native Method)
                   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
                  Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
                   at com.android.internal.policy.PhoneWindow.requestFeature(PhoneWindow.java:402)
                   at com.sangcomz.fishbun.ui.detail.ui.DetailImageActivity.onCreate(DetailImageActivity.kt:43)
                   at android.app.Activity.performCreate(Activity.java:8304)
                   at android.app.Activity.performCreate(Activity.java:8283)
                   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1417)
                   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3627)
                   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3783) 
                   at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101) 
                   at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
                   at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2308) 
                   at android.os.Handler.dispatchMessage(Handler.java:106) 
                   at android.os.Looper.loopOnce(Looper.java:201) 
                   at android.os.Looper.loop(Looper.java:288) 
                   at android.app.ActivityThread.main(ActivityThread.java:7866) 
                   at java.lang.reflect.Method.invoke(Native Method) 
                   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) 
                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936) 
2022-12-14 16:19:12.157 14949-14949 Process                 com.sangcomz.fishbundemo             I  Sending signal. PID: 14949 SIG: 9
---------------------------- PROCESS ENDED (14949) for package com.sangcomz.fishbundemo ----------------------------
---------------------------- PROCESS STARTED (15075) for package com.sangcomz.fishbundemo ----------------------------
2022-12-14 16:19:12.280 15075-15075 Compatibil...geReporter com.sangcomz.fishbundemo             D  Compat change id reported: 171979766; UID 10271; state: ENABLED
2022-12-14 16:19:12.290 15075-15075 ziparchive              com.sangcomz.fishbundemo             W  Unable to open '/data/app/~~S_rKOw1LXWO7_kldT8KMDg==/com.sangcomz.fishbundemo-IFe4rhaRNGH9h_y1myu6jw==/base.dm': No such file or directory
2022-12-14 16:19:12.290 15075-15075 ziparchive              com.sangcomz.fishbundemo             W  Unable to open '/data/app/~~S_rKOw1LXWO7_kldT8KMDg==/com.sangcomz.fishbundemo-IFe4rhaRNGH9h_y1myu6jw==/base.dm': No such file or directory
2022-12-14 16:19:12.430 15075-15075 nativeloader            com.sangcomz.fishbundemo             D  Configuring classloader-namespace for other apk /data/app/~~S_rKOw1LXWO7_kldT8KMDg==/com.sangcomz.fishbundemo-IFe4rhaRNGH9h_y1myu6jw==/base.apk. target_sdk_version=33, uses_libraries=, library_path=/data/app/~~S_rKOw1LXWO7_kldT8KMDg==/com.sangcomz.fishbundemo-IFe4rhaRNGH9h_y1myu6jw==/lib/arm64, permitted_path=/data:/mnt/expand:/data/user/0/com.sangcomz.fishbundemo
2022-12-14 16:19:12.439 15075-15075 GraphicsEnvironment     com.sangcomz.fishbundemo             V  ANGLE Developer option for 'com.sangcomz.fishbundemo' set to: 'default'
2022-12-14 16:19:12.439 15075-15075 GraphicsEnvironment     com.sangcomz.fishbundemo             V  ANGLE GameManagerService for com.sangcomz.fishbundemo: false
2022-12-14 16:19:12.439 15075-15075 GraphicsEnvironment     com.sangcomz.fishbundemo             V  Updatable production driver is not supported on the device.
2022-12-14 16:19:12.442 15075-15075 NetworkSecurityConfig   com.sangcomz.fishbundemo             D  No Network Security Config specified, using platform default
2022-12-14 16:19:12.442 15075-15075 NetworkSecurityConfig   com.sangcomz.fishbundemo             D  No Network Security Config specified, using platform default
2022-12-14 16:19:12.465 15075-15075 omz.fishbundemo         com.sangcomz.fishbundemo             W  Accessing hidden method Landroid/view/WindowManagerGlobal;->getInstance()Landroid/view/WindowManagerGlobal; (unsupported, reflection, allowed)
2022-12-14 16:19:12.465 15075-15075 omz.fishbundemo         com.sangcomz.fishbundemo             W  Accessing hidden field Landroid/view/WindowManagerGlobal;->mViews:Ljava/util/ArrayList; (unsupported, reflection, allowed)
2022-12-14 16:19:12.465 15075-15075 omz.fishbundemo         com.sangcomz.fishbundemo             W  Accessing hidden field Landroid/app/ActivityThread;->mH:Landroid/app/ActivityThread$H; (unsupported, reflection, allowed)
2022-12-14 16:19:12.465 15075-15075 omz.fishbundemo         com.sangcomz.fishbundemo             W  Accessing hidden method Landroid/app/ActivityThread;->currentActivityThread()Landroid/app/ActivityThread; (unsupported, reflection, allowed)
2022-12-14 16:19:12.465 15075-15075 omz.fishbundemo         com.sangcomz.fishbundemo             W  Accessing hidden field Landroid/os/Handler;->mCallback:Landroid/os/Handler$Callback; (unsupported, reflection, allowed)
2022-12-14 16:19:12.466 15075-15075 omz.fishbundemo         com.sangcomz.fishbundemo             W  Accessing hidden field Landroid/util/Singleton;->mInstance:Ljava/lang/Object; (unsupported, reflection, allowed)
2022-12-14 16:19:12.466 15075-15075 omz.fishbundemo         com.sangcomz.fishbundemo             W  Accessing hidden method Landroid/util/Singleton;->get()Ljava/lang/Object; (unsupported, reflection, allowed)
2022-12-14 16:19:12.466 15075-15075 omz.fishbundemo         com.sangcomz.fishbundemo             W  Accessing hidden field Landroid/app/ActivityManager;->IActivityManagerSingleton:Landroid/util/Singleton; (unsupported, reflection, allowed)
2022-12-14 16:19:12.523 15075-15075 omz.fishbundemo         com.sangcomz.fishbundemo             W  Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (unsupported, reflection, allowed)
2022-12-14 16:19:12.523 15075-15075 omz.fishbundemo         com.sangcomz.fishbundemo             W  Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (unsupported, reflection, allowed)
2022-12-14 16:19:12.568 15075-15075 Compatibil...geReporter com.sangcomz.fishbundemo             D  Compat change id reported: 210923482; UID 10271; state: ENABLED
2022-12-14 16:19:12.598 15075-15075 omz.fishbundemo         com.sangcomz.fishbundemo             W  Accessing hidden field Lcom/android/internal/policy/DecorView;->mWindow:Lcom/android/internal/policy/PhoneWindow; (unsupported, reflection, allowed)
2022-12-14 16:19:12.626 15075-15098 AdrenoGLES-0            com.sangcomz.fishbundemo             I  QUALCOMM build                   : 4783c89, I46ff5fc46f
                  Build Date                       : 11/30/20
                  OpenGL ES Shader Compiler Version: EV031.31.04.01
                  Local Branch                     : QPR2
                  Remote Branch                    : 
                  Remote Branch                    : 
                  Reconstruct Branch               : 
2022-12-14 16:19:12.626 15075-15098 AdrenoGLES-0            com.sangcomz.fishbundemo             I  Build Config                     : S P 10.0.4 AArch64
2022-12-14 16:19:12.626 15075-15098 AdrenoGLES-0            com.sangcomz.fishbundemo             I  Driver Path                      : /vendor/lib64/egl/libGLESv2_adreno.so
2022-12-14 16:19:12.631 15075-15098 AdrenoGLES-0            com.sangcomz.fishbundemo             I  PFP: 0x016dd093, ME: 0x00000000
2022-12-14 16:19:12.632 15075-15098 AdrenoUtils             com.sangcomz.fishbundemo             W  <ReadGpuID_from_sysfs:197>: Failed to open /sys/class/kgsl/kgsl-3d0/gpu_model
2022-12-14 16:19:12.632 15075-15098 AdrenoUtils             com.sangcomz.fishbundemo             W  <ReadGpuID:221>: Failed to read chip ID from gpu_model. Fallback to use the GSL path
2022-12-14 16:19:12.633 15075-15075 RecyclerView            com.sangcomz.fishbundemo             W  No adapter attached; skipping layout
2022-12-14 16:19:12.651 15075-15096 LeakCanary              com.sangcomz.fishbundemo             D  LeakCanary is running and ready to detect memory leaks.
2022-12-14 16:19:12.658 15075-15098 Parcel                  com.sangcomz.fishbundemo             W  Expecting binder but got null!
2022-12-14 16:19:12.682 15075-15075 Compatibil...geReporter com.sangcomz.fishbundemo             D  Compat change id reported: 147798919; UID 10271; state: ENABLED
2022-12-14 16:19:12.810 15075-15098 Parcel                  com.sangcomz.fishbundemo             W  Expecting binder but got null!
2022-12-14 16:19:13.305 15075-15075 LeakCanary              com.sangcomz.fishbundemo             D  Watching instance of androidx.fragment.app.FragmentManagerViewModel (androidx.fragment.app.FragmentManagerViewModel received ViewModel#onCleared() callback) with key 74efe2de-305d-4b53-ae87-9ceaf732e51a
2022-12-14 16:19:13.305 15075-15075 LeakCanary              com.sangcomz.fishbundemo             D  Watching instance of androidx.lifecycle.SavedStateHandlesVM (androidx.lifecycle.SavedStateHandlesVM received ViewModel#onCleared() callback) with key 70b7d17d-c2da-4d90-8ede-3ea8b566bb1d
2022-12-14 16:19:13.306 15075-15075 LeakCanary              com.sangcomz.fishbundemo             D  Watching instance of leakcanary.internal.ViewModelClearedWatcher (leakcanary.internal.ViewModelClearedWatcher received ViewModel#onCleared() callback) with key 3ca9ec85-4572-4bbd-b214-f7b4ea6d4efd
2022-12-14 16:19:13.306 15075-15075 LeakCanary              com.sangcomz.fishbundemo             D  Watching instance of androidx.lifecycle.ReportFragment (androidx.lifecycle.ReportFragment received Fragment#onDestroy() callback) with key 1f832e3a-bac7-4be9-9daa-711114e9b8a2
2022-12-14 16:19:13.306 15075-15075 LeakCanary              com.sangcomz.fishbundemo             D  Watching instance of com.sangcomz.fishbun.ui.album.ui.AlbumActivity (com.sangcomz.fishbun.ui.album.ui.AlbumActivity received Activity#onDestroy() callback) with key 7fb6e0c4-a4ee-4405-a68f-19d148d0cb3a
2022-12-14 16:19:14.472 15075-15097 LeakCanary              com.sangcomz.fishbundemo             D  Setting up flushing for Thread[LeakCanary-Heap-Dump,5,main]
2022-12-14 16:19:14.473 15075-15097 LeakCanary              com.sangcomz.fishbundemo             D  Setting up flushing for Thread[queued-work-looper,5,main]
2022-12-14 16:19:18.325 15075-15096 omz.fishbundemo         com.sangcomz.fishbundemo             W  Cleared Reference was only reachable from finalizer (only reported once)
2022-12-14 16:19:18.327 15075-15096 omz.fishbundemo         com.sangcomz.fishbundemo             I  Explicit concurrent copying GC freed 39313(2550KB) AllocSpace objects, 1(20KB) LOS objects, 87% free, 3541KB/27MB, paused 63us,28us total 16.105ms
2022-12-14 16:19:18.331 15075-15087 System                  com.sangcomz.fishbundemo             W  A resource failed to call close. 

@sangcomz
Copy link
Owner

@KoheiMoroi thanks for the good clue.
The above solution is good as a short-term solution, but in the long-term, it would be better to find the root cause and fix it.
I will also look for the cause until this week, and if I can't find it, I will apply this solution first, and then I will work in the direction of finding and fixing the cause.

@sangcomz
Copy link
Owner

And sorry for the late response.🙏
I will try to respond as quickly as possible. Thanks again for sending the PR.

@KoheiMoroi
Copy link
Author

It's my pleasure.
Please do not hesitate to let me know if there is something to help.

@sangcomz
Copy link
Owner

@KoheiMoroi I'm trying to reproduce it now, but does it happen when I simply add implementation "androidx.fragment:fragment-ktx:1.5.5" to the fishbundemo project? I seem to be working fine, are there other conditions?

@KoheiMoroi
Copy link
Author

@KoheiMoroi I'm trying to reproduce it now, but does it happen when I simply add implementation "androidx.fragment:fragment-ktx:1.5.5" to the fishbundemo project? I seem to be working fine, are there other conditions?

My bad.
I just remembered that I had to describe the steps to reproduce.
Please check it by the following:

  1. Open the Album screen
  2. Select either All view, Screenshots, images, or camera
  3. Hit the thumbnail at the image

@sangcomz
Copy link
Owner

@KoheiMoroi Thanks, I found the problem code.
The code below was the problem. I will fix this part.

in DetailImageActivity.kt

       super.onCreate(savedInstanceState)
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            window.requestFeature(Window.FEATURE_CONTENT_TRANSITIONS)
        }
        setContentView(R.layout.activity_detail_activity)
        initView()
        ...

@sangcomz
Copy link
Owner

Please test once through this version.
implementation 'io.github.sangcomz:fishbun:1.1.1-SNAPSHOT'
If there is nothing wrong, I will release it.

@KoheiMoroi
Copy link
Author

Please test once through this version. implementation 'io.github.sangcomz:fishbun:1.1.1-SNAPSHOT' If there is nothing wrong, I will release it.

Got it.
I could not get the artifact, the error says:
Failed to resolve: io.github.sangcomz:fishbun:1.1.1-SNAPSHOT
I will check after rolling it out.

@sangcomz
Copy link
Owner

oh, you need to add the code below to get a snapshot.

maven {
    url "https://s01.oss.sonatype.org/content/repositories/snapshots/"
}

I will upload it as version 1.1.1.

@sangcomz
Copy link
Owner

@KoheiMoroi
I don't think we need logic to change the image adapter to nullable.
However, I think it's good that you translated it into Japanese. Could you please resend this part as a PR?
Thank you very much for your help in fixing the issue. 🙏

I'll close this PR. 🙇

@sangcomz sangcomz closed this Dec 15, 2022
@KoheiMoroi
Copy link
Author

@sangcomz
OK.
I will keep on watch if the crash goes away using the new version on the production app.
Thank you.

@EdgarBarcenas97
Copy link

image
I get this error in version 1.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants