Skip to content

anr - with repro steps - com.google.android.c2dm.intent.RECEIVE #3382

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

Closed
aapunain opened this issue Jan 31, 2022 · 17 comments
Closed

anr - with repro steps - com.google.android.c2dm.intent.RECEIVE #3382

aapunain opened this issue Jan 31, 2022 · 17 comments

Comments

@aapunain
Copy link

[READ] Step 1: Are you in the right place?

Issues filed here should be about bugs in the code in this repository.
If you have a general question, need help debugging, or fall into some
other category use one of these other channels:

  • For general technical questions, post a question on StackOverflow
    with the firebase tag.
  • For general Firebase discussion, use the firebase-talk
    google group.
  • For help troubleshooting your application that does not fall under one
    of the above categories, reach out to the personalized
    Firebase support channel.

[REQUIRED] Step 2: Describe your environment

  • Android Studio version: Arctic fox_
  • Firebase Component: _BOM (29.0.3) (Database, Firestore, Storage, Functions, etc)
  • Component version: _____

[REQUIRED] Step 3: Describe the problem

ANR in x.y.z
PID: ##
Reason: Broadcast of Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x11000010 pkg=x.y.z cmp=x.y.z/com.google.firebase.iid.FirebaseInstanceIdReceiver (has extras) }

Steps to reproduce:

its getting reported in play console for app at #1

i tried to reproduce it in sample app

put Thread.sleep(15000) in Application-> onCreate()

now send message
when I sent "data message" issue not reproduced
but when I sent "notification message" issue reproduced

** sent message every time after killing app process

WHY IS IT SO?? .. if its because of time taken in Application's onCreate then why its not occurring for both the cases.

Relevant Code:

mentioned above
@google-oss-bot
Copy link
Contributor

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@argzdev
Copy link
Contributor

argzdev commented Jan 31, 2022

Thanks for reporting, @aapunain. May I ask which Firebase component are you using and using it at what version? Is it 29.0.3?

@aapunain
Copy link
Author

Thanks for reporting, @aapunain. May I ask which Firebase component are you using and using it at what version? Is it 29.0.3?

YES
implementation platform('com.google.firebase:firebase-bom:29.0.3')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-messaging'

@argzdev
Copy link
Contributor

argzdev commented Jan 31, 2022

Thanks for the details, @aapunain. While we look into this, any chance you could provide us an MCVE of this issue? It'll greatly help us in our investigation.

@waseefakhtar
Copy link

waseefakhtar commented Jan 31, 2022

It's been the same for us. It's the # 1 ANR in our app right now. And I see there were plenty of issues opened for it but I see them closed by the bot without any solution by anyone:

#3308
#3059

Has updating to the latest BOM solved it for anyone? I currently use these versions:

"com.google.firebase:firebase-common:16.0.3"
"com.google.firebase:firebase-analytics:18.0.2"
"com.google.firebase:firebase-plugins:1.1.0"
"com.google.firebase:firebase-iid:20.0.2"
"com.google.firebase:firebase-messaging:20.2.4"
"com.google.firebase:firebase-config:19.1.1"
"com.google.firebase:firebase-crashlytics:17.2.1"
"com.google.firebase:firebase-crashlytics-gradle:2.3.0"

@argzdev
Copy link
Contributor

argzdev commented Feb 2, 2022

Hi @waseefakhtar, ANR issues can be due to many reasons, as such we treat it as a different case for each developer. With that said, could you create a new issue with our template so we can investigate your issue as well. Thanks!

@argzdev
Copy link
Contributor

argzdev commented Feb 2, 2022

@aapunain, could you clarify the steps to reproduce the issue, if I understand correctly:

  1. Add Thread.sleep(15000) in the onCreate method of Application class
  2. Using a server send a "notification message"
  3. App crashes after receiving message

Is this correct? Also if you could provide us an MCVE, it'll speed up our investigation, thanks!

@aapunain aapunain closed this as completed Feb 4, 2022
@aapunain
Copy link
Author

