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

打开设置页面卡顿[Bug] #2516

Closed
BruceLee569 opened this issue May 15, 2024 · 62 comments · Fixed by #2640
Closed

打开设置页面卡顿[Bug] #2516

BruceLee569 opened this issue May 15, 2024 · 62 comments · Fixed by #2640
Labels
🐛 Bug Something isn't working | 缺陷

Comments

@BruceLee569
Copy link

💻 系统环境

Windows

📦 部署环境

Official Preview

🌐 浏览器

Chrome

🐛 问题描述

每次打开设置都会向服务器发送请求,导致设置页面显示卡顿,没请求必要时能否先显示?

🚦 期望结果

No response

📷 复现步骤

No response

📝 补充信息

No response

@BruceLee569 BruceLee569 added the 🐛 Bug Something isn't working | 缺陷 label May 15, 2024
@Cp0204
Copy link

Cp0204 commented May 16, 2024

不只是设置页,整个lobe都卡卡的,切换对话,卡片的时候,经常要刷新页面。

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Not only the settings page, but also the entire Lebo is stuck. When switching conversations or cards, I often have to refresh the page.

@arvinxx
Copy link
Contributor

arvinxx commented May 16, 2024

@Cp0204 你确定最新版本还有这个问题吗

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@Cp0204 Are you sure the latest version still has this problem?

@BruceLee569
Copy link
Author

@Cp0204 你确定最新版本还有这个问题吗

用的是最新版本,每次打开设置页和子设置项时,都会往 api/market 发送GET请求,导致进入页面卡顿。
image

@Cp0204
Copy link

Cp0204 commented May 16, 2024

@Cp0204 你确定最新版本还有这个问题吗

是的,最新版。lobe请求资源太频繁,首次打开,就有200+个请求,切换对话,也会请求,部署在远程的体验很不好。

image

@Cp0204
Copy link

Cp0204 commented May 16, 2024

image

每切换对话都会请求这些资源,其实不必要的。


不知道作者是不是部署在本地,并且用的配置非常高的电脑(或者mac和windows之间的差异?),因为我在issue下尝试搜解决方法,发现其实很多人反映过卡顿的问题,作者似乎感受不强。其实卡顿感很明显的。

我也怀疑过网络的问题,试过部署在国内的服务器,有一点改善,但也没有质的区别。

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


image

These resources will be requested every time you switch conversations, which is actually unnecessary.


I don’t know if the author deployed it locally and used a very high-configuration computer (or is it the difference between mac and windows?), because I tried to search for solutions under the issue and found that many people have reported the lag problem. The author doesn't seem to feel strongly about it. In fact, the lag is very obvious.

I also suspected a network problem and tried deploying a domestic server. There was a slight improvement, but there was no qualitative difference.

@ShinChven
Copy link

确实很卡

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Really stuck

@devyujie
Copy link

+1

@eightHundreds
Copy link

求求你把ssr,server component去掉💔

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Please remove ssr, server component💔

@arvinxx
Copy link
Contributor

arvinxx commented May 20, 2024

都会往 api/market 发送GET请求,导致进入页面卡顿。

是因为这个请求卡顿吗?

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Will send a GET request to api/market, causing the page to freeze.

Is it because of this request?

@arvinxx
Copy link
Contributor

arvinxx commented May 20, 2024

每切换对话都会请求这些资源,其实不必要的。

这些资源应该都在 service worker 缓存了的。你说的卡应该和这个没关系

我日常用的是MBP 20年 M1 的 13寸,并没有很卡。另外之前已经做了非常多轮的性能优化,应该比以前好很多了。目前剩余已知的是会话页面的切换和助手的切换是还存在一定延迟的问题,下个月应该能根治掉了。

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


These resources will be requested every time you switch conversations, which is actually unnecessary.

These resources should be cached in the service worker. The card you mentioned should have nothing to do with this.

I use the 13-inch MBP 20-year-old M1 on a daily basis, and it’s not very stuck. In addition, many rounds of performance optimization have been done before, and it should be much better than before. What is currently known is that there is still a certain delay in switching session pages and assistants, which should be resolved next month.

@ShinChven
Copy link

反正没有NextChat丝滑

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Not as smooth as NextChat anyway

@BruceLee569
Copy link
Author

BruceLee569 commented May 20, 2024

有缓存的情况下体验还过得去,首次访问的加载速度是真的慢,PC端要1分多钟才渲染完毕。我对比过ChatGPT-Next-Web和chatgpt-web-midjourney-proxy,PC端浏览器他们只需要三四秒,移动端lobe也至少比他们慢一倍,包括PWA应用。推荐给朋友都不好意思,用户体验堪忧呀,希望能多多测试优化一下。

测试用户端:Windows11 Chrome浏览器
测试链接:https://ai.jdz-ceramic.com/chat https://ai1.jdz-ceramic.com/ https://ai2.jdz-ceramic.com/
测试服务器:搬瓦工2H2G
服务器部署方式:docker镜像

1716173717854-1716173266494-20240520_104413.mp4

@Cp0204
Copy link

Cp0204 commented May 20, 2024

service worker

service worker 也撐不住資源多啊,一個幾十毫秒,時間都量變引起質變了。再加上服務器的請求…… 😂

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


service worker

The service worker cannot support the large number of resources. Every tens of milliseconds, the time changes quantitatively and qualitatively. Plus server requests... 😂

@arvinxx
Copy link
Contributor

arvinxx commented May 20, 2024

首次访问的加载速度是真的慢,PC端要1分多钟才渲染完毕。

@BruceLee569 preview 站点的访问也有这么慢么?另外我拿我的电脑打开你的站点很快啊,没缓存的情况也基本上秒开。你确定不是你的网络问题么?

default.mp4

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


The loading speed on the first visit is really slow, and it takes more than 1 minute to complete rendering on the PC side.

@BruceLee569 Is access to the preview site also so slow? In addition, when I open your site on my computer, it is very fast. Even if there is no cache, it can be opened in almost a second. Are you sure it's not a problem with your network?

default.mp4

@BruceLee569
Copy link
Author

BruceLee569 commented May 20, 2024

@arvinxx 网络没问题的,直接进这个聊天页面会很卡:https://ai.jdz-ceramic.com/chat
为什么要发送两百多个JS请求 chat UI 才渲染出来 😂

像你这样先进主页,再点立即开始速度就还好。

另外提个建议:感觉主页没必要单独显示一个欢迎界面,没啥作用,直接显示对话框用户体验会更好吧,主流的工具默认都是一个对话框,功能够用能用就好,拖慢性能的实现可以考虑放一放。

@Cp0204
Copy link

Cp0204 commented May 20, 2024

有缓存的情况下体验还过得去,首次访问的加载速度是真的慢,PC端要1分多钟才渲染完毕。我对比过ChatGPT-Next-Web和chatgpt-web-midjourney-proxy,PC端浏览器他们只需要三四秒,移动端lobe也至少比他们慢一倍,包括PWA应用。推荐给朋友都不好意思,用户体验堪忧呀,希望能多多测试优化一下。

测试用户端:Windows11 Chrome浏览器 测试链接:https://ai.jdz-ceramic.com/chat https://ai1.jdz-ceramic.com/ https://ai2.jdz-ceramic.com/ 测试服务器:搬瓦工2H2G 服务器部署方式:docker镜像

1716173717854-1716173266494-20240520_104413.mp4

首次访问的请求数😂,虽然有绝大一部分是UI出来,可以边用变加载的。但是1000+个请求,也真是不太优雅。

image

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


With cache, the experience is passable. The loading speed for the first visit is really slow. It takes more than a minute to render on the PC side. I have compared ChatGPT-Next-Web and chatgpt-web-midjourney-proxy. They only take three or four seconds for PC browsers, and mobile lobe is at least twice as slow as them, including PWA applications. I'm embarrassed to recommend it to my friends. The user experience is worrisome. I hope I can test and optimize it more.

Test client: Windows11 Chrome browser test link: https://ai.jdz-ceramic.com/chat https://ai1.jdz-ceramic.com/ https://ai2.jdz-ceramic.com/ test Server: 2H2G Server deployment method: docker image

1716173717854-1716173266494-20240520_104413.mp4

Number of requests for first visit😂

image

@ShinChven
Copy link

2024-05-20.2.35.28.mov

MacBook Pro 15 mid 2014 16GB

@BruceLee569
Copy link
Author

2024-05-20.2.35.28.mov
MacBook Pro 15 mid 2014 16GB

😂 跟我一样,没有对比就没有伤害。。

@arvinxx
Copy link
Contributor

arvinxx commented May 20, 2024

MacBook Pro 15 mid 2014 16GB

@ShinChven 如果是这个配置,使用 LobeChat 会卡的话,我个人还是建议你使用 NextChat 吧。 我并不打算为这么老的设备做什么优化,抱歉 🤷‍♂️

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


MacBook Pro 15 mid 2014 16GB

@ShinChven If LobeChat is stuck in this configuration, I personally recommend you to use NextChat. I don’t intend to do any optimization for such an old device, sorry 🤷‍♂️

@ShinChven
Copy link

MacBook Pro 15 mid 2014 16GB

