Skip to content

Commit

Permalink
Remove unnecessary -keep rule for AndroidDispatcherFactory, AndroidEx…
Browse files Browse the repository at this point in the history
…ceptionPreHandler

R8 supports keeping and/or optimizing classes found in
META-INF/services:
https://b.corp.google.com/issues/120436373#comment7

The last R8 commit I can find related to ServerLoader is
https://r8-review.googlesource.com/53824 (Sept 2020),
so I think R8 1.6 still needs the -keep rule, but 3.0+ should not.

Fixes: 3111
  • Loading branch information
agrieve committed May 17, 2022
1 parent 31b9269 commit 6ececff
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 14 deletions.
Expand Up @@ -3,3 +3,4 @@
# - META-INF/proguard/coroutines.pro

-keep class kotlinx.coroutines.android.AndroidDispatcherFactory {*;}
-keep class kotlinx.coroutines.android.AndroidExceptionPreHandler {*;}
Expand Up @@ -9,8 +9,6 @@
boolean ANDROID_DETECTED return true;
}

-keep class kotlinx.coroutines.android.AndroidDispatcherFactory {*;}

# Disable support for "Missing Main Dispatcher", since we always have Android main dispatcher
-assumenosideeffects class kotlinx.coroutines.internal.MainDispatchersKt {
boolean SUPPORT_MISSING return false;
Expand All @@ -21,4 +19,4 @@
boolean getASSERTIONS_ENABLED() return false;
boolean getDEBUG() return false;
boolean getRECOVER_STACK_TRACES() return false;
}
}

This file was deleted.

@@ -0,0 +1,6 @@
# After R8 3.0.0 (or probably sometime before that), R8 learned how to optimize
# classes mentioned in META-INF/services files, and explicitly -keeping them
# disables these optimizations.
# https://github.com/Kotlin/kotlinx.coroutines/issues/3111
-keep class kotlinx.coroutines.android.AndroidDispatcherFactory {*;}
-keep class kotlinx.coroutines.android.AndroidExceptionPreHandler {*;}
Expand Up @@ -5,3 +5,4 @@
# - META-INF/com.android.tools/r8-upto-1.6.0/coroutines.pro

-keep class kotlinx.coroutines.android.AndroidDispatcherFactory {*;}
-keep class kotlinx.coroutines.android.AndroidExceptionPreHandler {*;}
Expand Up @@ -5,12 +5,10 @@
package kotlinx.coroutines.android

import android.os.*
import androidx.annotation.*
import kotlinx.coroutines.*
import java.lang.reflect.*
import kotlin.coroutines.*

@Keep
internal class AndroidExceptionPreHandler :
AbstractCoroutineContextElement(CoroutineExceptionHandler), CoroutineExceptionHandler
{
Expand Down

0 comments on commit 6ececff

Please sign in to comment.