logseq / logseq

A privacy-first, open-source platform for knowledge management and collaboration. Download link: http://github.com/logseq/logseq/releases. roadmap: http://trello.com/b/8txSM12G/roadmap
https://logseq.com
GNU Affero General Public License v3.0
30.26k stars 1.77k forks source link

Input Lag 输入卡顿 #3486

Closed linluxiang closed 1 year ago

linluxiang commented 2 years ago

Note The issue only exists on the desktop version. https://logseq.com/ is not impacted.

Machine Translation: At any time when typing, there is a certain chance of lag, each lag is about 1-2 seconds, and the interval between occurrences varies from a few seconds to more than 10 seconds. There is a higher probability of occurrence in the following cases.

When pressing enter to create a new block
When typing a new word after a space
When pressing and holding backspace to delete text

Less likely to occur in the following cases

When you keep holding down a letter and keep typing

After a second or so, all the content entered during the lag will appear on the screen at once.

I suspect that the new block, or the function that saves the page at regular intervals, is a blocking function, blocking the event that listens for keyboard input in the input area.

Not on any machine, I have two computers, in one of them there is no problem, even if the operation of remote network disk files. And the other one has problems operating local files. The antivirus software installed on the two computers is not the same.

Translated with www.DeepL.com/Translator (free version)

Original: 在任何时候输入的时候,都有一定几率出现卡顿,每次卡顿大概在1-2秒钟左右,发生间隔时间从几秒到10几秒不等。 在以下情况下有较大概率出现。

  1. 按回车新建一个块的时候
  2. 在空格以后输入新单词的时候
  3. 不停按住backspace删除文字的时候

在以下情况较少出现

  1. 一直按住一个字母不停输入的时候

卡顿的表现是光标闪烁,但是键盘按键输入的任何内容都无法显示在屏幕上,过了大概1秒钟左右,在卡顿期间输入的内容会一次性的全部出现在屏幕上。

怀疑是新建块,或者定时保存页面的函数是阻塞函数,阻塞了输入区域的监听键盘输入内容的事件。

不是在任何机器上都有,我有两台电脑,在其中一台就没问题,就算操作远程网盘的文件也没问题。而另一台操作本地文件也有问题。两台电脑安装的杀毒软件不一样。

Issue

系统信息

Additional context

可能和 #3320 是同一个问题

cnrpman commented 2 years ago

To locate the problem, may you provide more details, e.g., do some measurement with the Developer Tools? 为了方便还原问题, 可以尝试用开发者工具测量一下性能吗? 谢谢~

linluxiang commented 2 years ago

请问怎样使用?能否给出详细的步骤来帮助还原问题?

cnrpman commented 2 years ago

Example:

  1. Ctrl + shift + i 打开开发者工具
  2. 查看 Performance (性能) 标签
  3. 点一下圆点录制按钮
linluxiang commented 2 years ago

我录制了一个profile文件,请问如何上传profile文件?

cnrpman commented 2 years ago

@linluxiang 可以打成压缩包上传吗?

linluxiang commented 2 years ago

image 从profile里面可以很明显的看到卡顿产生的大块空白

linluxiang commented 2 years ago

Profile-20211216T093240.zip 我把Profile文件上传了

cnrpman commented 2 years ago

What I saw currently is the crbrowser is blocked after a Layout Shift caused by creating new block happens. Might be chromium's issue under specific environment..? Need some more clue.. I got some similar reports on Discord and going to collect more cases.

cnrpman commented 2 years ago

Related report on Discord

linluxiang commented 2 years ago

Yes, I can imagine it's a low-level problem. But I don't have any similar problem for other electron-based softwares such as Obisidian or VS Code on the same machine.

cnrpman commented 2 years ago

@linluxiang a small request: if the same issue happens in the LogSeq's browser version?d

linluxiang commented 2 years ago

How to get access to the browser version?

cnrpman commented 2 years ago

open https://logseq.com/ with any browser supports Native File System API (e.g. Chrome 86+)

linluxiang commented 2 years ago

Great, I just tested Chrome and Edge, both worked totally fine without any problem.

cnrpman commented 2 years ago

@linluxiang I see. So it's a desktop only issue. You may deem the browser LogSeq as a temporary replacement till we can totally fix it. Basically they are doing the same job while the desktop version supports plugins.

linluxiang commented 2 years ago

Yeah, that's the only compromised option ATM. Thank you very much for your work and I hope this bug can be fixed soon.

whatzitmather commented 2 years ago

@cnrpman Thanks for looking into this (you and I had chatted over on Discord about a similar issue). I look forward to a resolution - the web app works for now, but I would love to be able to run plugins, upload assets with a slash command, and use custom themes (all of which can only be done in the desktop app, if I'm not mistaken).

sawhney17 commented 2 years ago

Something that makes a huge difference is refreshing the database. Every once in a while, i notice a lot of input lag and specifically while hitting enter.

Screen Shot 2022-01-12 at 7 26 41 PM
andelf commented 2 years ago

@sawhney17 both Refresh and Re-index require seconds to finish(depends on your size of graph data). It might be a normal situation.

mahso commented 2 years ago

I experience very similar issues as the topic starter. The most severe lags occur when I do ctrl-backspace to delete whole words, but they also occur on regular typing and when creating new blocks.

The issues are only in the desktop app (currently v.0.5.8 but also in the previous versions) and only on my newest laptop (Windows 10). Everything runs smoothly in the browser version and also on the desktop app (also v.0.5.8) on my much older Surface Pro. On the problematic PC, the issue occurs even on a newly opened graph stored on a local-only drive. I have no custom CSS or plugins. Refresh and re-index do not help.

I'd be happy to contribute to the troubleshooting. Just let me know what I can do!

whatzitmather commented 2 years ago

Same here - definitely happy to do whatever I can to provide additional info.

@mahso , that's interesting that the older surface pro worked just fine...I guess it's just particular windows machines...

My daily driver is a work computer running Windows 10 enterprise. I wonder if there are additional pieces of info that would help to isolate the problem for the devs?

mahso commented 2 years ago

My daily driver is a work computer running Windows 10 enterprise. I wonder if there are additional pieces of info that would help to isolate the problem for the devs?

@whatzitmather My problematic PC is also running Windows 10 Enterprise. A screenshot of System Information is given below.

@cnrpman Let me know if I can help to troubleshoot. Parts of the replies to the topic starter is in Chinese, so I don't know what exactly you requested from him/her :-) image

cnrpman commented 2 years ago

@mahso Currently we think there are many factors that will affect the input lag:

  1. Long page;
  2. The current page has custom queries;
  3. Maybe the file has just been imported, some feedback in the community is that re-index will fix this;
  4. Cache issue: try the settings / clear cache option, and delete your .logseq directory (have to re-add your graph and plug-ins after this step)

We are optimizing the 1. and 2.

mahso commented 2 years ago

@cnrpman I get the lagging issue even after clearing cache, deleting .logseq directory and opening a very small, locally stored test graph with just a couple of short pages and no queries. On my slower, secondary PC I have larger graphs and no lag. So it is something with my primary PC (and @whatzitmather 's PC) that doesn't play well with the Logseq desktop app.

If I can do anything to help diagnoseing, I'd be happy to help!

cnrpman commented 2 years ago

@mahso @whatzitmather It would be great if you can record a profile log and attach here:

  1. Ctrl + shift + i to open Dev Tool
  2. Visit the Performance Tab
  3. Click the Red Circle on the panel to record
  4. Click the Down arrow on the panel to save the profile log
mahso commented 2 years ago

@cnrpman Here is the profile log from some 30 seconds of random typing and erasing over several blocks. I had severe lags a few times in the session. Hope it helps :-) If not, let me know what more I can do.

The saved log is a JSON file which is not a supported file type to attach here so I zip'ed it. Profile-20220118T181143.zip

whatzitmather commented 2 years ago

@mahso - thanks for chiming in, too!

@cnrpman , my experience is similar - desktop app input lag even after:

Profile-20211216T101825 (1).zip

heilca commented 2 years ago

I'm running logseq in a Windows Enterprise environment an a notebook too.

Version 0.4.8 runs well (e.g. short response times creating new tags). I tested all versions above (0.4.9 => 0.5.9) creating links generates long waiting times (5 to 10 sec) before you can type the next characters.

I run Windows 10 Enterprise, version 21H2 build 19044.1466

davidjaggi commented 2 years ago

Just experienced the same problem too. The same graph runs smoothly on my private machine with Windows 10 Pro. As I opened the graph on my working machine (Windows 10 Enterprise Version 1909) I encountered some input lag. Happy to help to resolve this issue.

cnrpman commented 2 years ago

@davidjaggi @heilca @mahso @whatzitmather Thanks for report. Going to install a Win 10 Enterprise on VM @linluxiang Just wonder are you also using Win 10 Enterprise?

rudidu commented 2 years ago

Hi Team,

Just wanted to say I have the same issue.

Win10 Pro 1909.1556 Logseq V0.5.9

Happy to help with any testing/debugging that might be required. It runs perfectly on my other machine with the same vault/graph.

cnrpman commented 2 years ago

@rudidu thanks. Just wonder are you using some pro-only features? (e.g. bitlocker)

rudidu commented 2 years ago

@cnrpman Oh yes, Bitlocker is enabled (has to be) - my other machine is not using Bitlocker.

Not sure if that's the issue, Logseq is accessing files on another internal drive that doesn't have Bitlocker enabled. I suspended Bitlocker protection and the behaviour persists.

cnrpman commented 2 years ago

@rudidu Might related to caching - will investigate it

linluxiang commented 2 years ago

@cnrpman Nope, I'm using Win 10 Professional.

davidjaggi commented 2 years ago

I also have Windows 10 Pro 19044.1469 at home and there it works without any issues. Could this be due to the OS build? Since the lagging OS build on my Enterprise machine is also 1909.

heilca commented 2 years ago

The system I use: Edition: Windows 10 Enterprise Version: 21H2 Build: 19044.1466

whatzitmather commented 2 years ago

This is my build:

image

mahso commented 2 years ago

@cnrpman Oh yes, Bitlocker is enabled (has to be) - my other machine is not using Bitlocker.

Not sure if that's the issue, Logseq is accessing files on another internal drive that doesn't have Bitlocker enabled. I suspended Bitlocker protection and the behaviour persists.

@cnrpman For what it's worth, I also have BitLocker enabled on my c-drive (enforced by the administrator), but I tried making a new graph on a USB drive without BitLocker and it lags even more than those on my c-drive.

linluxiang commented 2 years ago

Yes, I have Bitlocker enabled as well.

davidjaggi commented 2 years ago

I also have BitLocker enabled. Testing on an external SSD and the issue still persists. The same graph performs well on my home machine. Another option would be if Windows defender is the bottleneck.

heilca commented 2 years ago

Bitlocker enabled as well (demand by administrator).

I observed, that the activity of Windows Defender increased (50% or even more) when I start typing.

nickriches commented 2 years ago

Hi. I am having the same issues as above. Performance report below, and machine specifications.

Running from the web is a viable option, but there are certain plugins I would miss.

logseq_performance

Processor Intel(R) Core(TM) i5-8500 CPU @ 3.00GHz 3.00 GHz Installed RAM 16.0 GB (15.8 GB usable) Device ID 282A5416-28B8-400B-B1E0-8E879C752427 Product ID 00329-00000-00003-AA674 System type 64-bit operating system, x64-based processor Pen and touch No pen or touch input is available for this display

cnrpman commented 2 years ago

@helica Good observation!

davidjaggi commented 2 years ago

I initially thought that real-time protection was the issue. But it is enabled on my lagging as well as on my well-performing machine.

ashishbhateja commented 2 years ago

I use a Mac and Logseq 0.5.9 is giving me grief. I have a 3-5 seconds lag. Tried refreshing, reindexing and reinstalling. It’s quite frustrating.

mahso commented 2 years ago

I think @heilca is onto something important. I see a strong correlation between the lag in the desktop app and the CPU use of the process "Antimalware Service Executable/Microsoft Defender Antivirus Service". It doesn't go very high but always up to 10-20% when I experience lag and fall back to a few percent or less (typically less than 1%) after the lagging stops.

The strange thing is that I have the same process (at least a process with identical name) on my secondary computer. It never spikes during typing and Logseq never lags.

heilca commented 2 years ago

I think @heilca is onto something important. I see a strong correlation between the lag in the desktop app and the CPU use of the process "Antimalware Service Executable/Microsoft Defender Antivirus Service". It doesn't go very high but always up to 10-20% when I experience lag and fall back to a few percent or less (typically less than 1%) after the lagging stops.

The strange thing is that I have the same process (at least a process with identical name) on my secondary computer. It never spikes during typing and Logseq never lags.

... and with version 0.4.8 there ist no Input lag.

mahso commented 2 years ago

I think @heilca is onto something important. I see a strong correlation between the lag in the desktop app and the CPU use of the process "Antimalware Service Executable/Microsoft Defender Antivirus Service". It doesn't go very high but always up to 10-20% when I experience lag and fall back to a few percent or less (typically less than 1%) after the lagging stops. The strange thing is that I have the same process (at least a process with identical name) on my secondary computer. It never spikes during typing and Logseq never lags.

... and with version 0.4.8 there ist no Input lag.

I downgraded to version 0.4.8 now and also experience no lag. @cnrpman If it is of help, I can upgrade to 0.4.9 and so on and report back in which version the lagging starts.

mahso commented 2 years ago

I think @heilca is onto something important. I see a strong correlation between the lag in the desktop app and the CPU use of the process "Antimalware Service Executable/Microsoft Defender Antivirus Service". It doesn't go very high but always up to 10-20% when I experience lag and fall back to a few percent or less (typically less than 1%) after the lagging stops. The strange thing is that I have the same process (at least a process with identical name) on my secondary computer. It never spikes during typing and Logseq never lags.

... and with version 0.4.8 there ist no Input lag.

I downgraded to version 0.4.8 now and also experience no lag. @cnrpman If it is of help, I can upgrade to 0.4.9 and so on and report back in which version the lagging starts.

... unless @heilca already did that exercise :-)