Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whole browser becomes lagging on 11.3.0 #8774

Closed
apeiniger opened this issue Feb 7, 2025 · 11 comments
Closed

Whole browser becomes lagging on 11.3.0 #8774

apeiniger opened this issue Feb 7, 2025 · 11 comments

Comments

@apeiniger
Copy link

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

@apeiniger apeiniger added new A new issue that hasn't be categoirzed as question, bug or feature request question labels Feb 7, 2025
@google-oss-bot
Copy link
Contributor

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

@jbalidiong jbalidiong added api: firestore needs-attention and removed needs-triage new A new issue that hasn't be categoirzed as question, bug or feature request labels Feb 7, 2025
@dlarocque
Copy link
Contributor

dlarocque commented Feb 7, 2025

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
Copy link
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.

@milaGGL
Copy link
Contributor

milaGGL commented Feb 10, 2025

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
Copy link
Author

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

@lars-w-pedersen
Copy link

lars-w-pedersen commented Feb 11, 2025

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
Copy link

11.3.1 does not have the issue, nice :)

@dlarocque
Copy link
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
Copy link
Author

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

@dlarocque
Copy link
Contributor

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

That's great to hear! Thanks for confirming.

@milaGGL
Copy link
Contributor

milaGGL commented Feb 14, 2025

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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants