Summary
During testing I have now seen the sample app crash several times when trying to open the NFT details screen. The crash is caused do to improper use of a Context instance that is no longer valid.
java.lang.IllegalArgumentException: You cannot start a load for a destroyed activity
at com.bumptech.glide.manager.RequestManagerRetriever.assertNotDestroyed(RequestManagerRetriever.java:353)
at com.bumptech.glide.manager.RequestManagerRetriever.get(RequestManagerRetriever.java:153)
at com.bumptech.glide.manager.RequestManagerRetriever.get(RequestManagerRetriever.java:133)
at com.bumptech.glide.Glide.with(Glide.java:818)
at com.metaplex.sample.NFTRecycleViewAdapter$onBindViewHolder$2$1.invoke$lambda-0(FirstFragment.kt:124)
at com.metaplex.sample.NFTRecycleViewAdapter$onBindViewHolder$2$1.$r8$lambda$yvSIRD4fwJzOUi96RoJ85KaCCgg(Unknown Source:0)
at com.metaplex.sample.NFTRecycleViewAdapter$onBindViewHolder$2$1$$ExternalSyntheticLambda0.run(Unknown Source:6)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Cause
NFT metadata data loading is not lifecycle aware, leading to an improper use of an already destroyed context if the callback is triggered after the activity has been stopped.
metadata(metaplex) { result ->
result.onSuccess {
...
Handler(Looper.getMainLooper()).post(Runnable {
Glide
.with(context) << context could be invalid here
...
})
}
}
Impact
Its a sample app, it is not meant to be perfect. Likely will leave this bug as-is.
Summary
During testing I have now seen the sample app crash several times when trying to open the NFT details screen. The crash is caused do to improper use of a Context instance that is no longer valid.
Cause
NFT metadata data loading is not lifecycle aware, leading to an improper use of an already destroyed context if the callback is triggered after the activity has been stopped.
Impact
Its a sample app, it is not meant to be perfect. Likely will leave this bug as-is.