简体   繁体   English

ANR 错误“Broadcast of Intent { act=com.google.firebase.INSTANCE_ID_EVENT”……Android 7.1 和 8.0 的“FirebaseInstanceIdInternalReceiver”

[英]ANR error “Broadcast of Intent { act=com.google.firebase.INSTANCE_ID_EVENT” … “FirebaseInstanceIdInternalReceiver” for Android 7.1 and 8.0

We have an Android app that have many ANR errors reported lately.我们有一个 Android 应用程序,最近报告了许多 ANR 错误。 This only occurs on Android 7.1 and 8.0 (not on eg 4.4, 5.0 or 6.0).这仅发生在 Android 7.1 和 8.0 上(例如 4.4、5.0 或 6.0)。 The ANR is: ANR 是:

Broadcast of Intent { act=com.google.firebase.INSTANCE_ID_EVENT flg=0x14 cmp=com.our.package.name/com.google.firebase.iid.FirebaseInstanceIdInternalReceiver (has extras) }

The question is: Why do we get this ANR, and what can we do to avoid this?问题是:为什么我们会得到这个 ANR,我们可以做些什么来避免这种情况? Note that this works fine on earlier Android-versions, which in my opinion proves that we do not do any of the rookie-mistakes causing ANR.请注意,这在早期的 Android 版本上运行良好,在我看来,这证明我们没有犯任何导致 ANR 的新手错误。

I am having a really hard time reproducing this bug.我真的很难重现这个错误。 Since it is only on Android 7.1 and 8.0 I think it may have to do with the new doze mode and battery saving, but even using adb shell dumpsys deviceidle force-idle etc. while testing does not reproduce this issue, neither does putting in SystemClock.sleep(20000);由于它仅在 Android 7.1 和 8.0 上,我认为它可能与新的休眠模式和省电有关,但即使使用adb shell dumpsys deviceidle force-idle 等,在测试时也不会重现此问题,也不会放入SystemClock.sleep(20000); several places.几个地方。

Our code for InstanceIdService is:我们的InstanceIdService代码是:

public class InstanceIdService extends FirebaseInstanceIdService {
    private Analytics mAnalytics;

    @Override
    public void onCreate() {
        super.onCreate();

        mAnalytics = new AnalyticsImpl();
        boolean isFullVersion = getApplicationContext().getPackageName().endsWith("full");
        mAnalytics.init(getApplicationContext(), isFullVersion);
    }

    @Override
    public void onTokenRefresh() {
        boolean initialLoginSucceeded = OurAppNameApplication.getInstance().getSettings().getInitialLoginSucceeded();
        mAnalytics.logEvent("FCM_Token_Refresh_Triggered", "initialLoginSucceeded", String.valueOf(initialLoginSucceeded));

        if (initialLoginSucceeded) { // We only report the FCM token to our server if the user has logged in at least once
            OurAppNameApplication.getInstance().getOurAppNameService().registerDeviceWithRetry();
        }
    }
}

We use Google Play Services and Firebase version 11.2.0.我们使用 Google Play 服务和 Firebase 11.2.0 版。 Our targetSdkVersion is 25.我们的 targetSdkVersion 是 25。

PS: The code mAnalytics.init(...) above gives us a StrictMode warning, as this initializes Flurry . PS:上面的代码mAnalytics.init(...)给了我们一个 StrictMode 警告,因为它初始化了 Flurry But this is disk access, not network traffic.但这是磁盘访问,而不是网络流量。 And putting in SystemClock.sleep(20000);并放入SystemClock.sleep(20000); at this location does not trigger any ANR.在这个位置不会触发任何ANR。

Why do we get an ANR, and what can we do to avoid this?为什么我们会收到 ANR,我们可以做些什么来避免这种情况?

-- ——

Edit: As per the suggestion in the comment from Bob Snyder, I have tried to test with adb shell cmd appops set com.our.package.name RUN_IN_BACKGROUND ignore .编辑:根据 Bob Snyder 评论中的建议,我尝试使用adb shell cmd appops set com.our.package.name RUN_IN_BACKGROUND ignore进行测试。 However, this does not produce any ANR, it only stops our Broadcast receiver from running, as shown in logcat:然而,这不会产生任何 ANR,它只会阻止我们的广播接收器运行,如 logcat 所示:

09-21 10:39:25.314 943-6730/? W/ActivityManager: Background start not allowed: service Intent { act=com.google.firebase.INSTANCE_ID_EVENT pkg=com.our.package.name cmp=com.our.package.name/com.our.package.service.notifications.InstanceIdService (has extras) } to com.our.package.name/com.our.package.service.notifications.InstanceIdService from pid=4062 uid=10139 pkg=com.our.package.name
09-21 10:39:25.314 4062-4062/com.our.package.name E/FirebaseInstanceId: Error while delivering the message: ServiceIntent not found.

My conclusion is that this may not be a correct way to reproduce this ANR error.我的结论是,这可能不是重现此 ANR 错误的正确方法。

For completeness sake: All ADB commands used when testing are:为了完整起见:测试时使用的所有 ADB 命令是:

adb shell dumpsys deviceidle force-idle
adb shell dumpsys battery unplug
adb shell am set-inactive com.our.package.name true
adb install -r our-app.apk
adb shell cmd appops set com.our.package.name RUN_IN_BACKGROUND ignore

(Actually - the last line is run many times in parallel with the adb install so that we are sure it takes effect before the installation and restore (of settings) is done and Firebase registration token is automatically refreshed after the installation.) (实际上 - 最后一行与adb install并行运行多次,以便我们确保它在安装和恢复(设置)完成之前生效,并且安装后 Firebase 注册令牌会自动刷新。)

This is a bug that was fixed in the September 18 release of the FCM SDK :这是FCM SDK 9 月 18 日版本中修复的错误:

Fixed an issue that would occasionally cause apps to crash with Android Not Responding (ANR) errors when receiving a message.修复了在接收消息时偶尔会导致应用程序崩溃并显示 Android 无响应 (ANR) 错误的问题。

Updating to com.google.firebase:firebase-messaging:17.3.2 or later should fix the issue.更新到com.google.firebase:firebase-messaging:17.3.2或更高版本应该可以解决问题。 If it doesn't, please contact support .如果没有,请联系支持

Try the latest version of Firebase and Play Services SDKs (v. 11.4.2).试用最新版本的FirebasePlay Services SDKs (v. 11.4.2)。 Also change your targetSDKVersion to 26 and BuildToolsVersion to 26.0.2. targetSDKVersion您的targetSDKVersion更改为 26,并将BuildToolsVersion为 26.0.2。

I was also receiving the same error for Google Pixel/Nexus devices running on Android 8.0.对于在 Android 8.0 上运行的 Google Pixel/Nexus 设备,我也收到了同样的错误。 I haven't received any new report after updating all the libraries.更新所有库后,我没有收到任何新报告。

Why do we get this ANR, and what can we do to avoid this?为什么我们会得到这个 ANR,我们可以做些什么来避免这种情况?

Not really sure why this is happening.不太确定为什么会发生这种情况。 I contacted Firebase support as well to know the reasons but they asked for mcve and since I don't know what is causing the problem I wasn't able to provide mcve.我也联系了 Firebase 支持人员以了解原因,但他们要求提供mcve ,由于我不知道是什么导致了问题,因此我无法提供 mcve。 I am using only Firebase authentication in my app, so I firmly believe the issue has something to do with it.我在我的应用中只使用 Firebase 身份验证,所以我坚信这个问题与它有关。

Application Memory Leak can be one reason for emitting this com.google.firebase.iid.firebaseinstanceidreceiver ANR .应用程序内存泄漏可能是发出此com.google.firebase.iid.firebaseinstanceidreceiver ANR 的原因之一。

So you can verify on Android profiler for your app memory leak, If memory leak issue is fix then this ANR automatically come DOWN.因此,您可以在Android Profiler上验证您的应用程序内存泄漏,如果内存泄漏问题已修复,则此 ANR 会自动关闭。

Hope this help to all you guys.希望这对大家有帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 接收广播Intent时出错{act = com.google.android.gms.appinvite.intent.action.INVITE_SENT - Error receiving broadcast Intent { act=com.google.android.gms.appinvite.intent.action.INVITE_SENT ANR意图播报{act = com.google.android.c2dm.intent.RECEIVE flg = 0x10 cmp = receiver.GcmBroadcastReceiver(有其他功能)} - ANR Broadcast of Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10 cmp=receiver.GcmBroadcastReceiver (has extras) } 错误广播意图回调:result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg=com.flagg327.guicomaipu(有额外的)} - Error broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg=com.flagg327.guicomaipu (has extras) } ANR 意图广播 { act=android.intent.action.SCREEN_ON flg=0x50200010(有额外内容)} - ANR Broadcast of Intent { act=android.intent.action.SCREEN_ON flg=0x50200010 (has extras) } ANR 意图广播 { act=android.intent.action.SCREEN_OFF flg=0x50000010 } - ANR Broadcast of Intent { act=android.intent.action.SCREEN_OFF flg=0x50000010 } 接收广播时出错 Intent act=com.android.vending.billing.PURCHASES_UPDATED - Error receiving broadcast Intent act=com.android.vending.billing.PURCHASES_UPDATED 无法启动接收器com.google.firebase.iid.FirebaseInstanceIdInternalReceiver - Unable to start receiver com.google.firebase.iid.FirebaseInstanceIdInternalReceiver ANR 意图广播 { act=android.intent.action.TIME_TICK flg=0x50000014(有额外内容)} 问题 - ANR Broadcast of Intent { act=android.intent.action.TIME_TICK flg=0x50000014 (has extras) } issue ANR 意图广播 - ANR Broadcast of Intent Android GCM错误:java.lang.SecurityException:不允许启动服务意图{act = com.google.android.c2dm.intent.REGISTER} - Android GCM error: java.lang.SecurityException: Not allowed to start service Intent { act=com.google.android.c2dm.intent.REGISTER }
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM