Skip to content
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

Firebase Performance Plugin Null Pointer Exception While Measuring Network Performance #3406

Closed
tfkci opened this issue Feb 4, 2022 · 1 comment · Fixed by #3415
Closed
Assignees

Comments

@tfkci
Copy link

tfkci commented Feb 4, 2022

[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 categories 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: Android Studio Dolphin | 2021.3.1 Canary 1
  • Firebase Component: Performance
  • Component version: 'com.google.firebase:perf-plugin:1.4.1' && ('com.google.firebase:firebase-bom:29.0.4')

[REQUIRED] Step 3: We follow the null-pointer exception after upgrading the performance plugin, while the Performance plugin tries to measure some third-party SDK's network calls.

Steps to reproduce: The problem is not reproducible on our end

What happened? How can we make the problem occur?

image

While the 3rd party SDK's relevant code is null-safe,

com.google.firebase.perf.network.InstrHttpInputStream.close (InstrHttpInputStream.java:67) this line is not. We assess while trying to measure network performance inputStream object closes before measuring.

Relevant Code:

Their code's relevant part :

image

// TODO(you): The bug can not be reproducible on our end

image

@raymondlam
Copy link
Member

HI @tfkci, thanks for raising this issue.

Without a way to replicate this, it's a bit tricky to figure out the full root cause.

Digging into the code, InstrHttpInputStream accepts an InputStream but does not modify the variable reference within the class

InstrHttpInputStream is used by InstrURLConnectionBase and has one place where there could be a null could possibility be passed in:

      final InputStream inputStream = httpUrlConnection.getInputStream();
      return new InstrHttpInputStream(inputStream, networkMetricBuilder, timer);

return new InstrHttpInputStream(inputStream, networkMetricBuilder, timer);

Although getInputStream() doesn't mention that a null can be returned, I can add a null check here to make sure that this isn't null. I'll reach out to some team members to see if they spot anything else.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants