-
Notifications
You must be signed in to change notification settings - Fork 44
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
Add R8/ProGuard rules to the codegen artifact #143
base: master
Are you sure you want to change the base?
Conversation
Also process the codegen test code with both R8 and ProGuard to ensure they work correctly in practice.
@@ -0,0 +1,49 @@ | |||
# When using factories or builders, the enclosing class is used to determine the component type. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a mention of @Binds
which I think may be a special case as it's not referenced by generated Dagger component code. Is it covered by one of these rules?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These rules are for the codegen artifact reflection, not the reflection in the reflect artifact.
I'm not convinced anyone will be using shrinking with the reflect artifact. I'd be curious what their use case for this was.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, good point, sorry.
Re shrinking with reflect: we sometimes minifyEnabled=true on debug flavor so we can test shrinking-related issues. If dagger-reflect was set up it with if (idea)
this quick-change-for-debugging would fail the build unexpectedly because of reflect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, though, having dagger-reflect in your APK would already produce results that were not representative of what happens when shrinking in release. In release builds a large portion of Dagger-generated types are vertically merge and/or inlined. I've even written some non-trivial graphs that have been completely eliminated by shrinking leaving only a bunch of chained calls to constructors.
I'm not opposed to adding rules to the reflect artifact. They're probably pretty basic. But I think the concept of shrinking and using reflect are mutually exclusive in their goals so it's not a high priority.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I was referring to here is adding minifyEnabled=true
to debug so that we can verify things not related to Dagger, or dagger-reflect. But at the moment if the debug build is set up with dagger-reflect, it prevents debugging other problems., because injection crashes. I see why it's not high priority though, as it shouldn't be hard to turn off dagger-reflect, it's just inconvenient.
The ruleset crashed on my branch using the activity in To replicate the issue:
The current broader ruleset works. |
Thanks. I'll look soon. Although I'd be happy to land this as-is and fix that separately as a bug. |
Using this ruleset even basic use of |
I might be misunderstanding how it works, do we need to mark components with |
When I wrote them I was inspecting the classfile output of both tools and
both looked correct.
…On Thu, Jul 18, 2019 at 1:22 PM Laimonas Turauskas ***@***.***> wrote:
Using this ruleset even basic use of AppComponent crashes. I suspect that
the R8 doesn't run correctly during the test you have written because that
exact use case crashes for me.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#143?email_source=notifications&email_token=AAAQIEIPJPSV5GZJJVRWF4LQACREDA5CNFSM4IDSBLTKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2JGBRA#issuecomment-512909508>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAQIEK2NTOEMFMZISL4CALQACREDANCNFSM4IDSBLTA>
.
|
Any ideas of what could be the cause for the crash? |
I haven't had time to look at it yet so I don't even know what's crashing.
…On Thu, Jul 18, 2019 at 2:26 PM Laimonas Turauskas ***@***.***> wrote:
Any ideas of what could be the cause for the crash?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#143?email_source=notifications&email_token=AAAQIEKL4XJOIKKPJR5XFGTQACYUFA5CNFSM4IDSBLTKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2JLUDQ#issuecomment-512932366>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAQIEMCOAVEK5PUBP2STP3QACYUFANCNFSM4IDSBLTA>
.
|
@JakeWharton Played around a bit, but couldn't make it work.
// integration-tests/android/build.gradle
buildTypes {
debug {
minifyEnabled true
shrinkResources minifyEnabled
}
}
android.enableR8=true
com.example.AppComponent
|- is referenced in keep rule:
| <PROGUARD_COMPATIBILITY_RULE>:Unknown
Nothing is keeping com.example.DaggerAppComponent android.enableR8=true
android.enableR8.fullMode=true
Nothing is keeping com.example.AppComponent
Nothing is keeping com.example.DaggerAppComponent android.enableR8=false
com.example.AppComponent
is invoked by com.example.DaggerAppComponent.create (32:32)
is kept by a directive in the configuration.
com.example.DaggerAppComponent
is kept by a directive in the configuration.
# but still crashes with java.lang.ClassNotFoundException: Didn't find class "com.example.Daggera"
|
You stated |
Uuuuh, @mochadwi I have no memory of doing this investigation :D, but here are my thoughts: The whole point of the comment is validating @Laimiux's claim that in the current state it crashes, and trying to find out why to help @JakeWharton, which is: the keeps to achieve what's in 3. is missing (or handled differently in all 3 shrinking modes as seen in 2.) from the generic rules in this PR. So of course, manually keeping your |
Nice, I really appreciate it for your answer. That's explained everything about this issue still open. @TWiStErRob |
Also process the codegen test code with both R8 and ProGuard to ensure they work correctly in practice.