Closed aapunain closed 2 years ago
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
Thanks for reporting, @aapunain. May I ask which Firebase component are you using and using it at what version? Is it 29.0.3?
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'
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.
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:
https://github.com/firebase/firebase-android-sdk/issues/3308 https://github.com/firebase/firebase-android-sdk/issues/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"
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!
@aapunain, could you clarify the steps to reproduce the issue, if I understand correctly:
Thread.sleep(15000)
in the onCreate
method of Application
classIs this correct? Also if you could provide us an MCVE, it'll speed up our investigation, thanks!
@argzdev yes right I will attach MCVE also by EOD
Thanks for confirming, @aapunain. I'll wait for the MCVE. I also re-opened the issue, I think you mistakenly closed it.
@argzdev PFA
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:
onCreate: app sleeping
node index.js
onCreate: app woke up
Am I missing anything? Could you provide more details or information for me to repro the issue? Thanks!
@argzdev don't start app first .. Kill the app process Then send the notification message.. I was sending it from 🔥base console
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.
This timeout is too long, only leave 1s to do other things. If change it to 5000, I think anr will less.
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!
@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:
From 'notification message' and 'data message' I mean : https://firebase.google.com/docs/cloud-messaging/concept-options#notifications_and_data_messages
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!
[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:
[REQUIRED] Step 2: Describe your environment
[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: