Repository navigation
App Check (Desktop): register function registry calls on every App - #1985
Open
AustinBenoit wants to merge 4 commits into
Open
AustinBenoit wants to merge 4 commits into
AustinBenoit wants to merge 4 commits into
Conversation
AppCheckInternal used a process-wide counter to register its function registry entries only when the first instance was created and to unregister them only when the last one was destroyed. Each App has its own function registry, so a second App never got the entries: Auth, Database, Firestore, Functions and Storage on that App looked up FnAppCheckGetTokenAsync, found nothing, and sent their requests without an App Check token. Teardown had the mirror-image problem and unregistered from whichever App happened to bring the counter to zero. The registered callbacks already find the AppCheck instance from the App they are given, so drop the counter and register and unregister on each instance's own App. Fixes #1970
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the desktop App Check implementation to register its functions on every App instance's registry rather than using a global count, fixing an issue where secondary App instances failed to send App Check tokens. It also adds a new desktop test suite to verify this behavior. The feedback recommends adding defensive null checks for app_ in both InitRegistryCalls and CleanupRegistryCalls to prevent potential null pointer dereferences. Additionally, it points out an existing bug in FunctionRegistry::UnregisterFunction where a range-erase with identical iterators results in a silent no-op.
… against null app_
…r-per-app # Conflicts: # release_build_files/readme.md
AustinBenoit
marked this pull request as ready for review
November 25, 2026 03:41
…registration - Resolve release_build_files/readme.md conflict against origin/main. - Add DestroyingAppCheckUnregistersOnlyItsAppsRegistryFunctions verifying that destroying one AppCheck unregisters all 4 FnAppCheck* entries only on its own App without recreating AppCheck, leaves other Apps intact, and re-registers cleanly when recreated.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
On desktop, App Check registered its function registry entries only for the first
Appcreated, using a process-wide counter. EachApphas its own registry, so Auth, Database, Firestore, Functions and Storage on any otherAppfound nothing and sent requests without an App Check token.This removes the counter and registers and unregisters on each instance's own
App.Testing
New
app_check/tests/desktop/app_check_desktop_test.cc, with two Apps:Both fail without the fix. Built and run on Linux (GCC, Firestore excluded).
Type of Change
Fixes #1970