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

Add SessionMaintainerFollower and create in FirebaseSessions when… #5368

Open
wants to merge 9 commits into
base: session-maintainer
Choose a base branch
from

Conversation

jrothfeder
Copy link
Contributor

… we're a follower process.

daymxn and others added 2 commits September 26, 2023 15:59
@google-oss-bot
Copy link
Contributor

google-oss-bot commented Sep 27, 2023

Coverage Report 1

This report is too large (214,739 characters) to be displayed here in a GitHub comment. Please use the below link to see the full report on Google Cloud Storage.

Test Logs

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

@github-actions
Copy link
Contributor

github-actions bot commented Sep 27, 2023

Unit Test Results

   820 files     820 suites   41m 34s ⏱️
5 008 tests 4 987 ✔️ 21 💤 0
9 925 runs  9 883 ✔️ 42 💤 0

Results for commit 2300e61.

♻️ This comment has been updated with latest results.

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Sep 27, 2023

Size Report 1

Affected Products

  • base

    TypeBase (2ccb569)Merge (99bfafd)Diff
    apk (aggressive)?8.39 kB? (?)
    apk (release)?8.66 kB? (?)
  • firebase-abt

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?13.9 kB? (?)
    apk (aggressive)?116 kB? (?)
    apk (release)?1.27 MB? (?)
  • firebase-annotations

    TypeBase (2ccb569)Merge (99bfafd)Diff
    apk (aggressive)?8.39 kB? (?)
    apk (release)?9.47 kB? (?)
  • firebase-appcheck

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?36.9 kB? (?)
    apk (aggressive)?362 kB? (?)
    apk (release)?1.56 MB? (?)
  • firebase-appcheck-debug

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?11.3 kB? (?)
    apk (aggressive)?363 kB? (?)
    apk (release)?1.56 MB? (?)
  • firebase-appcheck-debug-testing

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?7.40 kB? (?)
    apk (aggressive)?380 kB? (?)
    apk (release)?1.64 MB? (?)
  • firebase-appcheck-interop

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?5.10 kB? (?)
    apk (aggressive)?312 kB? (?)
    apk (release)?931 kB? (?)
  • firebase-appcheck-ktx

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?6.08 kB? (?)
    apk (aggressive)?370 kB? (?)
    apk (release)?1.94 MB? (?)
  • firebase-appcheck-playintegrity

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?11.1 kB? (?)
    apk (aggressive)?365 kB? (?)
    apk (release)?1.57 MB? (?)
  • firebase-appcheck-safetynet

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?10.5 kB? (?)
    apk (aggressive)?364 kB? (?)
    apk (release)?1.57 MB? (?)
  • firebase-appdistribution

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?251 kB? (?)
    apk (aggressive)?904 kB? (?)
    apk (release)?2.64 MB? (?)
  • firebase-appdistribution-api

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?16.0 kB? (?)
    apk (aggressive)?112 kB? (?)
    apk (release)?1.27 MB? (?)
  • firebase-appdistribution-api-ktx

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?5.94 kB? (?)
    apk (aggressive)?124 kB? (?)
    apk (release)?1.65 MB? (?)
  • firebase-common

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?75.7 kB? (?)
    apk (aggressive)?112 kB? (?)
    apk (release)?1.26 MB? (?)
  • firebase-common-ktx

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?13.3 kB? (?)
    apk (aggressive)?123 kB? (?)
    apk (release)?1.64 MB? (?)
  • firebase-components

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?45.5 kB? (?)
    apk (aggressive)?23.3 kB? (?)
    apk (release)?596 kB? (?)
  • firebase-config

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?89.7 kB? (?)
    apk (aggressive)?152 kB? (?)
    apk (release)?1.32 MB? (?)
  • firebase-config-ktx

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?10.0 kB? (?)
    apk (aggressive)?160 kB? (?)
    apk (release)?1.71 MB? (?)
  • firebase-crashlytics

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?359 kB? (?)
    apk (aggressive)?433 kB? (?)
    apk (release)?2.17 MB? (?)
  • firebase-crashlytics-ktx

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?7.40 kB? (?)
    apk (aggressive)?433 kB? (?)
    apk (release)?2.18 MB? (?)
  • firebase-crashlytics-ndk

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?1.66 MB? (?)
    apk (aggressive / arm64-v8a)?1.60 MB? (?)
    apk (aggressive / armeabi-v7a)?1.08 MB? (?)
    apk (aggressive / x86)?1.58 MB? (?)
    apk (aggressive / x86_64)?1.64 MB? (?)
    apk (release / arm64-v8a)?3.34 MB? (?)
    apk (release / armeabi-v7a)?2.81 MB? (?)
    apk (release / x86)?3.32 MB? (?)
    apk (release / x86_64)?3.38 MB? (?)
  • firebase-database

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?488 kB? (?)
    apk (aggressive)?359 kB? (?)
    apk (release)?1.72 MB? (?)
  • firebase-database-collection

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?33.7 kB? (?)
    apk (aggressive)?312 kB? (?)
    apk (release)?942 kB? (?)
  • firebase-database-ktx

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?28.2 kB? (?)
    apk (aggressive)?367 kB? (?)
    apk (release)?2.11 MB? (?)
  • firebase-datatransport

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?5.82 kB? (?)
    apk (aggressive)?163 kB? (?)
    apk (release)?1.35 MB? (?)
  • firebase-decoders-json

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?7.76 kB? (?)
    apk (aggressive)?8.69 kB? (?)
    apk (release)?15.3 kB? (?)
  • firebase-dynamic-links

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?53.6 kB? (?)
    apk (aggressive)?360 kB? (?)
    apk (release)?1.56 MB? (?)
  • firebase-dynamic-links-ktx

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?8.39 kB? (?)
    apk (aggressive)?368 kB? (?)
    apk (release)?1.94 MB? (?)
  • firebase-dynamic-module-support

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?5.73 kB? (?)
    apk (aggressive)?124 kB? (?)
    apk (release)?1.31 MB? (?)
  • firebase-encoders

    TypeBase (2ccb569)Merge (99bfafd)Diff
    apk (aggressive)?8.69 kB? (?)
    apk (release)?15.3 kB? (?)
  • firebase-encoders-json

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?11.4 kB? (?)
    apk (aggressive)?24.0 kB? (?)
    apk (release)?596 kB? (?)
  • firebase-encoders-proto

    TypeBase (2ccb569)Merge (99bfafd)Diff
    apk (aggressive)?8.87 kB? (?)
    apk (release)?21.7 kB? (?)
  • firebase-encoders-reflective

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?7.88 kB? (?)
    apk (aggressive)?9.06 kB? (?)
    apk (release)?22.5 kB? (?)
  • firebase-firestore

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?1.36 MB? (?)
    apk (aggressive)?520 kB? (?)
    apk (release)?3.95 MB? (?)
  • firebase-firestore-ktx

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?25.4 kB? (?)
    apk (aggressive)?528 kB? (?)
    apk (release)?4.34 MB? (?)
  • firebase-functions

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?47.1 kB? (?)
    apk (aggressive)?400 kB? (?)
    apk (release)?1.82 MB? (?)
  • firebase-functions-ktx

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?6.33 kB? (?)
    apk (aggressive)?408 kB? (?)
    apk (release)?2.19 MB? (?)
  • firebase-inappmessaging

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?458 kB? (?)
    apk (aggressive)?701 kB? (?)
    apk (release)?3.96 MB? (?)
  • firebase-inappmessaging-display

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?182 kB? (?)
    apk (aggressive)?1.53 MB? (?)
    apk (release)?5.22 MB? (?)
  • firebase-inappmessaging-display-ktx

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?17.7 kB? (?)
    apk (aggressive)?1.54 MB? (?)
    apk (release)?5.60 MB? (?)
  • firebase-inappmessaging-ktx

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?5.13 kB? (?)
    apk (aggressive)?709 kB? (?)
    apk (release)?4.34 MB? (?)
  • firebase-installations

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?55.4 kB? (?)
    apk (aggressive)?114 kB? (?)
    apk (release)?1.28 MB? (?)
  • firebase-installations-interop

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?8.17 kB? (?)
    apk (aggressive)?65.2 kB? (?)
    apk (release)?652 kB? (?)
  • firebase-installations-ktx

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?5.11 kB? (?)
    apk (aggressive)?127 kB? (?)
    apk (release)?1.67 MB? (?)
  • firebase-messaging

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?142 kB? (?)
    apk (aggressive)?465 kB? (?)
    apk (release)?1.72 MB? (?)
  • firebase-messaging-directboot

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?5.19 kB? (?)
    apk (aggressive)?465 kB? (?)
    apk (release)?1.72 MB? (?)
  • firebase-messaging-ktx

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?6.21 kB? (?)
    apk (aggressive)?472 kB? (?)
    apk (release)?2.10 MB? (?)
  • firebase-ml-modeldownloader

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?122 kB? (?)
    apk (aggressive)?168 kB? (?)
    apk (release)?1.41 MB? (?)
  • firebase-ml-modeldownloader-ktx

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?6.22 kB? (?)
    apk (aggressive)?176 kB? (?)
    apk (release)?1.79 MB? (?)
  • firebase-perf

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?318 kB? (?)
    apk (aggressive)?1.25 MB? (?)
    apk (release)?3.75 MB? (?)
  • firebase-perf-ktx

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?16.1 kB? (?)
    apk (aggressive)?1.25 MB? (?)
    apk (release)?3.76 MB? (?)
  • firebase-sessions

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?134 kB? (?)
    apk (aggressive)?369 kB? (?)
    apk (release)?2.07 MB? (?)
  • firebase-storage

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?115 kB? (?)
    apk (aggressive)?361 kB? (?)
    apk (release)?1.59 MB? (?)
  • firebase-storage-ktx

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?13.2 kB? (?)
    apk (aggressive)?369 kB? (?)
    apk (release)?1.97 MB? (?)
  • protolite-well-known-types

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?1.00e+03 kB? (?)
    apk (aggressive)?134 kB? (?)
    apk (release)?666 kB? (?)
  • transport-api

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?6.81 kB? (?)
    apk (aggressive)?8.69 kB? (?)
    apk (release)?14.9 kB? (?)
  • transport-backend-cct

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?53.8 kB? (?)
    apk (aggressive)?57.6 kB? (?)
    apk (release)?105 kB? (?)
  • transport-runtime

    TypeBase (2ccb569)Merge (99bfafd)Diff
    aar?160 kB? (?)
    apk (aggressive)?44.6 kB? (?)
    apk (release)?79.1 kB? (?)

