Skip to content

Whole browser becomes lagging on 11.3.0 #8774

Closed
@apeiniger

Description

@apeiniger

Operating System

macOS Sequoia 15.2

Environment (if applicable)

Arc

Firebase SDK Version

11.3.0

Firebase SDK Product(s)

Firestore

Project Tooling

Vite

Detailed Problem Description

Since the update to 11.3.0 our app became very unresponsive and CPU intensive. A downgrade to 11.2.0 fixes the problem.

Steps and code to reproduce issue

Upgrade from 11.2.0 to 11.3.0

Activity

added
newA new issue that hasn't be categoirzed as question, bug or feature request
on Feb 7, 2025
google-oss-bot

google-oss-bot commented on Feb 7, 2025

@google-oss-bot
Contributor

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

added and removed
newA new issue that hasn't be categoirzed as question, bug or feature request
on Feb 7, 2025
dlarocque

dlarocque commented on Feb 7, 2025

@dlarocque
Contributor

Hi @apeiniger, thanks for reporting this issue. It's really helpful to know that this issue only occurs in 11.3.0. This may be related to #8691. Could you confirm whether your app reaches the code path compareUtf8Strings()? If not, please share what other products are used in your app.

Also, if possible, could you provide a minimal app that is affected by this performance issue?

apeiniger

apeiniger commented on Feb 8, 2025

@apeiniger
Author

Hi @apeiniger, thanks for reporting this issue. It's really helpful to know that this issue only occurs in 11.3.0. This may be related to #8691. Could you confirm whether your app reaches the code path compareUtf8Strings()? If not, please share what other products are used in your app.

Also, if possible, could you provide a minimal app that is affected by this performance issue?

@dlarocque What is the easiest way to find out if our app reaches the mentioned code path?

We mainly use Authentication and Firestore. On the Firestore side we have about 10 onSnapshot calls running in parallel, otherwise it's only standard Firestore calls.

self-assigned this
on Feb 10, 2025
milaGGL

milaGGL commented on Feb 10, 2025

@milaGGL
Contributor

Hi @apeiniger, we are quite confirmative that the performance issue is created by the utf-8 encoded string comparison. Before a patch is added, please downgrade to Version 11.2.0. Sorry for the inconvenience.

Besides, would you be willing to try out a special release when a fix is added? That would be very helpful.

apeiniger

apeiniger commented on Feb 11, 2025

@apeiniger
Author

@milaGGL Sure, happy to try out a special release once it's there. Just let me know.

lars-w-pedersen

lars-w-pedersen commented on Feb 11, 2025

@lars-w-pedersen

I have the same issue and can reproduce it with this code:

<!DOCTYPE html>
<html>
<head>
<script src="https://www.gstatic.com/firebasejs/11.3.0/firebase-app-compat.js"></script>
<script src="https://www.gstatic.com/firebasejs/11.3.0/firebase-firestore-compat.js"></script>
</head>
<body>

<script type="text/javascript">
const firebaseConfig = {...};

const app = firebase.initializeApp(firebaseConfig);
const db = firebase.firestore();

var i = 0;
//start timer
console.time("fetching data");
db.collection("users/1ODZLpoiftVBrNQ1piJwfdrc6GK2/experiments/mc1-1#2022-09-01T12:00:00.000Z/measurements").get().then((querySnapshot) => {
querySnapshot.forEach((doc) => {
i++;
});
console.log(i);
//end timer
console.timeEnd("fetching data");
});

</script>
</body>
</html>

"users/1ODZLpoiftVBrNQ1piJwfdrc6GK2/experiments/mc1-1#2022-09-01T12:00:00.000Z/measurements" is a subcollection with 1000 documents that has a timestamp as id, and 2 properties "p" and "t" both numbers.
using 11.3.0 it takes 7000ms to fetch them, using 11.2.0 it only takes 700ms

lars-w-pedersen

lars-w-pedersen commented on Feb 11, 2025

@lars-w-pedersen

11.3.1 does not have the issue, nice :)

dlarocque

dlarocque commented on Feb 11, 2025

@dlarocque
Contributor

11.3.1 does not have the issue, nice :)

Thanks for confirming! That was fast- I just released it 😅

Before closing this issue, @apeiniger could you confirm that this performance issue is gone after upgrading to 11.3.1?

apeiniger

apeiniger commented on Feb 12, 2025

@apeiniger
Author

@dlarocque Seems to be fixed for me as well. Thanks for the quick turnaround.

dlarocque

dlarocque commented on Feb 12, 2025

@dlarocque
Contributor

@dlarocque Seems to be fixed for me as well. Thanks for the quick turnaround.

That's great to hear! Thanks for confirming.

milaGGL

milaGGL commented on Feb 14, 2025

@milaGGL
Contributor

Hi @apeiniger , could you please help custom build and test this fix out? A lazy encoding is used instead of original "encode them all first" method. Hopefully, this should be able to do the UTF-8 encoded string comparison without dragging the performance down.

#  Clone the web SDK 
git clone https://github.com/firebase/firebase-js-sdk.git
cd firebase-js-sdk

# Checkout the modified branch and build
git checkout origin/mila/fix-string-utf8-comparison
npm install -g yarn
yarn
yarn build

# Create a .tgz file for Firestore
cd packages/firestore
yarn pack

# Cd to your project directory containing package.json and install the package
npm install <path_to_tgz_file_created_by_yarn_pack>
locked and limited conversation to collaborators on Mar 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @apeiniger@google-oss-bot@dlarocque@lars-w-pedersen@jbalidiong

      Issue actions

        Whole browser becomes lagging on 11.3.0 · Issue #8774 · firebase/firebase-js-sdk