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: forward 插件从tg转发图片或者视频导致应用假死 #975

Open
ghost opened this issue Feb 12, 2023 · 14 comments
Open

Bug: forward 插件从tg转发图片或者视频导致应用假死 #975

ghost opened this issue Feb 12, 2023 · 14 comments

Comments

@ghost
Copy link

ghost commented Feb 12, 2023

Describe the bug

  1. forward插件把图片从tg转发到Q群或者频道会导致应用假死
    BD3U{}XO2BWXS 5XNUD~6DR

  2. 停止应用再启动发现端口被占用,查看进程,发现没有别关闭
    image

  3. 从onebot转发到tg没有问题

Steps to reproduce

1、安装onebot和forward插件
2. 让tg频道的消息转发onebot
3. 向tg频道发送一个图片

Expected behavior

能转发并且不会假死

Screenshots

No response

Versions

  • OS: ubuntu
  • Platform: onebot & tg
  • Node version: 17.9
  • Koishi version: 4.11.5

Additional context

No response

@ghost ghost added the bug BUG label Feb 12, 2023
@shigma
Copy link
Member

shigma commented Feb 12, 2023

cc @Anillc

@Anillc
Copy link
Member

Anillc commented Feb 13, 2023

经测试,无论是从 qq 转发图片到 tg 还是从 tg 转发图片到 qq, 均没有遇到卡死的情况。

假死是指任何指令都无法触发吗?是否可以提供日志参考一下。

另外你跑机器人的服务器的性能如何呢,有没有可能是内存不足等原因导致的转发失败。如果可以的话尝试一下配置机器人的 selfUrl 选项(telegram-adapter 在没有配置该选项的时候图片等消息经过了 base64 编码,可能在配置较低的机器上不能成功处理)

@shigma shigma added the needs repro 无法复现 label Feb 14, 2023
@ghost
Copy link
Author

ghost commented Feb 14, 2023

经测试,无论是从 qq 转发图片到 tg 还是从 tg 转发图片到 qq, 均没有遇到卡死的情况。

假死是指任何指令都无法触发吗?是否可以提供日志参考一下。

另外你跑机器人的服务器的性能如何呢,有没有可能是内存不足等原因导致的转发失败。如果可以的话尝试一下配置机器人的 selfUrl 选项(telegram-adapter 在没有配置该选项的时候图片等消息经过了 base64 编码,可能在配置较低的机器上不能成功处理)

小图片(100k以下)没问题,超过100k就会出现阻塞主线程
比如这张:
image

@ghost
Copy link
Author

ghost commented Feb 14, 2023

经测试,无论是从 qq 转发图片到 tg 还是从 tg 转发图片到 qq, 均没有遇到卡死的情况。
假死是指任何指令都无法触发吗?是否可以提供日志参考一下。
另外你跑机器人的服务器的性能如何呢,有没有可能是内存不足等原因导致的转发失败。如果可以的话尝试一下配置机器人的 selfUrl 选项(telegram-adapter 在没有配置该选项的时候图片等消息经过了 base64 编码,可能在配置较低的机器上不能成功处理)

小图片(100k以下)没问题,超过100k就会出现阻塞主线程 比如这张: image

在图片没有转发成功前,bot不会相应任何指令,转发完成后才会继续响应
具体操作

  1. 发送一张较大的图片
  2. 发送help指令
    image

在图片转发完成前不会响应任何指令
image

@Anillc
Copy link
Member

Anillc commented Feb 20, 2023

我这边尝试多种方式仍然无法复现,测试大图片也不会阻塞,机器人能够正常响应指令。希望给出更多信息便于调试。

@ghost
Copy link
Author

ghost commented Feb 21, 2023

我这边尝试多种方式仍然无法复现,测试大图片也不会阻塞,机器人能够正常响应指令。希望给出更多信息便于调试。

请问你是国外服务器还是国内服务器挂梯子

@MaikoTan
Copy link
Member

MaikoTan commented Feb 22, 2023

What is your spec for running the Koishi Robot?

It would be better to copy your envinfo messages from the status bar of the Koishi Console.

@ghost
Copy link
Author

ghost commented Feb 22, 2023

What is your spec for running the Koishi Robot?

It would be better to copy your envinfo messages from the status bar of the Koishi Console.

System:
OS: Linux 4.15 Ubuntu 18.04.2 LTS (Bionic Beaver)
CPU: (2) x64 Intel(R) Xeon(R) Platinum 8269CY CPU @ 2.50GHz

Binaries:
Node: 16.19.0
Yarn: 1.22.19

Koishi:
Core: 4.11.7
Console: 5.5.0

你们的服务器是在国内吗,我有国内和国外的服务器,但是国内服务器我没梯子测试

@ghost
Copy link
Author

ghost commented Feb 24, 2023

在windows 下测试,没有这个问题。今天尝试在国内ubuntu上测试

@ghost
Copy link
Author

ghost commented Feb 24, 2023

已经确定 无论国内外服务器,只要是ubuntu,在tg转发图片到QQ群就会假死加分钟,期间所有机器人都不会响应指令。几分钟后图片转发成功,全部指令一起响应。请问开发者有没有在ubuntu下测试,我可以提供服务器,我目前没有任何头绪。

@KuroshioDev
Copy link

测试了一下,与OS系统无关,但是与平台有关。
测试方法

  1. 在forward插件里面打log
  2. 编写几个shotcut正则匹配的的方法

在onebot下,图片进来的格式是
image

他的执行时间是
image

用了不到1s

而tg进来的图片格式是base64
image

用了2分钟。

去掉正则匹配的命令
再执行forward,速度又变正常。
应该是base64字符串过长导致shotcut匹配耗时过长

@shigma
Copy link
Member

shigma commented Feb 26, 2023

感谢楼上提供的线索!这看起来是一个需要在 Koishi 侧优化的点。我会将它加入下一阶段的 roadmap。

@shigma shigma added confirmed and removed needs repro 无法复现 labels Feb 26, 2023
@KuroshioDev
Copy link

感谢楼上提供的线索!这看起来是一个需要在 Koishi 侧优化的点。我会将它加入下一阶段的 roadmap。

是否需要考虑用户恶意输入超长字符串

@purerosefallen
Copy link
Member

Seemed that the string matching task made Node's main thread stuck. Is it possible to move it to worker_threads?

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

5 participants