@ShinChven 如果是这个配置,使用 LobeChat 会卡的话,我个人还是建议你使用 NextChat 吧。 我并不打算为这么老的设备做什么优化,抱歉 🤷‍♂️

我主力机 M1 Max 64GB 进 Settings 也卡……

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


MacBook Pro 15 mid 2014 16GB

@ShinChven If LobeChat is stuck in this configuration, I personally recommend you to use NextChat. I don’t intend to do any optimization for such an old device, sorry 🤷‍♂️

My main machine, M1 Max 64GB, is stuck in Settings...

@arvinxx
Copy link
Contributor

arvinxx commented May 20, 2024

@ShinChven 那能否录个屏看下具体怎么卡呢?

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@ShinChven Can you record the screen and see how it gets stuck?

@BruceLee569
Copy link
Author

另外提个建议:感觉主页没必要单独显示一个欢迎界面,没啥作用,直接显示对话框用户体验会更好吧,主流的工具默认都是一个对话框,功能够用能用就好,拖慢性能的实现可以考虑放一放。

你的这个建议让我有点怀疑你是不是真的在用了… 这个 welcome 只有新用户进来才会显示,如果你的本地会话记录超过 4 条,默认就会跳转到 /chat 路由的。

我用了这么久,都安利给几个朋友了。谁也不会去留意首页的跳转路由啊,所以我说缓存之后再用速度还可以,但进设置页还是会卡,我对前端不太熟悉,但我觉得点击后路由跳转到 settings/modal 应该就是卡顿的原因,其他框架进入设置并不会有路由跳转的动作。包括进入每一个子设置项,都会单独发送请求,等个一两秒,请问这设计是否合理呢?

即使将它优化到秒进,让请求在后台成功后再更新数据,但我只是进一个首页,后台在那里默默发送超过1000个请求(绝大部分都是不知道有什么用处的 js 文件),然后点一下设置,又在那里发送超过500个请求,说实话用这耗电量都大好多。

大部分用户都是普通人,第一次打开的时候也确实很卡(人们分享的时候也不会留意链接是首页还是聊天页),我试了你的 vercel 链接也是一样卡,跟 cdn 没关系,请在Windows端测试一下。

1716204996711-20240520_191121.mp4

找到bug点了,3秒请求之后,在页面处随便点击一下,UI就渲染出来了。(虽然后台还是会默默依次发送近1000个js请求。。)

20240520_191324.mp4

@arvinxx
Copy link
Contributor

arvinxx commented May 20, 2024

找到bug点了,3秒请求之后,在页面处随便点击一下,UI就渲染出来了

这个似乎是 SSR 水合问题… 就是客户端和服务端的语种没有匹配上,导致首次水合失败,然后会一直 fallback 到静态 html 的样子。只有用户做了点击操作后,才会重新在 client 端进行渲染。但第二次及以后,客户端的主题/语种都会在 cookie 中记录下来,这样水合就能顺利完成。

我理解这个应该也就是第一次会出现,而且用户不做任何操作的概率也比较低,所以一直没当回事 😅 我看看后续怎么修复下吧。

即使将它优化到秒进,让请求在后台成功后再更新数据,但我只是进一个首页,后台在那里默默发送超过1000个请求(绝大部分都是不知道有什么用处的 js 文件),然后点一下设置,又在那里发送超过500个请求,说实话用这耗电量都大好多。

这个我理解应该是 pwa 的特性吧?浏览器会在空闲的时候预先将整个网站都缓存下来,这样在未来打开网站的速度会加快。这不算一个 feature 么…

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Found the bug. After 3 seconds of request, just click on the page and the UI will be rendered.

This seems to be an SSR hydration problem... that is, the language of the client and server do not match, causing the first hydration to fail, and then it will fall back to static html. Only after the user clicks, it will be rendered again on the client side. But the second time and later, the client's theme/language will be recorded in the cookie, so that the hydration can be completed smoothly.

I understand that this should only appear for the first time, and the probability of users not doing anything is relatively low, so I haven’t taken it seriously 😅

I'll see how to fix it later.

Even if it is optimized to be processed in seconds and the data is updated after the request succeeds in the background, I just enter a homepage, and the background silently sends more than 1,000 requests there (most of them are js files with no idea of ​​their use) , then click Settings, and send more than 500 requests there. To be honest, this consumes a lot more power.

I understand this should be a feature of pwa, right? The browser will cache the entire website in advance when it is idle, so that the speed of opening the website in the future will be faster. Isn’t this a feature?…

@arvinxx
Copy link
Contributor

arvinxx commented May 20, 2024

其他框架进入设置并不会有路由跳转的动作。包括进入每一个子设置项,都会单独发送请求,等个一两秒,请问这设计是否合理呢

你说的发给 /api/market 这个我已经修了,你再试试看? 另外我好像没看到你录制关于进入设置页卡的视频?

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


When other frameworks enter the settings, there will be no routing jump action. Including entering each sub-setting item, a request will be sent separately and wait for a second or two. Is this design reasonable?

You said to send it to /api/market. I have already fixed this. Can you try it again? Also, I don’t think I saw the video you recorded about entering the settings page?

@BruceLee569
Copy link
Author

BruceLee569 commented May 21, 2024

嗯嗯 感谢回复 现在好很多了

设置项每次点完还是需要等待渲染,不能秒开,操作速度一快UI也容易反应不过来,给人感觉卡卡的。首次缓存后再次点击,大部分UI都不用等待渲染了。但是关闭窗口之后再进入又会慢一点,PWA应用杀后台再进又会更慢一点。

后续能够注意优化就更好啦 👏

@kele527
Copy link

kele527 commented May 22, 2024

问题是本质不是加载慢,而是操作的时候UI卡顿,比如点任意一个按钮,都要等2秒才响应,正常的网页应该是点击后在0.1秒内响应,超过0.3秒就会明显感受到卡顿

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


The problem is not that loading is slow, but that the UI freezes during operation. For example, when you click on any button, you have to wait for 2 seconds to respond. A normal web page should respond within 0.1 seconds after clicking it. If it exceeds 0.3 seconds, you will notice it. to katon

@arvinxx
Copy link
Contributor

arvinxx commented May 22, 2024

@kele527 你说的没错,操作延迟的问题是存在的,还需要做更多的优化

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@kele527 You are right, the problem of operation delay exists, and more optimization needs to be done

@ShinChven
Copy link

你是不是整了什么 SSR ?纯SPA应该不会这么卡

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Did you fix some SSR? A pure SPA should not be so stuck

@arvinxx
Copy link
Contributor

arvinxx commented May 23, 2024

你是不是整了什么 SSR ?纯SPA应该不会这么卡

跟SSR没啥关系。 Next 默认的路由体系是 MPA (多页应用),理论上是会比SPA的慢

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Did you fix any SSR? A pure SPA should not be so stuck

It has nothing to do with SSR. Next The default routing system is MPA (Multi-page Application), which is theoretically slower than SPA.

@dongjb
Copy link

dongjb commented May 24, 2024

我部署在新加坡的服务器上,有缓存的情况下访问应该还行,2S左右,但是切换操作的不是很流畅,有卡顿,另外我将代码拉到本地,启动巨慢,是超级慢,点一个页面都得好2、3分钟......

配置:i9Mac 64G内存

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


I deployed it on a server in Singapore. With cache, the access should be fine, about 2 seconds. However, the switching operation is not very smooth and there are lags. In addition, I pulled the code locally and the startup was extremely slow. It was super slow. Click Each page takes 2 or 3 minutes...

Configuration: i9Mac 64G memory

@ShinChven
Copy link

我部署在新加坡的服务器上,有缓存的情况下访问应该还行,2S左右,但是切换操作的不是很流畅,有卡顿,另外我将代码拉到本地,启动巨慢,是超级慢,点一个页面都得好2、3分钟......

配置:i9Mac 64G内存

新加坡+1,我NextChat和Lobe都在一起。

最近给朋友安利lobe,昨天就告诉我加载不出来。

image

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


I deployed it on a server in Singapore. With cache, the access should be fine, about 2 seconds. However, the switching operation is not very smooth and there are lags. In addition, I pulled the code locally and the startup was extremely slow. It was super slow. It takes 2 or 3 minutes to click on a page...

Configuration: i9Mac 64G memory

Singapore +1, I have NextChat and Lobe together.

I recently gave my Amway logo to a friend, but yesterday I was told that it could not be loaded.

image

@ShinChven
Copy link

你是不是整了什么 SSR ?纯SPA应该不会这么卡

跟SSR没啥关系。 Next 默认的路由体系是 MPA (多页应用),理论上是会比SPA的慢

要不要用 Vite + React Router 重构一下, 非常丝滑的。挂在 Express 的 middleware 上一样可以搞 MPA 。

https://github.com/ShinChven/druid/blob/main/app/src/views/index.ts

@arvinxx
Copy link
Contributor

arvinxx commented May 24, 2024

@ShinChven 不计划 ,next 比 rr 好多了

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@ShinChven not planning

@lobehubbot
Copy link
Member

@BruceLee569

This issue is closed, If you have any questions, you can comment and reply.
此问题已经关闭。如果您有任何问题,可以留言并回复。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Something isn't working | 缺陷
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

9 participants