⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

@notfoundzzz
Copy link
Contributor

@notfoundzzz notfoundzzz commented Feb 2, 2026

如何测试

  1. 启动 Mogan。
  2. 新建空文档。
  3. 点击 插入 -> 外观块 -> Art Frame -> Carved Wood
  4. 预期:不崩溃,外观块正常显示。

2026/02/02

What

复现场景中,点击 插入 -> 外观块 -> Art Frame -> Carved Wood 会直接崩溃。
根因是 src/Plugins/MuPDF/mupdf_picture.cpp 中像素读写实现对底层缓冲区做了固定 4 字节像素的假设:

  • 直接将 samples 强转为 color* 访问;
  • 忽略了 MuPDF pixmap 的真实 n(通道数)和 stride(行步长);
  • 在某些图像布局下会读错甚至越界,最终触发段错误。

修复内容:

  1. internal_get_pixel / internal_set_pixel 增加坐标边界保护。
  2. 按 MuPDF pixmap 的实际 n/stride/alpha 进行读写,不再使用 color* 强转访问。
  3. 在 alpha 场景下保持预乘/反预乘处理,兼容灰度、灰度+alpha、RGB、RGBA 路径。

Why

resolve #2732
Art Frame 会走图片 effect 链(含透明和裁剪),该链路对像素访问非常密集。
底层像素布局假设错误会在该场景被稳定放大,导致崩溃。
修复后,像素访问与 MuPDF pixmap 内存布局一致,避免越界和非法读取。

@notfoundzzz notfoundzzz marked this pull request as draft February 2, 2026 03:12
@notfoundzzz notfoundzzz force-pushed the 222-28/fix-artframe-crash branch from da808f9 to 1428216 Compare February 2, 2026 08:48
@notfoundzzz notfoundzzz changed the title 222-28 [222_28] 修复 Art Frame 崩溃 Feb 2, 2026
@notfoundzzz notfoundzzz force-pushed the 222-28/fix-artframe-crash branch from 1428216 to f9a75ea Compare February 2, 2026 08:53
@notfoundzzz notfoundzzz marked this pull request as ready for review February 2, 2026 08:56
@notfoundzzz notfoundzzz force-pushed the 222-28/fix-artframe-crash branch from 6fff9fe to f515df8 Compare February 3, 2026 03:15
Copy link
Contributor

@jetjinser jetjinser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@MoonL79
Copy link
Contributor

MoonL79 commented Feb 4, 2026

ISSUE #2732

Copy link
Contributor

@da-liii da-liii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

继续改进错误处理的细节

@MoonL79 MoonL79 added the bug Something isn't working label Feb 5, 2026
Copy link
Contributor

@da-liii da-liii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@MoonL79 MoonL79 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@da-liii da-liii merged commit e617903 into MoganLab:main Feb 5, 2026
4 checks passed
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

None yet

Development

Successfully merging this pull request may close these issues.

点击插入 -> 外观块 -> Art Frame -> Carved Wood 会直接 crash

4 participants