firebase / firebase/firebase-cpp-sdk

[Bug] High CPU utilisation after authentication when running in sandbox on desktop (macOS)

Abierto
#1,045 19 comentarios 8 reacciones 0 asignados Ver en GitHub
api: auth type: bug
Lenguaje dominante
C++
Estrellas
326
Forks
137
Merge medio
3 d 9 h
PR fusionados (30 d)
5

Descripción

### [REQUIRED] Please fill in the following fields:

* Pre-built SDK from the [website](https://firebase.google.com/download/cpp) or open-source from this repo: Pre-built
* Firebase C++ SDK version: 9.3
* Problematic Firebase Component: Auth (Auth, Database, etc.)
* Other Firebase Components in use: Firestore (Auth, Database, etc.)
* Platform you are using the C++ SDK on: Mac ARM64 & x86 (Mac, Windows, or Linux)
* Platform you are targeting: Desktop (iOS, Android, and/or desktop)

### [REQUIRED] Please describe the issue here:

When running the Firebase C++ SDK in a sandboxed app on macOS 12.5, high CPU utilisation is observed after authentication succeeds. Without sandboxing enabled, the issue does not occur.

#### Steps to reproduce:

Follow these steps to set up a test project that reproduces the issue. Or use the attached test project below.

1. Include Firebase Auth in a C++ or Objective-C++ class and implement an email + password authentication step.
2. Create an Xcode project with the template macOS → Application → App (Interface XIB, in order to select language Objective-C). Add your C++/Objective-C++ class to this project and the app target.
3. Under project → targets → $appname, add firebase_auth.framework (from fb_cpp_sdk/frameworks/darwin/universal/ in the pre-built C++ SDK folder) to the section "Frameworks, Libraries and Embedded Content", with the option Embed & Sign selected. Also add the other macOS dependencies here (CoreFoundation, Foundation, GSS, Kerberos, libpthread, Security and SystemConfiguration. Keep the standard value for embedding, Do not Embed).
5. Check that the frameworks in fb_cpp_sdk/frameworks/darwin/universal/ either contain all headers (four header files are missing from the v9.3 download in fb_cpp_sdk/frameworks/darwin/universal/firebase.framework/Headers/) or manually add the project header search path for fb_cpp_sdk/include/.
6. The project template contains the file $appname.entitlements. Make sure that the value for key "Sandboxing enabled" in this property list file is set to YES, in order to create a sandboxed app. Additionally, set both the com.apple.security.network.client and server values to YES, in order to allow network access.
7. Build the app and run it, then sign in using email + password.
8. As soon as the authentication succeeds, four Firebase worker threads keep running at full CPU utilisation. This can be checked in the debug navigator of Xcode when selecting CPU (displays about 400% usage continuously).

Expected outcome: The worker threads should use minimal CPU resources and sleep whenever possible.

8. (Optionally) Go back to the entitlements file and set "Sandboxing enabled" to NO, in order to deactivate sandboxing. The issue should no longer occur after clean build products and rebuild in Xcode, when running the app again and signing in.

Have you been able to reproduce this issue with just the [Firebase C++ quickstarts](https://github.com/firebase/quickstart-cpp) ?
What's the issue repro rate? (eg 100%, 1/5 etc)

Yes, happens with any sandboxed Mac app build (100%).

What happened? How can we make the problem occur?
This could be a description, log/console output, etc.

As soon as the authentication succeeds, four Firebase worker keep running at full CPU utilisation.
This is mostly due to `firebase::scheduler::Scheduler::WorkerThreadRoutine`. This can be verified using Instruments, when sampling the running app.

Expected outcome: The worker threads should use minimal CPU resources and sleep whenever possible.

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comienza en firebase::scheduler::Scheduler::WorkerThreadRoutine y reproduce el problema en una aplicación macOS Xcode en sandbox mediante autenticación con email/contraseña. Compara las muestras de CPU de Instruments con el sandbox habilitado y deshabilitado; el trabajo estará terminado cuando los cuatro hilos de trabajo de Firebase vuelvan a un uso mínimo de CPU después de la autenticación en el build con sandbox.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
cpp, macos
Área
authentication, desktop
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.