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

Dockerfile 支持安装 Playwright 依赖和字体 #113

Open
SK-415 opened this issue Jan 23, 2022 · 4 comments
Open

Dockerfile 支持安装 Playwright 依赖和字体 #113

SK-415 opened this issue Jan 23, 2022 · 4 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@SK-415
Copy link
Owner

SK-415 commented Jan 23, 2022

使用了一段时间后发现在非ubuntu上使用playwright是个坑,主要是依赖的安装(由于无法使用playwright install-deps),各种依赖、字体的安装要手动完成,依赖装不全会容易出现问题,当然手动安装虽然是麻烦了点但也可以接受。
不过centos7上有一个令人无法接受的问题,就是chromium的编码为utf8而非utf8mb4,导致了一些4字节的emoji表情无法正常显示,我暂时没有找到解决的办法(但应该是有的)。
我尝试改成firefox(为此手动编译安装了一个glibc-2.18),可以显示emoji了但是firefox上的emoji太丑了,于是我又去尝试webkit,但又被卡在了依赖安装这一步上,被centos上的playwright折磨了这么多之后我直接改成ubuntu,一行playwright install-deps下去啥事都没了(印象中貌似连字体都没装)。

所以我建议可以将应用移到ubuntu的docker里,可以是整个应用,也可以是仅playwright这部分,或者至少请在文档中建议使用ubuntu或者ubuntu的docker。

Originally posted by @YuKi74 in #12 (comment)

@SK-415
Copy link
Owner Author

SK-415 commented Jan 23, 2022

@YuKi74
Emoji 无法显示并不是编码问题而是缺少一个 Emoji 字体,比如 Noto Emoji Fonts。UTF-8 是涵盖完整 Unicode 的,包括四字节 Emoji。你提到的问题是 MySQL 数据库的 utf8 编码只有三个字节,因此需要 utf8mb4 才能储存四字节的字符。这是 MySQL 的特殊编码,并非 UTF-8 标准。

使用 Ubuntu 部署的体验确实远高于 CentOS,因为默认 Linux 用户有自行解决问题的能力就没做特别说明,之后会添加进 FAQ 里。

@YuKi74
Copy link

YuKi74 commented Jan 23, 2022

@YuKi74 Emoji 无法显示并不是编码问题而是缺少一个 Emoji 字体,比如 Noto Emoji Fonts。UTF-8 是涵盖完整 Unicode 的,包括四字节 Emoji。你提到的问题是 MySQL 数据库的 utf8 编码只有三个字节,因此需要 utf8mb4 才能储存四字节的字符。这是 MySQL 的特殊编码,并非 UTF-8 标准。

使用 Ubuntu 部署的体验确实远高于 CentOS,因为默认 Linux 用户有自行解决问题的能力就没做特别说明,之后会添加进 FAQ 里。

@SK-415
是我才疏学浅了。经过我的排查发现是emoji字体的版本太低了,大概是2012年左右的一个版本。导致其实有部分emoji是能显示了,而那个无法显示的emoji又恰好是组合式emoji,被拆成了两个字符,而其中一个还是正常显示的,另一个被显示为方块。因为这样的原因导致我错误地推断是4字节的字符无法被识别而直接被拆分。

而firefox从50版本开始使用的是内置的Twitter推出的Twemoji是真的丑而非系统字体,这导致我当时错误地认为系统中是有相应字体的。

对于这个问题个人有个小小的拙见,可以把playwright的环境包装到docker中,在python中使用subprocess或者docker-py模块操作docker来进行截图,解决额外的依赖安装问题。或者推荐用户使用项目中的Dockerfile进行构建与部署。

非常感谢您的指正,工作辛苦了。

@SK-415
Copy link
Owner Author

SK-415 commented Jan 23, 2022

构建 Docker 确实是一个不错的提议,目前的 Dockfile 是由 nb-cli 自动生成的并不会安装 Playwright 所需的相关依赖。可惜我并不熟悉 Linux 和 Docker,只能等之后有空了再慢慢研究。

@SK-415 SK-415 added documentation Improvements or additions to documentation enhancement New feature or request labels Jan 23, 2022
@SK-415 SK-415 changed the title 文档增加 Linux FAQ Dockerfile 支持安装 Playwright 依赖和字体,文档增加 Linux FAQ Jan 23, 2022
@SK-415 SK-415 modified the milestones: v1.4.0, 2.0.0 Feb 24, 2022
@SK-415 SK-415 changed the title Dockerfile 支持安装 Playwright 依赖和字体,文档增加 Linux FAQ Dockerfile 支持安装 Playwright 依赖和字体 Feb 24, 2022
@ECIAP
Copy link

ECIAP commented Mar 15, 2022

非ubuntu上使用playwright确实是个大坑,尽管已经在playwright上已经有不少的issue请求支持 CentOS,但看上去短时间内很难完成..


请问是否能否在wiki中提供需要的依赖项,来帮助手动安装

@SK-415 SK-415 modified the milestones: v2.0.0, v1.5.0 Sep 5, 2022
@SK-415 SK-415 removed this from the v1.5.0 milestone Feb 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants