pubnub / js-chat

PubNub JavaScript Chat SDK
https://github.com/pubnub/js-chat
8 stars 9 forks source link

100%+ CPU \ Safari Version 17.5 (19618.2.12.11.6) ? #175

Closed WalrusSoup closed 3 months ago

WalrusSoup commented 3 months ago

We've been running into an issue where a simple pubnub chat causes Safari to eat up 90% CPU when any channels have been joined. I've isolated it to opening a connection to channels. As soon as I call connect, it will have this issue after refreshing. It wont happen every refresh, but it happens most of the time.

Safari Version: Version 17.5 (19618.2.12.11.6)

Prior to refreshing, a lot of errors pop up in the console (~10 times): Fetch API cannot load [x] due to access control checks.

Give it a few refreshes & Safari Web Content process will be suddenly be stuck at around 90% CPU permanently.

Screenshot 2024-08-01 at 2 35 51 PM

This occurs even in a simple boilerplate page with nothing on it. This is from a vanilla vite project compilation, with an empty page:

Chat.init({
  publishKey: import.meta.env.VITE_PUBNUB_PUB_KEY,
  subscribeKey: import.meta.env.VITE_PUBNUB_SUB_KEY,
  userId: "1111111",
  storeUserActivityTimestamps: true,
  }).then((chat) => {
  const channel = await chat.getChannel("50")
  // connect or join
  channel.join((msg) => {
    console.log(msg);
  });
});

I've opened this here because I do not see this issue on the Debug Console of the website, and i do not see the errors Fetch API cannot load [x] due to access control checks. when reloading either.

Video because I think I'm going crazy trying to figure this out all day.

https://github.com/user-attachments/assets/16a1a76b-44b7-482c-ae3b-8791cde047e8

WalrusSoup commented 3 months ago

Going to migrate this to the main repo as it can be sort of mediated if you force disconnect before navigation events.