diff --git a/firebase-perf/CHANGELOG.md b/firebase-perf/CHANGELOG.md index 2f370bab159..8f376deff25 100644 --- a/firebase-perf/CHANGELOG.md +++ b/firebase-perf/CHANGELOG.md @@ -1,4 +1,5 @@ # Unreleased +* [fixed] Fix IllegalStateException when starting a trace before Firebase initializes. * [changed] Updated protobuf dependency to `3.25.5` to fix [CVE-2024-7254](https://github.com/advisories/GHSA-735f-pc8j-v9w8). diff --git a/firebase-perf/src/main/java/com/google/firebase/perf/config/RemoteConfigManager.java b/firebase-perf/src/main/java/com/google/firebase/perf/config/RemoteConfigManager.java index 88351ae6166..36d8c272aef 100644 --- a/firebase-perf/src/main/java/com/google/firebase/perf/config/RemoteConfigManager.java +++ b/firebase-perf/src/main/java/com/google/firebase/perf/config/RemoteConfigManager.java @@ -88,7 +88,13 @@ private RemoteConfigManager() { @VisibleForTesting @SuppressWarnings("FirebaseUseExplicitDependencies") static long getInitialStartupMillis() { - StartupTime startupTime = FirebaseApp.getInstance().get(StartupTime.class); + StartupTime startupTime = null; + try { + startupTime = FirebaseApp.getInstance().get(StartupTime.class); + } catch (IllegalStateException ex) { + // This can happen if you start a trace before Firebase is init + logger.debug("Unable to get StartupTime instance."); + } if (startupTime != null) { return startupTime.getEpochMillis(); } else {