firebase / firebase/firebase-js-sdk

Firebase Auth keeps browser tabs active while in the background

Open
#4,724 3 comments 0 reactions 1 assignee Claimed by @sam-gc View on GitHub
api: auth feature request
Dominant language
TypeScript
Stars
5.1k
Forks
1k
Avg merge
2d 21h
Merged PRs (30d)
37

Description

### [REQUIRED] Describe your environment

* Operating System version: macOS Big Sur
* Browser version: Chrome 89, Safari 14.0.3
* Firebase SDK version: 8.2.7
* Firebase Product: Auth

### [REQUIRED] Describe the problem

Firebase auth wakes up a background tab every 10s or so even when there's no activity in the firebase tab (e.g. via realtime database or firestore). This shows up in Safari as having a constant power usage and prevents low-power states for that tab.

I imagine this is due to refreshing auth tokens, but it would be nice to bring the power usage and tab wake ups down to 0 if indeed there's no activity happening.

#### Steps to reproduce:

- Log in to a firebase app in chrome that isn't getting any updates from RTDB or Firestore
- Start the CPU profiler in devtools
- Leave the tab in the background and stop the profiler after a few minutes
- You should see something like this:
![image](https://user-images.githubusercontent.com/4172079/113517630-c6c54b00-9546-11eb-93fa-9e19427aede8.png)
- Most of these spikes are attributed to firebase auth
![image](https://user-images.githubusercontent.com/4172079/113517653-f83e1680-9546-11eb-832c-10d369f7f881.png)
- Login to the same firebase app in safari
- Open the devtools, and record a timeline that includes cpu usage
- It should look like this
![image](https://user-images.githubusercontent.com/4172079/113517781-bfeb0800-9547-11eb-929e-ea9d142222dc.png)

#### Relevant Code:

Any logged in firebase session.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.