Skip to content

[Perf] Add networkInstrumentationEnabled opt-out flag (#8277)#16168

Open
JesusRojass wants to merge 5 commits into
firebase:mainfrom
JesusRojass:JesusRojass/#8277
Open

[Perf] Add networkInstrumentationEnabled opt-out flag (#8277)#16168
JesusRojass wants to merge 5 commits into
firebase:mainfrom
JesusRojass:JesusRojass/#8277

Conversation

@JesusRojass
Copy link
Copy Markdown
Collaborator

@JesusRojass JesusRojass commented May 11, 2026

Discussion

Fixes #8277

Adds an Info.plist array key, firebase_performance_swizzle_denylist, that lists class names to skip when registering swizzling instrumentors. Gives developers a way to opt out of swizzling for specific classes that surface leaks through third-party SDKs, without disabling the rest of Firebase Performance.

Usage

Add the key to your app's Info.plist. Each entry is the exact result of NSStringFromClass. To address the URLSession leak described in #8277, deny-list NSURLSession:

<key>firebase_performance_swizzle_denylist</key>
<array>
    <string>NSURLSession</string>
</array>

You can add as many entries as needed. The deny-list applies to any class the SDK tries to swizzle (URLSession, URLConnection, UIViewController, user-supplied delegate classes).

How it works

Enforced at the central swizzle chokepoint, FPRInstrument.registerClassInstrumentor:. If NSStringFromClass(instrumentedClass) is in the deny-list array, the method returns NO and the caller bails before any swizzle is installed. Three routes go through the chokepoint:

  • Static class registrations declared by each instrument in registerInstrumentors.
  • Subclass discovery at runtime (e.g. +sharedSession and +sessionWithConfiguration: discover __NSCFURLSession and friends).
  • User-supplied NSURLSessionDelegate classes registered by FPRNSURLSessionDelegateInstrument.

Strict NSStringFromClass equality, no subclass walk. Read fresh per registration call from Info.plist, no GULUserDefaults mirror, no runtime mutation API.

Testing

All existing tests pass. No new tests added: the deny-list runs at a single line in FPRInstrument.registerClassInstrumentor: and uses standard Info.plist array reading.

API Changes

  • No API Changes.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

@JesusRojass
Copy link
Copy Markdown
Collaborator Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a networkInstrumentationEnabled property to allow developers to opt-out of automatic URLSession and URLConnection instrumentation while keeping other performance monitoring features active. The setting can be configured via Info.plist, GULUserDefaults, or at runtime, with logic added to FPRConfigurations and FPRClient to handle the conditional registration of network instrumentation. Feedback was provided regarding the documentation style of the new method, suggesting it be made consistent with existing methods for better maintainability.

Comment thread FirebasePerformance/Sources/Configurations/FPRConfigurations.m Outdated
@JesusRojass
Copy link
Copy Markdown
Collaborator Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new opt-out mechanism for network instrumentation (URLSession/URLConnection) in the Firebase Performance SDK, configurable via Info.plist or at runtime. The review identified that the getter for the new property should reflect the active state of the SDK rather than just the pending configuration, and suggested simplifying the logic in the isNetworkInstrumentationEnabled method for better readability.

Comment thread FirebasePerformance/Sources/FIRPerformance.m Outdated
Comment thread FirebasePerformance/Sources/Configurations/FPRConfigurations.m Outdated
@JesusRojass
Copy link
Copy Markdown
Collaborator Author

/gemini review

@JesusRojass JesusRojass marked this pull request as ready for review May 11, 2026 21:14
@JesusRojass JesusRojass requested a review from a team as a code owner May 11, 2026 21:14
@JesusRojass JesusRojass requested a review from tejasd May 11, 2026 21:14
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a networkInstrumentationEnabled configuration option, allowing developers to selectively disable URLSession and URLConnection instrumentation via Info.plist or at runtime. The implementation includes new properties in FPRConfigurations and FPRClient, along with public API updates in FIRPerformance. Review feedback suggests resetting the networkInstrumentationSwizzled flag within disableInstrumentation to ensure consistency during testing and recommends using a more generic error code when settings are modified after the SDK has been configured.

Comment thread FirebasePerformance/Sources/FPRClient.m Outdated
Comment thread FirebasePerformance/Sources/FIRPerformance.m Outdated
@JesusRojass JesusRojass self-assigned this May 11, 2026
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.

Memory leaks inside FirebasePerformance InstrumentSessionWithConfiguration

1 participant