aapunain commented Feb 4, 2022

@argzdev yes right
I will attach MCVE also by EOD

@argzdev
Copy link
Contributor

argzdev commented Feb 4, 2022

Thanks for confirming, @aapunain. I'll wait for the MCVE. I also re-opened the issue, I think you mistakenly closed it.

@argzdev argzdev reopened this Feb 4, 2022
@aapunain
Copy link
Author

aapunain commented Feb 4, 2022

@argzdev
PFA

AnrMcve.zip

@argzdev
Copy link
Contributor

argzdev commented Feb 7, 2022

Thanks for the MCVE, @aapunain. Unfortunately, I'm unable to repro the issue.

Here is the relevant code of my node JS server:

const registrationToken = 'YOUR_REGISTRATION_TOKEN_HERE';

const message = {
  data: {
    score: '850',
    time: '2:45'
  },
  notification: {
    "body" : "This is an FCM notification that displays an image.!",
    "title" : "FCM Notification",
    "image": "https://dogtime.com/assets/uploads/2011/03/puppy-development.jpg",
  },
  token: registrationToken
};

admin.messaging().send(message)
  .then((response) => {
    console.log('Successfully sent message:', response);
  })
  .catch((error) => {
    console.log('Error sending message:', error);
  });

Here are the steps I did:

  1. Run the app on Android 10.0.0
  2. While app is in sleeping mode: onCreate: app sleeping
  3. Call node index.js
  4. App wakes up: onCreate: app woke up
  5. App receives message and handleintent, no crash happened.

Am I missing anything? Could you provide more details or information for me to repro the issue? Thanks!

@aapunain
Copy link
Author

aapunain commented Feb 7, 2022

@argzdev don't start app first ..
Kill the app process
Then send the notification message.. I was sending it from 🔥base console

@argzdev
Copy link
Contributor

argzdev commented Feb 7, 2022

Thanks for the extra details, @aapunain. I was able to repro the issue, I'll notify an engineer and see what we can do here.

@fanfanxiaozu
Copy link

fanfanxiaozu commented Feb 8, 2022

image
This timeout is too long, only leave 1s to do other things. If change it to 5000, I think anr will less.

@argzdev
Copy link
Contributor

argzdev commented Feb 9, 2022

Thanks for the extra details, @fanfanxiaozu. It is plausible that this causes the ANR, but this may require a deeper investigation by our engineers.

Hi @aapunain, our engineers have responded with the following:

An app should avoid doing any blocking work in the main thread, including things like disk and network IO. Sleeping for seconds is a big problem.
If this can be reproduced using a realistic app then it is something we can look into.

With that said, if you could provide more details about this issue, then I can probably justify an engineer’s time to dig into it with that much evidence. Thanks!

@aapunain
Copy link
Author

aapunain commented Feb 9, 2022

@argzdev Thanks for details.

I agree with your point that this is happening when main thread is blocked in app's oncreate
And yes this is happening in realistic app, may be that app is taking 10+ seconds in on create, I will dig that definitely.

But my point is that:
#1. its happening only in case when 'notification message' is sent but not in case when 'data message' is sent, why is it so?
#2. Can not this be prevented in 'notification message' case similarly?

From 'notification message' and 'data message' I mean :
https://firebase.google.com/docs/cloud-messaging/concept-options#notifications_and_data_messages

@argzdev
Copy link
Contributor

argzdev commented Feb 10, 2022

Hi @aapunain, unfortunately, I cannot answer your question. As of the moment, our engineers have a lot on their plates and this would require an engineer to investigate the code to check the logic with that case. If you’d like us to dig deeper on this, you could provide us with a realistic situation or an app without blocking the UI thread where this issue is experienced.

As a good practice, it is usually best not to block the main thread when performing operations, since this can cause unexpected issues. With that said, I'll be closing this issue for now, feel free to open a new ticket with the said details. Thanks!

@argzdev argzdev closed this as completed Feb 10, 2022
@firebase firebase locked and limited conversation to collaborators Mar 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants