Skip to content

Fireperf: fix incorrect sessionIds for _fs and _bs traces #3122

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

Merged
merged 4 commits into from
Feb 11, 2022

Conversation

leotianlizhan
Copy link
Contributor

@leotianlizhan leotianlizhan commented Nov 10, 2021

b/204362742

TLDR

_fs and _bs traces are using the next sessionId instead of the current sessionId because we call updateAppState (line 176) before sending _fs or _bs traces (line 177). One of the callbacks of updateAppState is SessionManager which updates the sessionId, thus _fs and _bs uses the next session's sessionId.

This fix simply changes the order of methods, delaying updateAppState until session trace is sent.

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Nov 10, 2021

Coverage Report 1

Affected Products

  • firebase-perf

    Overall coverage changed from 70.80% (d9aa5b8) to 70.82% (1d36a60) by +0.02%.

    FilenameBase (d9aa5b8)Merge (1d36a60)Diff
    AppStateMonitor.java86.63%86.86%+0.23%
    AppStateUpdateHandler.java92.59%92.86%+0.26%

Test Logs

Notes

  • Commit (1d36a60) is created by Prow via merging PR base commit (d9aa5b8) and head commit (3f185ec).
  • Run gradle <product>:checkCoverage to produce HTML coverage reports locally. After gradle commands finished, report files can be found under <product-build-dir>/reports/jacoco/.

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/1VcJ6BFDcb.html

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Nov 10, 2021

Size Report 1

Affected Products

  • firebase-perf

    TypeBase (d9aa5b8)Merge (1d36a60)Diff
    aar301 kB301 kB+125 B (+0.0%)
    apk (aggressive)982 kB982 kB+64 B (+0.0%)
    apk (release)2.45 MB2.45 MB-32 B (-0.0%)

Test Logs

Notes

  • Commit (1d36a60) is created by Prow via merging PR base commit (d9aa5b8) and head commit (3f185ec).

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/4eRPAxvH2C.html

@leotianlizhan leotianlizhan changed the title Fireperf: fix incorrect sessionIds for _fs and _bs traces Fireperf: fix incorrect sessionIds for _fs and _bs traces Nov 11, 2021
Copy link
Contributor

@jeremyjiang-dev jeremyjiang-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for finding the bug and creating a fix! The changes look good to me.

Can you add some tests to make sure the session IDs are correctly generated?

@leotianlizhan
Copy link
Contributor Author

/test smoke-tests

Copy link
Contributor

@jeremyjiang-dev jeremyjiang-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for identifying and fixing this!!!

Copy link
Contributor

@visumickey visumickey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making this change.

sendSessionLog(Constants.TraceNames.FOREGROUND_TRACE_NAME.toString(), resumeTime, stopTime);
// order is important to avoid b/204362742
updateAppState(ApplicationProcessState.BACKGROUND);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also qualify the reasoning for this ordering? For example: Complete _fs trace before triggering a change in the application state as that would lead to a new sessionID change.

@leotianlizhan leotianlizhan merged commit 09fe06e into master Feb 11, 2022
@leotianlizhan leotianlizhan deleted the fireperf-fs-bs-session-id branch February 11, 2022 19:50
qdpham13 pushed a commit that referenced this pull request Feb 15, 2022
* simple fix by changing order of methods

* add test

* comments

* rewording
jeremyjiang-dev pushed a commit that referenced this pull request Mar 9, 2022
* simple fix by changing order of methods

* add test

* comments

* rewording
@firebase firebase locked and limited conversation to collaborators Mar 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes Override cla size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants