Skip to content

Update Fireperf logging to use sendBeacon only if the payload is under the 64KB limit #9120

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

raymondlam
Copy link
Member

@raymondlam raymondlam commented Jun 25, 2025

Addresses issue #9067
From this comment, Edge and Firefox enforce a 64KB limit per beacon. Chrome enforces a 64KB quota across all beacon-initiated requests within same nav context.

Since Chrome enforces a limit across all beacon requests, we'll attempt to use sendBeacon with a low number of events incase sendBeacon is also used by other libraries.

…r the 64KB limit for most browsers.

- For the flush, attempt to use sendBeacon with a low number of events incase sendBeacon is also used by other libraries.
@raymondlam raymondlam requested review from visumickey and a team as code owners June 25, 2025 07:21
Copy link

changeset-bot bot commented Jun 25, 2025

🦋 Changeset detected

Latest commit: 74db5f8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@firebase/performance Patch
firebase Patch
@firebase/performance-compat Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@raymondlam raymondlam requested a review from bryanatkinson June 25, 2025 07:21
@raymondlam raymondlam requested review from a team as code owners June 25, 2025 07:29
Copy link
Contributor

github-actions bot commented Jun 25, 2025

Changeset File Check ✅

  • No modified packages are missing from the changeset file.
  • No changeset formatting errors detected.

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Jun 25, 2025

Size Report 1

Affected Products

  • @firebase/performance

    TypeBase (86155b3)Merge (4a680d1)Diff
    browser30.6 kB31.3 kB+681 B (+2.2%)
    main31.0 kB31.7 kB+681 B (+2.2%)
    module30.6 kB31.3 kB+681 B (+2.2%)
  • bundle

    TypeBase (86155b3)Merge (4a680d1)Diff
    performance (trace)62.4 kB62.8 kB+400 B (+0.6%)
  • firebase

    TypeBase (86155b3)Merge (4a680d1)Diff
    firebase-compat.js807 kB807 kB+328 B (+0.0%)
    firebase-performance-compat.js40.0 kB40.3 kB+321 B (+0.8%)
    firebase-performance-standalone-compat.js105 kB105 kB+341 B (+0.3%)
    firebase-performance.js45.5 kB45.8 kB+363 B (+0.8%)

Test Logs

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

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Jun 25, 2025

Size Analysis Report 1

Affected Products

  • @firebase/performance

    • getPerformance

      Size

      TypeBase (86155b3)Merge (4a680d1)Diff
      size18.9 kB19.3 kB+398 B (+2.1%)
      size-with-ext-deps62.3 kB62.7 kB+400 B (+0.6%)

      Dependency

      TypeBase (86155b3)Merge (4a680d1)Diff
      functions

      52 dependencies

      addToQueue
      changeInitializationStatus
      configValid
      convertMetricValueToInteger
      createNetworkRequestEntry
      createUserTimingTrace
      dispatchQueueEvents
      flushLogs
      flushQueuedEvents
      getApiKey
      getAppId
      getApplicationInfo
      getAuthTokenPromise
      getConfig
      getDocumentReadyComplete
      getEffectiveConnectionType
      getIid
      getIidPromise
      getInitializationPromise
      getPerformance
      getProjectId
      getRemoteConfig
      getServiceWorkerStatus
      getStoredConfig
      getVisibilityState
      initializePerf
      isPerfInitialized
      isValidCustomAttributeName
      isValidCustomAttributeValue
      isValidMetricName
      logNetworkRequest
      logTrace
      mergeStrings
      postToFlEndpoint
      processConfig
      processQueue
      registerPerformance
      sendLog
      sendOobTrace
      sendTraceLog
      serializeNetworkRequest
      serializeTrace
      serializer
      setupApi
      setupNetworkRequests
      setupOobResources
      setupOobTraces
      setupTransportService
      setupUserTimingTraces
      shouldLogAfterSampling
      storeConfig
      transportHandler

      53 dependencies

      addToQueue
      buildPayload
      changeInitializationStatus
      configValid
      convertMetricValueToInteger
      createNetworkRequestEntry
      createUserTimingTrace
      dispatchQueueEvents
      flushLogs
      flushQueuedEvents
      getApiKey
      getAppId
      getApplicationInfo
      getAuthTokenPromise
      getConfig
      getDocumentReadyComplete
      getEffectiveConnectionType
      getIid
      getIidPromise
      getInitializationPromise
      getPerformance
      getProjectId
      getRemoteConfig
      getServiceWorkerStatus
      getStoredConfig
      getVisibilityState
      initializePerf
      isPerfInitialized
      isValidCustomAttributeName
      isValidCustomAttributeValue
      isValidMetricName
      logNetworkRequest
      logTrace
      mergeStrings
      postToFlEndpoint
      processConfig
      processQueue
      registerPerformance
      sendLog
      sendOobTrace
      sendTraceLog
      serializeNetworkRequest
      serializeTrace
      serializer
      setupApi
      setupNetworkRequests
      setupOobResources
      setupOobTraces
      setupTransportService
      setupUserTimingTraces
      shouldLogAfterSampling
      storeConfig
      transportHandler

      + buildPayload

      variables

      54 dependencies

      ATTRIBUTE_FORMAT_REGEX
      CONFIG_EXPIRY_LOCAL_STORAGE_KEY
      CONFIG_LOCAL_STORAGE_KEY
      COULD_NOT_GET_CONFIG_MSG
      CUMULATIVE_LAYOUT_SHIFT_ATTRIBUTE_NAME
      CUMULATIVE_LAYOUT_SHIFT_METRIC_NAME
      DEFAULT_CONFIGS
      DEFAULT_ENTRY_NAME
      DEFAULT_REMAINING_TRIES
      DEFAULT_SEND_INTERVAL_MS
      ERROR_DESCRIPTION_MAP
      ERROR_FACTORY
      FIRST_CONTENTFUL_PAINT_COUNTER_NAME
      FIRST_INPUT_DELAY_COUNTER_NAME
      FIRST_PAINT_COUNTER_NAME
      FIS_AUTH_PREFIX
      INITIAL_SEND_TIME_DELAY_MS
      INTERACTION_TO_NEXT_PAINT_ATTRIBUTE_NAME
      INTERACTION_TO_NEXT_PAINT_METRIC_NAME
      LARGEST_CONTENTFUL_PAINT_ATTRIBUTE_NAME
      LARGEST_CONTENTFUL_PAINT_METRIC_NAME
      MAX_ATTRIBUTE_NAME_LENGTH
      MAX_ATTRIBUTE_VALUE_LENGTH
      MAX_EVENT_COUNT_PER_REQUEST
      MAX_METRIC_NAME_LENGTH
      OOB_TRACE_PAGE_LOAD_PREFIX
      REMOTE_CONFIG_SDK_VERSION
      RESERVED_ATTRIBUTE_PREFIXES
      RESERVED_AUTO_PREFIX
      SDK_VERSION
      SERVICE
      SERVICE_NAME
      TRACE_MEASURE_PREFIX
      TRACE_START_MARK_PREFIX
      TRACE_STOP_MARK_PREFIX
      VisibilityState
      apiInstance
      consoleLogger
      factory
      firstInputDelay
      iid
      initializationPromise
      initializationStatus
      isTransportSetup
      logger
      name
      oobMetrics
      queue
      remainingTries
      sentPageLoadTrace
      settingsServiceInstance
      version
      webVitalMetrics
      windowInstance

      57 dependencies

      ATTRIBUTE_FORMAT_REGEX
      CONFIG_EXPIRY_LOCAL_STORAGE_KEY
      CONFIG_LOCAL_STORAGE_KEY
      COULD_NOT_GET_CONFIG_MSG
      CUMULATIVE_LAYOUT_SHIFT_ATTRIBUTE_NAME
      CUMULATIVE_LAYOUT_SHIFT_METRIC_NAME
      DEFAULT_CONFIGS
      DEFAULT_ENTRY_NAME
      DEFAULT_REMAINING_TRIES
      DEFAULT_SEND_INTERVAL_MS
      ERROR_DESCRIPTION_MAP
      ERROR_FACTORY
      FIRST_CONTENTFUL_PAINT_COUNTER_NAME
      FIRST_INPUT_DELAY_COUNTER_NAME
      FIRST_PAINT_COUNTER_NAME
      FIS_AUTH_PREFIX
      INITIAL_SEND_TIME_DELAY_MS
      INTERACTION_TO_NEXT_PAINT_ATTRIBUTE_NAME
      INTERACTION_TO_NEXT_PAINT_METRIC_NAME
      LARGEST_CONTENTFUL_PAINT_ATTRIBUTE_NAME
      LARGEST_CONTENTFUL_PAINT_METRIC_NAME
      MAX_ATTRIBUTE_NAME_LENGTH
      MAX_ATTRIBUTE_VALUE_LENGTH
      MAX_EVENT_COUNT_PER_REQUEST
      MAX_FLUSH_SIZE
      MAX_METRIC_NAME_LENGTH
      MAX_SEND_BEACON_PAYLOAD_SIZE
      OOB_TRACE_PAGE_LOAD_PREFIX
      REMOTE_CONFIG_SDK_VERSION
      RESERVED_ATTRIBUTE_PREFIXES
      RESERVED_AUTO_PREFIX
      SDK_VERSION
      SERVICE
      SERVICE_NAME
      TEXT_ENCODER
      TRACE_MEASURE_PREFIX
      TRACE_START_MARK_PREFIX
      TRACE_STOP_MARK_PREFIX
      VisibilityState
      apiInstance
      consoleLogger
      factory
      firstInputDelay
      iid
      initializationPromise
      initializationStatus
      isTransportSetup
      logger
      name
      oobMetrics
      queue
      remainingTries
      sentPageLoadTrace
      settingsServiceInstance
      version
      webVitalMetrics
      windowInstance

      + MAX_FLUSH_SIZE
      + MAX_SEND_BEACON_PAYLOAD_SIZE
      + TEXT_ENCODER

    • initializePerformance

      Size

      TypeBase (86155b3)Merge (4a680d1)Diff
      size19.0 kB19.4 kB+398 B (+2.1%)
      size-with-ext-deps55.6 kB56.0 kB+400 B (+0.7%)

      Dependency

      TypeBase (86155b3)Merge (4a680d1)Diff
      functions

      52 dependencies

      addToQueue
      changeInitializationStatus
      configValid
      convertMetricValueToInteger
      createNetworkRequestEntry
      createUserTimingTrace
      dispatchQueueEvents
      flushLogs
      flushQueuedEvents
      getApiKey
      getAppId
      getApplicationInfo
      getAuthTokenPromise
      getConfig
      getDocumentReadyComplete
      getEffectiveConnectionType
      getIid
      getIidPromise
      getInitializationPromise
      getProjectId
      getRemoteConfig
      getServiceWorkerStatus
      getStoredConfig
      getVisibilityState
      initializePerf
      initializePerformance
      isPerfInitialized
      isValidCustomAttributeName
      isValidCustomAttributeValue
      isValidMetricName
      logNetworkRequest
      logTrace
      mergeStrings
      postToFlEndpoint
      processConfig
      processQueue
      registerPerformance
      sendLog
      sendOobTrace
      sendTraceLog
      serializeNetworkRequest
      serializeTrace
      serializer
      setupApi
      setupNetworkRequests
      setupOobResources
      setupOobTraces
      setupTransportService
      setupUserTimingTraces
      shouldLogAfterSampling
      storeConfig
      transportHandler

      53 dependencies

      addToQueue
      buildPayload
      changeInitializationStatus
      configValid
      convertMetricValueToInteger
      createNetworkRequestEntry
      createUserTimingTrace
      dispatchQueueEvents
      flushLogs
      flushQueuedEvents
      getApiKey
      getAppId
      getApplicationInfo
      getAuthTokenPromise
      getConfig
      getDocumentReadyComplete
      getEffectiveConnectionType
      getIid
      getIidPromise
      getInitializationPromise
      getProjectId
      getRemoteConfig
      getServiceWorkerStatus
      getStoredConfig
      getVisibilityState
      initializePerf
      initializePerformance
      isPerfInitialized
      isValidCustomAttributeName
      isValidCustomAttributeValue
      isValidMetricName
      logNetworkRequest
      logTrace
      mergeStrings
      postToFlEndpoint
      processConfig
      processQueue
      registerPerformance
      sendLog
      sendOobTrace
      sendTraceLog
      serializeNetworkRequest
      serializeTrace
      serializer
      setupApi
      setupNetworkRequests
      setupOobResources
      setupOobTraces
      setupTransportService
      setupUserTimingTraces
      shouldLogAfterSampling
      storeConfig
      transportHandler

      + buildPayload

      variables

      54 dependencies

      ATTRIBUTE_FORMAT_REGEX
      CONFIG_EXPIRY_LOCAL_STORAGE_KEY
      CONFIG_LOCAL_STORAGE_KEY
      COULD_NOT_GET_CONFIG_MSG
      CUMULATIVE_LAYOUT_SHIFT_ATTRIBUTE_NAME
      CUMULATIVE_LAYOUT_SHIFT_METRIC_NAME
      DEFAULT_CONFIGS
      DEFAULT_ENTRY_NAME
      DEFAULT_REMAINING_TRIES
      DEFAULT_SEND_INTERVAL_MS
      ERROR_DESCRIPTION_MAP
      ERROR_FACTORY
      FIRST_CONTENTFUL_PAINT_COUNTER_NAME
      FIRST_INPUT_DELAY_COUNTER_NAME
      FIRST_PAINT_COUNTER_NAME
      FIS_AUTH_PREFIX
      INITIAL_SEND_TIME_DELAY_MS
      INTERACTION_TO_NEXT_PAINT_ATTRIBUTE_NAME
      INTERACTION_TO_NEXT_PAINT_METRIC_NAME
      LARGEST_CONTENTFUL_PAINT_ATTRIBUTE_NAME
      LARGEST_CONTENTFUL_PAINT_METRIC_NAME
      MAX_ATTRIBUTE_NAME_LENGTH
      MAX_ATTRIBUTE_VALUE_LENGTH
      MAX_EVENT_COUNT_PER_REQUEST
      MAX_METRIC_NAME_LENGTH
      OOB_TRACE_PAGE_LOAD_PREFIX
      REMOTE_CONFIG_SDK_VERSION
      RESERVED_ATTRIBUTE_PREFIXES
      RESERVED_AUTO_PREFIX
      SDK_VERSION
      SERVICE
      SERVICE_NAME
      TRACE_MEASURE_PREFIX
      TRACE_START_MARK_PREFIX
      TRACE_STOP_MARK_PREFIX
      VisibilityState
      apiInstance
      consoleLogger
      factory
      firstInputDelay
      iid
      initializationPromise
      initializationStatus
      isTransportSetup
      logger
      name
      oobMetrics
      queue
      remainingTries
      sentPageLoadTrace
      settingsServiceInstance
      version
      webVitalMetrics
      windowInstance

      57 dependencies

      ATTRIBUTE_FORMAT_REGEX
      CONFIG_EXPIRY_LOCAL_STORAGE_KEY
      CONFIG_LOCAL_STORAGE_KEY
      COULD_NOT_GET_CONFIG_MSG
      CUMULATIVE_LAYOUT_SHIFT_ATTRIBUTE_NAME
      CUMULATIVE_LAYOUT_SHIFT_METRIC_NAME
      DEFAULT_CONFIGS
      DEFAULT_ENTRY_NAME
      DEFAULT_REMAINING_TRIES
      DEFAULT_SEND_INTERVAL_MS
      ERROR_DESCRIPTION_MAP
      ERROR_FACTORY
      FIRST_CONTENTFUL_PAINT_COUNTER_NAME
      FIRST_INPUT_DELAY_COUNTER_NAME
      FIRST_PAINT_COUNTER_NAME
      FIS_AUTH_PREFIX
      INITIAL_SEND_TIME_DELAY_MS
      INTERACTION_TO_NEXT_PAINT_ATTRIBUTE_NAME
      INTERACTION_TO_NEXT_PAINT_METRIC_NAME
      LARGEST_CONTENTFUL_PAINT_ATTRIBUTE_NAME
      LARGEST_CONTENTFUL_PAINT_METRIC_NAME
      MAX_ATTRIBUTE_NAME_LENGTH
      MAX_ATTRIBUTE_VALUE_LENGTH
      MAX_EVENT_COUNT_PER_REQUEST
      MAX_FLUSH_SIZE
      MAX_METRIC_NAME_LENGTH
      MAX_SEND_BEACON_PAYLOAD_SIZE
      OOB_TRACE_PAGE_LOAD_PREFIX
      REMOTE_CONFIG_SDK_VERSION
      RESERVED_ATTRIBUTE_PREFIXES
      RESERVED_AUTO_PREFIX
      SDK_VERSION
      SERVICE
      SERVICE_NAME
      TEXT_ENCODER
      TRACE_MEASURE_PREFIX
      TRACE_START_MARK_PREFIX
      TRACE_STOP_MARK_PREFIX
      VisibilityState
      apiInstance
      consoleLogger
      factory
      firstInputDelay
      iid
      initializationPromise
      initializationStatus
      isTransportSetup
      logger
      name
      oobMetrics
      queue
      remainingTries
      sentPageLoadTrace
      settingsServiceInstance
      version
      webVitalMetrics
      windowInstance

      + MAX_FLUSH_SIZE
      + MAX_SEND_BEACON_PAYLOAD_SIZE
      + TEXT_ENCODER

    • trace

      Size

      TypeBase (86155b3)Merge (4a680d1)Diff
      size18.8 kB19.2 kB+398 B (+2.1%)
      size-with-ext-deps55.0 kB55.4 kB+400 B (+0.7%)

      Dependency

      TypeBase (86155b3)Merge (4a680d1)Diff
      functions

      52 dependencies

      addToQueue
      changeInitializationStatus
      configValid
      convertMetricValueToInteger
      createNetworkRequestEntry
      createUserTimingTrace
      dispatchQueueEvents
      flushLogs
      flushQueuedEvents
      getApiKey
      getAppId
      getApplicationInfo
      getAuthTokenPromise
      getConfig
      getDocumentReadyComplete
      getEffectiveConnectionType
      getIid
      getIidPromise
      getInitializationPromise
      getProjectId
      getRemoteConfig
      getServiceWorkerStatus
      getStoredConfig
      getVisibilityState
      initializePerf
      isPerfInitialized
      isValidCustomAttributeName
      isValidCustomAttributeValue
      isValidMetricName
      logNetworkRequest
      logTrace
      mergeStrings
      postToFlEndpoint
      processConfig
      processQueue
      registerPerformance
      sendLog
      sendOobTrace
      sendTraceLog
      serializeNetworkRequest
      serializeTrace
      serializer
      setupApi
      setupNetworkRequests
      setupOobResources
      setupOobTraces
      setupTransportService
      setupUserTimingTraces
      shouldLogAfterSampling
      storeConfig
      trace
      transportHandler

      53 dependencies

      addToQueue
      buildPayload
      changeInitializationStatus
      configValid
      convertMetricValueToInteger
      createNetworkRequestEntry
      createUserTimingTrace
      dispatchQueueEvents
      flushLogs
      flushQueuedEvents
      getApiKey
      getAppId
      getApplicationInfo
      getAuthTokenPromise
      getConfig
      getDocumentReadyComplete
      getEffectiveConnectionType
      getIid
      getIidPromise
      getInitializationPromise
      getProjectId
      getRemoteConfig
      getServiceWorkerStatus
      getStoredConfig
      getVisibilityState
      initializePerf
      isPerfInitialized
      isValidCustomAttributeName
      isValidCustomAttributeValue
      isValidMetricName
      logNetworkRequest
      logTrace
      mergeStrings
      postToFlEndpoint
      processConfig
      processQueue
      registerPerformance
      sendLog
      sendOobTrace
      sendTraceLog
      serializeNetworkRequest
      serializeTrace
      serializer
      setupApi
      setupNetworkRequests
      setupOobResources
      setupOobTraces
      setupTransportService
      setupUserTimingTraces
      shouldLogAfterSampling
      storeConfig
      trace
      transportHandler

      + buildPayload

      variables

      54 dependencies

      ATTRIBUTE_FORMAT_REGEX
      CONFIG_EXPIRY_LOCAL_STORAGE_KEY
      CONFIG_LOCAL_STORAGE_KEY
      COULD_NOT_GET_CONFIG_MSG
      CUMULATIVE_LAYOUT_SHIFT_ATTRIBUTE_NAME
      CUMULATIVE_LAYOUT_SHIFT_METRIC_NAME
      DEFAULT_CONFIGS
      DEFAULT_ENTRY_NAME
      DEFAULT_REMAINING_TRIES
      DEFAULT_SEND_INTERVAL_MS
      ERROR_DESCRIPTION_MAP
      ERROR_FACTORY
      FIRST_CONTENTFUL_PAINT_COUNTER_NAME
      FIRST_INPUT_DELAY_COUNTER_NAME
      FIRST_PAINT_COUNTER_NAME
      FIS_AUTH_PREFIX
      INITIAL_SEND_TIME_DELAY_MS
      INTERACTION_TO_NEXT_PAINT_ATTRIBUTE_NAME
      INTERACTION_TO_NEXT_PAINT_METRIC_NAME
      LARGEST_CONTENTFUL_PAINT_ATTRIBUTE_NAME
      LARGEST_CONTENTFUL_PAINT_METRIC_NAME
      MAX_ATTRIBUTE_NAME_LENGTH
      MAX_ATTRIBUTE_VALUE_LENGTH
      MAX_EVENT_COUNT_PER_REQUEST
      MAX_METRIC_NAME_LENGTH
      OOB_TRACE_PAGE_LOAD_PREFIX
      REMOTE_CONFIG_SDK_VERSION
      RESERVED_ATTRIBUTE_PREFIXES
      RESERVED_AUTO_PREFIX
      SDK_VERSION
      SERVICE
      SERVICE_NAME
      TRACE_MEASURE_PREFIX
      TRACE_START_MARK_PREFIX
      TRACE_STOP_MARK_PREFIX
      VisibilityState
      apiInstance
      consoleLogger
      factory
      firstInputDelay
      iid
      initializationPromise
      initializationStatus
      isTransportSetup
      logger
      name
      oobMetrics
      queue
      remainingTries
      sentPageLoadTrace
      settingsServiceInstance
      version
      webVitalMetrics
      windowInstance

      57 dependencies

      ATTRIBUTE_FORMAT_REGEX
      CONFIG_EXPIRY_LOCAL_STORAGE_KEY
      CONFIG_LOCAL_STORAGE_KEY
      COULD_NOT_GET_CONFIG_MSG
      CUMULATIVE_LAYOUT_SHIFT_ATTRIBUTE_NAME
      CUMULATIVE_LAYOUT_SHIFT_METRIC_NAME
      DEFAULT_CONFIGS
      DEFAULT_ENTRY_NAME
      DEFAULT_REMAINING_TRIES
      DEFAULT_SEND_INTERVAL_MS
      ERROR_DESCRIPTION_MAP
      ERROR_FACTORY
      FIRST_CONTENTFUL_PAINT_COUNTER_NAME
      FIRST_INPUT_DELAY_COUNTER_NAME
      FIRST_PAINT_COUNTER_NAME
      FIS_AUTH_PREFIX
      INITIAL_SEND_TIME_DELAY_MS
      INTERACTION_TO_NEXT_PAINT_ATTRIBUTE_NAME
      INTERACTION_TO_NEXT_PAINT_METRIC_NAME
      LARGEST_CONTENTFUL_PAINT_ATTRIBUTE_NAME
      LARGEST_CONTENTFUL_PAINT_METRIC_NAME
      MAX_ATTRIBUTE_NAME_LENGTH
      MAX_ATTRIBUTE_VALUE_LENGTH
      MAX_EVENT_COUNT_PER_REQUEST
      MAX_FLUSH_SIZE
      MAX_METRIC_NAME_LENGTH
      MAX_SEND_BEACON_PAYLOAD_SIZE
      OOB_TRACE_PAGE_LOAD_PREFIX
      REMOTE_CONFIG_SDK_VERSION
      RESERVED_ATTRIBUTE_PREFIXES
      RESERVED_AUTO_PREFIX
      SDK_VERSION
      SERVICE
      SERVICE_NAME
      TEXT_ENCODER
      TRACE_MEASURE_PREFIX
      TRACE_START_MARK_PREFIX
      TRACE_STOP_MARK_PREFIX
      VisibilityState
      apiInstance
      consoleLogger
      factory
      firstInputDelay
      iid
      initializationPromise
      initializationStatus
      isTransportSetup
      logger
      name
      oobMetrics
      queue
      remainingTries
      sentPageLoadTrace
      settingsServiceInstance
      version
      webVitalMetrics
      windowInstance

      + MAX_FLUSH_SIZE
      + MAX_SEND_BEACON_PAYLOAD_SIZE
      + TEXT_ENCODER

Test Logs

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

@raymondlam raymondlam changed the title Update Fireperf logging to use sendBeacon only if the payload is under the 64KB limit #9067 Update Fireperf logging to use sendBeacon only if the payload is under the 64KB limit Jun 25, 2025
@raymondlam raymondlam force-pushed the raymondlam/perffix branch from 6f57725 to 74db5f8 Compare June 25, 2025 22:18
@@ -88,7 +89,7 @@ describe('Firebase Performance > transport_service', () => {
expect(fetchStub).to.not.have.been.called;
});

it('sends up to the maximum event limit in one request', async () => {
it('sends up to the maximum event limit in one request if payload is under 64 KB', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

How are we ensuring that the payload is less than 64KB in this test? Is this based on the size of the events?

})
);

const payload = 'a'.repeat(300);
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a nit pick. Is there a way we cna turn the payload to be a factor of may be 512B so that we dispatch 128+ events to achieve the 64KB+ situation? That way it would be easier to understad what is happening in the test. Currently, it is cryptic.

const MAX_SEND_BEACON_PAYLOAD_SIZE = 65536;
// The max number of events to send during a flush. This number is kept low to since Chrome has a
// shared payload limit for all sendBeacon calls in the same nav context.
const MAX_FLUSH_SIZE = 40;
Copy link
Contributor

Choose a reason for hiding this comment

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

How did we arrive at this 40? Is this heuristic driven or are we making it as a random pick. If a random pick, should we make it Remote COnfig configurable with default value of 40?

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

Successfully merging this pull request may close these issues.

3 participants