Test Logs

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


override val isForegroundProcess: Boolean
get() {
val runningAppProcessInfo = RunningAppProcessInfo()
ActivityManager.getMyMemoryState(runningAppProcessInfo)
return runningAppProcessInfo.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND
return runningAppProcessInfo.importance <= RunningAppProcessInfo.IMPORTANCE_FOREGROUND_SERVICE
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should go back to runningAppProcessInfo.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND because IMPORTANCE_FOREGROUND_SERVICE is only available after a specific api level, and it'll make our logic complicated to also count services as leaders.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the one integration test fails if we don't consider foreground services to be foreground processes https://github.com/firebase/firebase-android-sdk/blob/master/firebase-sessions/test-app/src/androidTest/kotlin/com/google/firebase/testing/sessions/FirebaseSessionsTest.kt

That suggests to me that we may need it. Thoughts?

SessionMaintainer {
val tag = "SessionMaintainerFollow"

override fun register(subscriber: SessionSubscriber) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can say = Unit instead of an empty body. Looks better in my opinion.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is a no-op the right thing to do for followers? Should they still notify the subscribers on register?

Perf relies on the AQS session id being set before the call to firebaseSessions.register returns. Crashlytics is ok without an AQS session id.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay. We can force a lookup.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually, I'm unsure. We notify subscribers on init, and getRegisteredSusbscribers claims that it blocks until all subscribers are registered. Seems this should be okay, no?

Log.e(tag, "Error reading stored session data.", exception)
emit(emptyPreferences())
}
.map { preferences -> mapSessionsData(preferences) }
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be something like .map(::mapSessionsData) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that didn't work

FirebaseSessionsData(preferences[FirebaseSessionDataKeys.SESSION_ID])
}

const val SESSION_CONFIGS_NAME = "firebase_session_settings"
Copy link
Contributor

Choose a reason for hiding this comment

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

Putting top level constants directly in the file will cause the Firebase API check to complain, because it will generate a public class to put this in for Java. Maybe this and the FirebaseSessionDataKeys can go in a companion object instead.

@@ -22,4 +22,6 @@ import com.google.firebase.sessions.ProcessDetails
class FakeProcessDetails(
override val isDefaultProcess: Boolean = true,
Copy link
Contributor

Choose a reason for hiding this comment

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

If we have the process name and default process name in the interface, do we need this isDefaultProcess anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll remove.

data class FirebaseSessionsData(val sessionId: String?)

/** Persists session data that needs to be synchronized across processes */
class SessionsDataRepository(private val context: Context) {
Copy link
Contributor

Choose a reason for hiding this comment

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

These classes should all be internal visibility.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants