-
Notifications
You must be signed in to change notification settings - Fork 293
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
Kotlin synthetic caching not working in library artifact #235
Comments
You need to use the specific typed ViewHolder in your bind function but not the RecylerView.ViewHolder. |
@wbinarytree
As I said, kapt doesn't know enough about |
I just tested my code as well. It seems a kotlin bug(or they changed the implementation). I have a project that runs on kotlin 1.2.31 which works fine with |
I'm using 1.3.10 and I get Update: still the same for me after downgrading the kotlin compiler, android studio and the version in the project |
I see this also in the example project. This is extremely strange. I'm going to open a bug and then see if I can find what the *#$% happened ... |
OK, bizarre. It's happening only with the published library... If you go in https://github.com/lisawray/groupie/blob/master/example/build.gradle
Then you see any Item (say CardItem) using |
I opened an issue with the Kotlin team: https://youtrack.jetbrains.com/issue/KT-28617 |
I feel like this is a pretty big problem and maybe the groupie artifact should be removed from maven as long as this is not fixed, or overridden with the two classes removed. Most users won't notice this bug but it can have a bad influence on performance. |
@remcomokveld I agree we need to make people aware of this issue. Would you agree if we added a note to the README and document the behaviour on Unpublishing seems a bit too harsh, since this is a bug that will be hopefully fixed by the Kotlin team. |
People are most likely not going to read the readme or docs on the item, maybe deprecate it so long with that message that it will work if you copy the two classes into your own project? |
I'm currently trying to track down why this is happening. When depending on the published libraries, published libraries: |
I've now updated the readme to warn people about this bug and provided instructions on what to do. |
Great news! Yan Zhulanow from Jetbrains provided the solution to this on the Youtrack issue. New build 2.5.1 is now available, please use it and verify it fixes the problem. |
@ValCanBuild 💥 It's fixed! |
I've created a self-contained project using groupie where I checked that seems the caching of the kotlin synthetic views seems not being used whatsover .
if you look at the code
It will produce the following bytecode
which it stills use
findViewById
and notfindViewByCache
sinceItem
doesn't implementsLayoutContainer
doesn't really matter that ViewHolder implements its Ithink, the Kotlin Compiler doesn´t know about that because it really expects theItem
implementing it so it doesn´t generate the caching bytecode, seems like doing this is the same as not using LayoutContainer whatsover since it stills make the lookup in the hole itemView tree view.Or maybe I'm really missing something here
Project:
https://gitlab.com/leobrujah/kotlin-synthetic-test/blob/master/app/src/main/java/com/test/kotlinsyntheticssample/MainActivity.kt
The text was updated successfully, but these errors were encountered: