Repository navigation
Releases
0.1.6
0.1.6 — 512 MB 设备低内存阅读,超大图不再失败
本版让黑白屏上的超大跨页扫描图走低内存解码:之前会解码失败、占掉大量内存的 9000×6480 级源图,现在可以正常连读和来回翻。同时把 16 万字节的 opdsforcomic_pse.lua 拆成职责单一的模块,并按「内存优先」重新定尺缓存。
更新内容
- 超大图低内存解码(仅黑白屏):超过约 800 万像素的 PNG/JPEG 走新路线——PNG 用设备自带的 libpng 直接解成灰度、再用 Leptonica 原生缩图;JPEG 用 TurboJPEG 在解码时缩小。保留约 800 万像素的灰度阅读副本。适屏阅读的清晰度保持正常,高倍率放大的细节会少于原图。彩色屏和普通尺寸图片仍走原路径。
- 缓存按内存优先重新定尺:解码后的整页、半页缓存单张上限 8 MiB、合计 16 MiB(原 32 / 64 MiB);压缩数据内存缓存目标 8 MiB,并至少保留两页。为 512 MB 设备让出常驻内存。
- 失败语义更正确:内存不足时保留已下载的原始数据并冷却 10 秒后重试,不再把内存不足当坏图反复重下;只有确认是解码失败才丢弃并重新取图。低内存路线不会偷偷回退到高内存路径,超出预算时给出明确提示。
- 模块拆分:把
opdsforcomic_pse.lua按职责拆开——opdsforcomic_perf(性能计时)、opdsforcomic_worker(后台预取子进程)、opdsforcomic_image(独立 MuPDF 上下文解码,不再产生中间整幅 RGB 副本)、opdsforcomic_lowmem(低内存解码)。运行时 Lua 文件从 5 个增加到 9 个。 - 后台预取:子进程带字节与时间上限、超时抢占、文件描述符与待机锁回收和熔断;临时启动失败按 2 / 4 / 8 / 16 / 30 秒退避重试。
- 章节缓存与进度刷新:切章时按源页刷新缓存和进度,重绘不再误取消正在进行的预取。
实测与取舍
- 已在 512 MB 的 Kobo Aura One 上实测:此前会失败的 9000×6480 级源图章节可正常连读并来回翻,没有出现占位图或内存不足提示;同样的源图在上一版会出现解码失败。
- 代价是这类源图每次翻页都要等解码:约 2200 万像素的源图约 1.4 秒,约 5900 万像素的约 2.6 秒,加上取图合计约 1.5 ~ 4 秒。屏幕刷新本身仍是 0.1 秒级,等待来自解码。源图像素越大越明显。
- 这类超大图不进入解码缓存(每次重新解码),这是为省内存有意做的取舍。
- 不能承诺整个 KOReader 始终低于 200 MB。 独立 ARM 原生测试进程里,9033×6480 PNG 的完整处理峰值从约 362 MiB 降到约 89 MiB,大 JPEG 约 23 MiB;但真机整机占用还包含 KOReader 自身、字体和当前画面,200 MB 只是告警阈值,不是硬限制。
安装与验证
- 从本页 Assets 下载
opdsforcomic.koplugin.zip,解压出opdsforcomic.koplugin文件夹。 - 完全退出 KOReader,把整个文件夹覆盖到设备实际 KOReader 安装目录的
plugins/下。Kobo 通常为.adds/koreader/plugins/,Kindle 通常为koreader/plugins/。 - 重新启动 KOReader。日志中应出现
[perf-fixes 0.1.6]。
本版有 9 个 Lua 文件,请整体覆盖安装(0.1.5 只有 5 个);不要在旧目录上只替换部分文件。
验证包括独立代码审查、9 个 Lua 文件的 LuaJIT 加载检查,以及 10,699 项本地检查(含 5,938 项拆页回翻、3,211 项原生低内存解码像素断言与真实 ARM 图片库实测)。图像处理速度和整机内存仍取决于设备与源图。
已知边界:低内存路线只作用于黑白屏的 PNG / JPEG,彩色屏和其他图片格式保持原有行为,不等于所有格式都有统一的内存上限;进度按服务器源图保存,重新开章不保证恢复到同一半页。
0.1.6 — Low-memory reading on 512 MB readers, oversized images no longer fail
This release routes oversized spread scans on monochrome screens through a low-memory decoder: 9000×6480-class source images that used to fail to decode and consume a large amount of memory now stream and page back and forth normally. The 160 KB opdsforcomic_pse.lua is split into single-purpose modules, and the caches are re-sized with memory first.
Changes
- Low-memory decoding for oversized images (monochrome screens only): PNG/JPEG above roughly 8 megapixels take a new path — PNG decodes straight to grayscale with the device's own libpng and is then scaled natively by Leptonica; JPEG is scaled while decoding by TurboJPEG. A ~8-megapixel grayscale reading copy is kept. Fit-to-screen sharpness is unchanged; zooming in shows less detail than the original. Colour screens and ordinary sizes keep the old path.
- Caches re-sized with memory first: decoded whole pages and halves retain up to 8 MiB each and 16 MiB in total (was 32 / 64 MiB); compressed data targets an 8 MiB RAM budget and keeps at least two pages. This frees resident memory on 512 MB devices.
- Better failure semantics: on an allocation failure the already-downloaded raw data is kept and retried after a 10-second cooldown, instead of treating an out-of-memory failure as a corrupt image and downloading it again and again. Only a confirmed decode failure drops the data. The low-memory path never quietly falls back to the high-memory one, and exceeding the budget is reported explicitly.
- Modules split apart:
opdsforcomic_pse.luais divided by responsibility —opdsforcomic_perf(timing),opdsforcomic_worker(background prefetch subprocess),opdsforcomic_image(decoding in its own MuPDF context, with no intermediate full-size RGB copy) andopdsforcomic_lowmem(low-memory decoding). The plugin now ships 9 runtime Lua files, up from 5. - Background prefetching: the subprocess has byte and time ceilings, timeout preemption, file-descriptor and standby-lock reclaim and a circuit breaker; a temporary start failure backs off over 2 / 4 / 8 / 16 / 30 seconds.
- Chapter cache and progress refresh: switching chapters refreshes caches and progress by source page, and a redraw no longer cancels a prefetch in flight.
Measurements and trade-offs
- Tested on a 512 MB Kobo Aura One: chapters whose source images are 9000×6480-class now stream and page back and forth normally, with no placeholder pages and no out-of-memory notices, where the previous release failed to decode the same images.
- The cost is that every turn on such a source image waits for its decode: roughly 1.4 s for a ~22-megapixel image and 2.6 s for a ~59-megapixel one, about 1.5 – 4 s per turn including the fetch. The screen refresh itself is still in the 0.1 s range; the wait is the decode, and grows with the pixel count.
- These oversized images are not kept in the decoded cache (each visit decodes again) — a deliberate trade-off for memory.
- A whole-KOReader footprint below 200 MB cannot be promised. In an isolated ARM native test process the peak for a 9033×6480 PNG drops from about 362 MiB to about 89 MiB, and a large JPEG sits near 23 MiB; a real session also carries KOReader itself, fonts and the current screen. 200 MB is a warning threshold, not a hard limit.
Installation and validation
- Download
opdsforcomic.koplugin.zipfrom this release's Assets and extract theopdsforcomic.kopluginfolder. - Quit KOReader completely, then overwrite the plugin folder under the actual KOReader installation's
plugins/directory. Common locations are.adds/koreader/plugins/on Kobo andkoreader/plugins/on Kindle. - Restart KOReader. The log should show
[perf-fixes 0.1.6].
This release has 9 Lua files — overwrite the whole folder (0.1.5 had 5). Do not replace a subset of files in the old directory.
Validation includes independent code review, a LuaJIT load check on all 9 Lua files, and 10,699 local checks (5,938 reverse-navigation checks, 3,211 native low-memory decode pixel assertions, and real ARM image-library measurements). Image processing time and whole-device memory still depend on the device and the source images.
Known boundaries: the low-memory path applies to PNG / JPEG on monochrome screens only; colour screens and other image formats keep the old behaviour, and this is not a uniform memory ceiling for every format. Progress is saved by source image, so reopening may return to a different half of that image.
0.1.5
0.1.5 — 修复拆页回翻重复,完善续读、缓存和下载
本版修复开启“拆开双页扫描”后,阅读单页漫画时回翻可能需要点两次的问题,并包含续读、双页末尾、缓存与目录下载方面的修正。
更新内容
- 修复回翻重复:从中间续读或跳页后,反向进入尚未识别的单页源图时,立即校正页数和当前位置。原先可能出现
5 → 4 → 4 → 3 → 3,现在每次点击正确退一页;真正双页扫描的两个半页仍各占一屏。 - 续读直接加载目标页:打开章节时先加载记录的源页,减少先取首页再跳转的重复工作;同步校正自动旋转后的页码与初始进度条。
- 双页末尾与进度修正:“首页单独显示”开启时,偶数源页章节不再漏掉末页;关闭阅读器时按最后成功显示的源页补报进度,双页画面取后一张源页。
- 缓存与首次调色更稳:整页、半页解码缓存合计保留量限制为 64 MiB;远跳加载按目标源页淘汰压缩数据缓存;修复重启后首次调色的颜色空间初始化。
- 目录和邻章读取优化:目录改用 GET,并在服务器支持时利用 ETag / Last-Modified 条件请求;需要相邻章节时补取后续目录分页,减少已加载列表边界导致的邻章缺失。
- 下载失败和取消处理:先写临时文件,检查响应长度(服务器提供时)后再替换目标文件;失败保留原文件,取消后未确认完成的任务保留。下载保留单次网络等待时限,不限制总传输时长。
安装与验证
- 下载本页 Assets 中的
opdsforcomic.koplugin.zip,解压出opdsforcomic.koplugin文件夹。 - 完全退出 KOReader,覆盖安装到设备实际 KOReader 安装目录的
plugins/下。Kindle 通常为koreader/plugins/,Kobo 通常为.adds/koreader/plugins/。 - 重新启动 KOReader。可保持“拆开双页扫描”开启,打开单页漫画,从中间续读后连续回翻,检查每次点击是否只退一页。
本版通过独立代码 Review、15 个本地验证脚本(含 5938 项拆页回翻检查)及 LuaJIT 加载检查;相关 dev 版本已在 Kindle Scribe 上试用并反馈正常。具体图像处理速度和内存峰值仍取决于设备与源图。
拆页开关会保留到其他章节。阅读进度按服务器源图保存,重新开章不保证恢复到同一半页;64 MiB 是解码缓存保留量上限,不是进程内存峰值。
0.1.5 — Fix repeated pages on reverse turns and improve streaming reliability
This release fixes backward turns that could require two taps when reading single-page images with “Split two-page scans” enabled. It also improves resume loading, two-page boundaries, caching, catalog navigation and downloads.
Changes
- Fix repeated pages when turning back: after resuming or jumping, entering an unknown single-page image in reverse now corrects the screen count and current position immediately. Sequences such as
5 → 4 → 4 → 3 → 3become one page per turn. Each half of a genuine spread still gets its own screen. - Load the resume page directly: open the recorded source page first, avoiding the extra first-page load. Correct the initial page position and progress bar after automatic rotation.
- Fix the last page and progress in two-page mode: chapters with an even number of source pages retain their last page when “First page is cover” is enabled. Closing reports the last successfully displayed source page, using the latter source page of a two-page view.
- Improve caching and the first tone adjustment: decoded whole pages and halves share a 64 MiB retention budget; foreground jumps evict compressed data relative to the target page. Initialize the color space before the first tone adjustment after restarting.
- Improve catalogs and chapter navigation: use GET with ETag / Last-Modified conditional requests when supported. Fetch additional catalog pages when needed to find neighboring chapters beyond the loaded list.
- Handle interrupted downloads safely: write a temporary file, check the response length when supplied, then replace the destination. Failures retain the original file and cancellation retains unconfirmed tasks. Downloads keep a timeout for individual network waits without limiting total transfer duration.
Installation and validation
- Download
opdsforcomic.koplugin.zipfrom this release's Assets and extract theopdsforcomic.kopluginfolder. - Quit KOReader completely, then overwrite the plugin folder under the actual KOReader installation's
plugins/directory. Common locations arekoreader/plugins/on Kindle and.adds/koreader/plugins/on Kobo. - Restart KOReader. To check the fix, leave “Split two-page scans” enabled, resume a single-page comic in the middle and turn backwards: each tap should move back one page.
Validation includes independent code review, 15 local verification scripts with 5,938 reverse-navigation checks, and LuaJIT loading checks. The corresponding dev build was tried on a Kindle Scribe with a successful user report. Image processing time and peak memory usage still depend on the device and source images.
The split setting persists across chapters. Progress is saved by source image, so reopening may return to a different half of that image. The 64 MiB limit applies to retained decoded cache entries, not peak process memory.
SHA-256 (opdsforcomic.koplugin.zip): addaffe5b0925df4f77f1f4f0b1c518a98efa6088f9c23823a24c7292b1ff580
0.1.4
0.1.4 — 前光面板:长按「明暗」
本版只加一处操作:长按工具栏的「明暗」打开设备前光面板。阅读、翻页、超时、缓存这些都没动,0.1.3 的卡顿整改原样保留。
怎么用
工具栏上「明暗」这个按钮现在是两种亮度:
- 点 —— 调画面的明暗(gamma),和以前完全一样,扫描发白或太暗时用。
- 长按 —— 打开屏幕的前光面板:亮度滑条、开关,以及设备支持时的暖光。
之所以放在这里:这两件事用户心里的意图是同一条(「太暗了」),而工具栏上另外两个长按已经形成了规律——长按 = 同一类里更细的那一层(长按「旋转」→ 显示布局面板,长按「跳页」→ 章节列表,长按「明暗」→ 前光面板)。没有新增第 7 个按钮:图标库里没有灯泡或太阳的图样,而 6 个图标已经把工具栏铺满了。
一个面板,按机型自己适配
面板用的是 KOReader 自带的那个,不是插件自己画的。这不是省事,而是为了适配:面板自己会问设备「你有什么」,再决定显示什么,所以同一份代码能覆盖所有机型,也就不存在「按机型名写一堆分支」这种容易写错的做法。
| 设备能力 | 长按「明暗」会看到 |
|---|---|
| 没有前光 | 长按不生效(不会弹出一个滑不动的空面板) |
| 只有白光前光 | 亮度滑条 + 开关 |
| 带暖光的机型 | 再加一段暖光调节 |
| 可调色温的三色 LED(如 Kobo Aura One) | 再多一个 Configure,进去单独调白 / 红 / 绿三路 |
没有暖光的设备装上不会多出用不了的选项,这也是本版特意确认过的部分。
其它
- 覆盖安装后请完全退出 KOReader 再启动(插件改动不会热加载)。阅读进度和配置都在服务器上,不受影响。
0.1.4 — A frontlight panel on long press Tone
One new gesture in this release: long press Tone in the toolbar to open the device's frontlight panel. Nothing in the reading path changed — page fetches, turn speed, timeouts and caching are exactly as 0.1.3 left them.
How it works
The Tone button now does two kinds of brightness:
- Tap — the picture's brightness (gamma), unchanged, for washed-out or too-dark scans.
- Long press — the screen's frontlight: intensity slider, on/off, and warmth where the device has it.
It sits there because both are the same intent in the reader's head ("this is too dark"), and because the toolbar's other long presses already follow a rule — a long press is the finer layer of the same category (long press Rotate for display layout, long press Go to for the chapter list, long press Tone for the light). No seventh button was added: the icon set has no lamp or sun, and six icons already fill the bar.
One panel, adapted by the device itself
This uses KOReader's own frontlight panel rather than a hand-drawn one. That is not just less work — it is what makes it adapt: the panel asks the device what it has and builds only that, so a single code path covers every model instead of a pile of per-model branches that would be easy to get wrong.
| Device capability | What long press Tone gives you |
|---|---|
| No frontlight | The long press does nothing (rather than opening a slider that moves nothing) |
| Plain white frontlight | Intensity slider + on/off |
| A board with warmth | Plus the warmth control |
| Adjustable-temperature three-colour LEDs (e.g. Kobo Aura One) | Plus a Configure button for white / red / green separately |
A reader without warmth never grows a control it cannot use — that was a specific thing this release set out to confirm.
Misc
- After overwriting the plugin folder, quit KOReader completely and start it again — plugin changes are not hot-loaded. Reading progress and settings live on the server and are unaffected.
0.1.3
0.1.3 — 卡顿整改:超时收紧、断链熔断、整幅页缓存
本版不加新功能,只改卡顿和稳定性:界面、操作、配置都不变,变的是坏网络下屏幕死等的时间。
症状
服务器偶尔抖动时(不是每台设备、也不是每个网络都会遇到),点开一章会出现十几秒完全没反应——屏幕不动、翻页也不响应,过后又自己好了。查设备日志,一天里这类冻结累计 504 秒,来源很集中:
| 卡在哪 | 次数 × 每次时长 |
|---|---|
| 后台预取下一页 | 38 次 × 6 秒 |
| 翻页取图 | 13 次 × 15 秒 |
| 打开目录 / 章节列表 | 8 次 × 10 秒,而且每次都弹窗挡屏,得点掉才能继续 |
关键是这不是网卡的问题:日志里 refused、DNS 解析失败、HTTP 4xx/5xx 一次都没有,51 次失败全部是 timeout;其中 49 次(96%)在 3 分钟内同一个链接就成功了(最快 1 秒,中位数 9 秒)。所以触发是服务器抖动,放大成十几秒冻屏的是插件自己的超时值太宽——服务器不回答时,我们就在原地干等满 15 秒。
改了什么
- 取图超时 15 秒 → 8 秒。成功请求的最慢一次是 1874 ms、中位数 572 ms;15 秒对着 1.9 秒的最慢值,多出来的 13 秒纯粹白等。8 秒已经比正常慢一个数量级,误杀风险极低,真误杀了翻页也会重取。
- 目录 / 章节列表超时 10 秒 → 5 秒。这条路径原来不只慢,失败还会弹一个要点掉的提示框,连做章节导航时会一个接一个弹出来挡手。
- 预取超时 6 秒 → 3 秒。预取的是你还没翻到的页,卡在那里最不划算。
- 断链熔断换了判据:原来要「连续 3 次失败」才停止预取,可真实网络是「失败—失败—成功—失败」交替的,永远攒不满连续 3 次,熔断形同虚设。现在改成「60 秒内累计 ≥3 次」,攒够就停预取 45 秒,之后自动恢复。
- 整幅页也有缓存了(原先只有拆页模式切出来的半页有)。往回翻同一页不必再解一次码。
实测
在一条明显变差的网络上跑了一整段(一张 3 MB 的图要走 28.9 秒,比平时慢一个数量级),改动全部按要求生效:
- 取图卡在 8010 / 8002 / 8011 ms(原来会等到 15000)
- 目录失败每次 5 秒(原来 10 秒)
- 预取卡在 3008 / 3004 / 3068 ms(原来 6000)
- 熔断按新判据触发一次,撤下后能自动恢复(紧接着就又有了成功的预取)
- 整幅缓存命中 29 ms / 30 ms,而同样两页第一次渲染是 4620 ms / 3462 ms
网络正常时:「体验还行,很稳定,没有经历长时间的卡顿、白屏」。
已知限制(本版有意没动)
超时其实分两层:「传输中途卡住」由上面这些值管;「服务器一直在慢慢滴数据」由总超时管(取图 60 秒 / 预取 15 秒 / 目录 30 秒);还有更极端的一种——连接建好后一个字节都不来,只有连接层的总超时管得住。
本次实测最慢的一次成功取图是 28.9 秒,就在这些总超时之内。把总超时也调紧能再削掉这部分,但会让「慢慢滴、最终能出来」的页变成失败、需要手动重翻,属于体验取舍,本版保守起见没有动。如果你在特别慢的网络下仍觉得等待过长,欢迎反馈,再单独评估。
其它
- 顺带修了 6 处日志格式:
logger.info不是 printf,%d/%s会原样打进日志、值跟在后面。现在正常了,反馈问题时日志更好读。 - 覆盖安装后请完全退出 KOReader 再启动(插件改动不会热加载)。阅读进度和配置都在服务器上,不受影响。
0.1.3 — Making the stalls shorter: tighter timeouts, a link-failure breaker, whole-page caching
No new features in this release — only stalls and stability. Same UI, same gestures, same settings; what changes is how long the screen sits frozen on a flaky network.
The symptom
When the server occasionally hiccups (not every device, not every network), opening a chapter could leave the reader unresponsive for ten-odd seconds — screen frozen, page turns ignored — and then recover on its own. The log put the total at 504 seconds of freeze in one day, from three sources:
| Where it blocked | How often × how long |
|---|---|
| Background prefetch of the next pages | 38 × 6 s |
| Fetching a page you turned to | 13 × 15 s |
| Opening the catalog / chapter list | 8 × 10 s, each raising a modal that had to be dismissed |
The important part: this was not the network card. The log contains zero refused, zero name-resolution failures, zero HTTP 4xx/5xx — all 51 failures were timeout. And 49 of them (96%) succeeded on the same URL within three minutes (fastest 1 s, median 9 s). So the server hiccup was only the trigger; what turned it into a ten-second freeze was our own timeouts being far too generous — when the server went quiet, we stood there waiting out the full 15 seconds.
What changed
- Page fetch timeout 15 s → 8 s. The slowest successful request was 1874 ms, the median 572 ms — 15 s against a 1.9 s worst case means 13 seconds of pure waiting. 8 s is already an order of magnitude above normal, so killing a good request is very unlikely (and a page turn retries it anyway).
- Catalog / chapter list timeout 10 s → 5 s. On this path a failure did not just stall: it raised a modal dialog you had to tap away, so walking through chapters meant dismissing one after another.
- Prefetch timeout 6 s → 3 s. A prefetch is for a page you have not turned to yet, so blocking on it is the least defensible wait of the three.
- A new rule for the prefetch circuit breaker. It used to require three failures in a row, but real networks alternate — fail, fail, succeed, fail — so three consecutive failures essentially never accumulated and the breaker never fired. It is now three failures inside a 60-second window, after which prefetching stands down for 45 s and resumes by itself.
- Whole pages are cached too now (previously only the halves produced by split mode were). Turning back to a page no longer decodes it again.
Measured
On a visibly degraded network (a 3 MB page took 28.9 s — an order of magnitude slower than usual), every change behaved as designed:
- Page fetches capped at 8010 / 8002 / 8011 ms (previously they ran to 15000)
- Catalog failures took 5 s each (previously 10)
- Prefetches capped at 3008 / 3004 / 3068 ms (previously 6000)
- The breaker tripped once on the new rule and recovered on its own — a successful prefetch followed right after
- Whole-page cache hits at 29 ms / 30 ms, against 4620 ms / 3462 ms for those same pages' first render
On a normal network it behaved the ordinary way: stable, with no long freezes or blank screens.
Known limitation (deliberately left alone)
There are two layers here. A transfer that stalls part-way is bounded by the values above. A server that dribbles data slowly but keeps going is bounded instead by the total timeouts (fetch 60 s / prefetch 15 s / catalog 30 s). And in the most extreme case — connection established, then not a single byte arrives — only the connection layer's total bounds it.
The slowest successful fetch measured was 28.9 s, inside those totals. Tightening the totals as well would shave that too, but it would turn "slow but eventually delivers" pages into failures needing a manual re-turn — a real trade-off, so this release leaves them alone. If very slow networks still feel like too long a wait, tell us and we will look at it separately.
Misc
- Six log calls were fixed along the way:
logger.infois not printf, so%d/%swere landing in the log verbatim with the values trailing after them. Bug reports are readable now. - After overwriting the plugin folder, quit KOReader completely and start it again — plugin changes are not hot-loaded. Reading progress and settings live on the server and are unaffected.
0.1.2
0.1.2 — 章节导航(章末跳下一章 / 长按看前后五章)+ 「返回章节列表」修复
章末、章首都问一句
读到一章的最后一页再往后翻,弹窗问你要不要继续;第 1 页往回翻也会问(同一章 3 秒内只弹一次,不会被误触烦到)。
- 弹窗里章节名一并列出,并且「下一章 / 上一章」的标签标在名字前面,而不是按列表位置猜:
Suwayomi 的章节列表新章在前,你正在读的那一行上面那条其实是更晚的章节 —— 只写「上一章」
会在约一半的场合给你开错章节。 - 列表里点哪一章就直接开哪一章;「更多章节…」展开前后各 5 章。
长按「跳页」看前后各 5 章
底部工具栏长按「跳页」(放大镜图标),列出当前章前后各 5 章,按章节列表本来的顺序排,
当前这一章标成「正在阅读」(不可点,因为它已经开着了)。追连载时几页翻完一章的节奏很顺手。
「返回章节列表」修复
症状:从历史记录里点开一章 → 打开章节列表(长按跳页)→ 点「返回章节列表」,回到的是
历史记录而不是这本书的章节列表。
原因:这一章不是从这本书的列表里点开的,屏幕底下的列表停留的是历史记录 —— 那里也有这一章的
条目,但它的邻居是时间上的邻居,甚至可能是别的漫画。按钮承诺的是「这本书的章节列表」,
关掉阅读器露出来的却是历史记录。「点开的要么来自这本书的列表、要么来自历史记录」这个前提
在 0.1.1 之前不成立,当时的按钮也只是「关掉阅读器」而已。
修复:按钮现在会先在阅读器底下打开这本书的章节列表(这一步是阻塞抓取,而屏幕正被阅读器
盖着,谁都看不见),再关阅读器 —— 落地时正确的那份列表已经在那里了。从这本书自己的列表点开的
章节零请求、零变化,行为和以前逐字节相同。日志里也能区分这两条路:需要抓取时会打
Suwayomi series: fetched N chapter(s), P page(s) so far, from <url>;信任屏上列表时什么都不打。
其它
- 章节列表的判定是「屏上的 feed 自己说它是这本书的章节列表」才信任,否则默认去服务器抓;宁可多
一次请求,也不给错标签。 - 行为与 0.1.1 一致:章节直读、手机遥控、续读位置、自动裁剪、拆页、文件夹快捷方式、预取与两级缓存均不变。
0.1.2 — Chapter navigation, and "back to the chapter list" fixed
Asks at the end of a chapter — and at its start
Turning past a chapter's last page asks whether to carry on; turning back on its first page asks as well (once per chapter, every three seconds, so stray taps do not nag).
- The offered chapters are named, and the "Next / Previous chapter" label sits in front of the name rather than being guessed from the row's position: a Suwayomi list runs newest first, so the row above the one you are reading is the later chapter — a label-only "previous chapter" button would open the wrong chapter about half the time.
- Tapping a row opens that chapter directly; "More chapters…" widens the window to five chapters either way.
Long press Go to for five chapters either way
Long pressing the Go to icon (the magnifier) lists the five chapters on each side of the current one, in the chapter list's own order, with the current one marked as what you are reading (not tappable — it is already open). Handy when a chapter lasts a few pages.
"Back to chapter list" fixed
Symptom: open a chapter from History, open the chapter list (long press Go to), tap "Back to chapter list" — and land on History, not on this book's chapter list.
Cause: that chapter was not tapped in this book's list, so the list under the reader is History — which does contain the row, but its neighbours are temporal ones, possibly of another book. The button promises "this book's chapter list", yet closing the reader revealed History. The premise "the chapter came from either this book's list or History" held before 0.1.1, and the button was only ever "close the reader".
Fix: the button now opens this book's chapter list underneath the reader first — the fetch is blocking, but the reader covers the screen, so nobody sees it — and then closes the reader, so the correct list is already there when it lands. For a chapter tapped in this book's own list it stays zero-request and byte-for-byte identical to before. The logs tell the two paths apart: a fetch prints Suwayomi series: fetched N chapter(s), P page(s) so far, from <url>; trusting the list on screen prints nothing.
Misc
- The chapter list is trusted only when the feed on screen identifies itself as this book's chapter list; otherwise it is fetched from the server by default — one extra request beats a wrong label.
- Everything from 0.1.1 is unchanged: direct chapter reading, the phone remote, accurate resume, auto-crop, page splitting, the folder shortcut, prefetching and the two-level cache.
0.1.1
0.1.1 — Suwayomi 章节直读 + 手机遥控(翻页 / 旋转 / 全刷)+ 续读位置修复
Suwayomi 章节直读
点章节名直接进阅读器,不再先跳一层元数据页、再弹一次下载对话框。
- 效果:每章少两次点击,追连载时手感差别很明显。
- 只对 Suwayomi 生效(按链接形状识别)。Komga 和 KOReader 内置 OPDS 的流程完全不变。
手机遥控
配套项目:koreader_remote_turnpages —— 用手机当遥控器。
- 翻页:上一页 / 下一页(沿用 0.1.0)
- 旋转:遥控切换横竖屏。左手倒持看漫画时不用再把设备转回来。
- 全刷:手动消残影。墨水屏攒久了会留鬼影,这是唯一能一键清掉的办法。
这个键原来按下去完全没反应 —— 事件发出去了,但阅读界面里没有接收者,被静默丢掉。现在修好了。
遥控端不用改,用项目里现成的版本即可。
续读位置修复
症状:章节点开、看几页、退出去再进来,还是第一页;但退出插件再重进,记录又在了。
原因:服务器存的页码是从 0 数起的,写进去的时候减了 1,读回来的时候忘了加回去。所以每次都停在停止位置的前一页。停在章首附近时,「前一页」就是第 1 页,看起来就和完全没有记录一样。
效果:现在退出再进来,落在你实际停下的那一页。日志里也会同时打出服务器索引和实际落点(resume: catalog index 20, landed on source page 21),以后排查一眼就能看出对不对。
其它
- README 附上了配套遥控项目的链接。
- 行为与 0.1.0 一致:明暗档位阶梯、自动裁剪、拆页、文件夹快捷方式、预取与两级缓存均不变。
0.1.1 — Suwayomi chapters open directly, phone remote control, and a resume fix
Suwayomi chapters open directly
Tapping a chapter name now goes straight into the reader instead of showing a one-item metadata page and then a download dialog.
- Effect: two taps fewer per chapter — very noticeable when following an ongoing series.
- Suwayomi only (detected by link shape). Komga and KOReader's bundled OPDS are unchanged.
Phone remote control
Companion project: koreader_remote_turnpages — use a phone as the remote.
- Page turns: previous / next (as in 0.1.0)
- Rotate: portrait / landscape from the remote, so holding the reader left-handed no longer means turning the device back.
- Full refresh: clears e-ink ghosting on demand — the only one-tap way to do it. This button used to do nothing at all: the event was sent, but no widget in the reader received it and it was dropped silently. Fixed.
No change needed on the remote side; the released version works as-is.
Resume position fixed
Symptom: open a chapter, read a few pages, back out and re-enter — still page one. Exit the plugin and come back, though, and the position is there.
Cause: the page number the server stores is zero-based. The plugin subtracts one when writing it but never added it back when reading, so every resume landed one page before where you stopped. Near the front of a chapter that "one page back" is page one, which looks exactly like having no position at all.
Effect: reopening now lands on the page you actually stopped at. The log also prints both numbers (resume: catalog index 20, landed on source page 21) so any future mismatch is obvious at a glance.
Misc
- The README now links the companion remote project.
- Everything from 0.1.0 is unchanged: the tone ladder, auto-crop, page splitting, the folder shortcut, prefetching and the two-level cache.
0.1.0
0.1.0 — 远程翻页 + 实体键翻页 + 左手倒持
翻页
- 远程控制翻页:支持 KOReader 远程控制(如局域网翻页器)的翻页事件——上一页 / 下一页 / 跳到指定屏。
- 实体键翻页:Kindle / Kobo 的物理翻页键可以翻页了,翻页方向跟随阅读位置。
左手倒持
- 显示面板(长按「旋转」)新增 「倒置 180°(左手)」 开关:
- 开启后整个画面旋转 180°,方便左手握持(握住设备时屏幕内容始终正向);
- 实体翻页键自动对调(倒过来握时按键方向跟随画面),不需要额外设置;
- 关闭阅读界面时自动恢复,文件管理器不受影响。
其它
- 行为与 0.0.9 一致:明暗档位阶梯、自动裁剪、拆页、文件夹快捷方式、预取与两级缓存均不变。
0.1.0 — Remote page turns, hardware keys, and left-hand hold
Page turns
- Remote controls: the page-turn events used by KOReader remote * controls (e.g. a LAN page-turner) now work — previous / next / jump to a given screen.
- Hardware keys: physical page-turn buttons on Kindle / Kobo turn the page, in the direction you are reading.
Left-hand hold
- New "Upside down (left hand)" switch in the display panel (long-press Rotate):
- Flips the whole display 180° for holding in the left hand — the content stays upright in your hand;
- The physical page-turn keys swap automatically along with the flip (no extra setup);
- Restored when the viewer closes, so the file manager is unaffected.
Misc
- Everything from 0.0.9 is unchanged: the tone ladder, auto-crop, page splitting, the folder shortcut, prefetching and the two-level cache.
0.0.9
0.0.9 — 图标工具栏 + 明暗档位阶梯
阅读界面
- 底部按钮换成图标工具栏(和 KOReader 自带阅读器一致),新增 明暗(Tone)按钮,JPEG / PNG / GIF / WebP / SVG 都支持。
明暗档位阶梯
- 0.5 ~ 0.9:提亮,步长 0.1(提亮很敏感,细一点)
- 1.0:原样
- 2 ~ 10:加深,步长 1.0(小幅加深在墨水屏上看不出来,粗一点)
- 对话框里加了「恢复原样 1.0」按钮;关闭时值没变不再重复渲染整页。
修复
- 明暗开到 4 及以上时,自动裁剪会静默失效(白边掉进墨迹阈值,整页被判成有内容)。上色已挪到裁剪量测之后,现在 gamma 10 + 自动裁剪可以同时开(真机验证)。
其它
- README 顶部加了实机截图。
- 预取 / 两级缓存 / 拆页 / 文件夹快捷方式行为不变。
0.0.9 — Icon toolbar and a tone ladder
Reading view
- The bottom row is now an icon toolbar (matching KOReader's own readers), with a new Tone button. JPEG / PNG / GIF / WebP / SVG.
The tone ladder
- 0.5 – 0.9 brightens, in 0.1 steps (brightening shows at once, so it is fine-grained)
- 1.0 untouched
- 2 – 10 darkens, in 1.0 steps (small gamma changes are invisible on e-ink, so it is coarse)
- A "Back to 1.0" button, and closing the dialog without changing the value no longer re-renders the page.
Fix
- At gamma 4 and above auto-crop silently stopped working (the page's own white margin fell under the ink threshold and the whole page read as content). Toning now runs after the crop measurement, so gamma 10 and auto-crop work together (verified on device).
Misc
- Real device screenshots at the top of the README.
- Prefetching, the two-level cache, split mode and the folder shortcut behave as before.
0.0.8
做了什么
这一版没有改阅读路径,性能和 0.0.7 完全一样。只加了一个入口,并把 README 精简了。
新增:文件夹里的快捷方式
在任意文件夹里放一个空文件,文件名随意、扩展名用 .opdscomic:
你的漫画文件夹/
├── OPDS for Comic.opdscomic ← 空文件,点它就进 OPDS 界面
├── 第 01 卷.cbz
└── 第 02 卷.cbz
点它就直接进入 OPDS 界面,不用再走「文件管理器 → 扳手 → 搜索 → OPDS catalog (Comic)」那几步。
- 文件内容不会被读取,留空即可(写什么也不影响)。
- 改名不会失效:扩展名才是机制,名字只是你自己认它的标记。中文、符号、长短都行。
- 想放几层目录、放几个都可以。它就是一个普通文件,随便复制移动删除。
- 在文件浏览器里长这样:和其它文件一样的普通一行,没有图标。这是 KOReader 列表模式本来的样子(见下面「已知限制」)。
为什么没有「生成快捷方式」的按钮? 因为这件事每台设备只做一次,任何菜单里都为它占一行不划算——先在文件管理器菜单里试过,又在插件自己的菜单里试过,最后都去掉了。建一个空文件比点菜单快。
实现上它没有碰 KOReader 本体。 KOReader 的 provider 机制里,带 order 字段的 provider 会被当作「辅助的」——FileManager:openFile 不会去建一个阅读界面,而是直接回调插件自己的方法。本插件注册 .opdscomic 这个扩展名(全树无占用),于是这个文件能被文件浏览器认出来、并被算作可打开,点击就落到插件的 openFile。同一条路也是 KOReader 自带的 archiveviewer、texteditor 打开自己文件类型的方式。
README 从 696 行精简到 112 行
只留功能与安装。工作原理、缓存调参、日志解读、已知限制、以及整份更新日志全部移出——它们本来就在每个版本的 Release 说明里,README 里重复一遍只是让人不想读。README 末尾留了一个指向 Releases 的入口。
安装
解压后得到 opdsforcomic.koplugin 文件夹——名字已经是对的,不需要重命名。整个放进 KOReader 的 plugins/ 目录(Kobo 是 .adds/koreader/plugins/),完全退出 KOReader 再启动。
已知限制
- 快捷方式的外观无法定制。 列表模式(经典)没有按文件类型给图标,那一行只有文件名和右侧的大小/日期,所以「标记」只能是文件名本身。封面模式(mosaic / 带缩略图的列表)由
coverbrowser处理:它会试着把这个文件当书打开,失败后标记为「引擎读不了」并且不再重试,因此拿不到封面,也没有受支持的途径塞一个进去。唯一能绕过的办法是伪造一个文档对象骗过封面提取,但那会让这个文件在所有查询文档注册表的地方都变成「一本可读的书」(页数、历史、最近阅读都算上),为一个装饰不值得,没做。 - 整页(横屏看跨页,或关掉拆页)没有任何缓存。 凡是把当前屏整个重算的操作——改设置、转屏——都要重新解码整张,实测约 0.88 s 一次。半页那套缓存在这里用不上:整页就是解码出来的那张本身,旁边没有「另一半」可以顺手留下。这是目前已知最大的一块可优化项,仍未处理
- 拆页模式下最贵的是第一次打开一张跨页:要整张解码才能知道它是不是跨页、才能切半(约 0.6 s 解码 + 约 0.55 s 切半与裁剪)。第二半、往回翻、设置来回切都由缓存接下(约 0.14 s)
- 扫描时就转了 90° 的单页也是横的,会被切开。本地没有任何信息能把它和跨页区分开,解法只能是把这个开关关掉
- 预取仍是阻塞式的:KOReader 没有线程池,预取在主线程执行,最坏卡顿上限 15 秒
- 未实现 HTTP 连接复用:LuaSocket 硬编码
Connection: close, TE且无条件重连
0.0.7
做了什么
这一版没有新功能,屏幕上显示的东西也不变。只做一件事:已经看过的一屏,不该再解码一次。
起因是一次真机日志:11 分钟、43 次渲染里,有 10.1 秒花在「同一张图被重复解码」上。其中最极端的一张半页被解码了 5 次,每次都要把整张 12.6 Mpx 的跨页重新解开。
半页缓存:从一张到三张,并且把正在显示的那一半也留下
拆页模式下,渲染一半时顺手把两半都切好留着,下一屏直接用——这个机制 0.0.6 就有了。但它只留一张,而且只留「读者旁边那一张」,于是有两种情况必然重解码:
| 想回到哪一屏 | 0.0.6 | 0.0.7 |
|---|---|---|
| 往后翻(跨页的后半) | 命中,约 0.14 s | 命中,约 0.14 s |
| 往回翻(跨页的前半) | 重解码,约 1.3 s | 命中,约 0.14 s |
| 改了设置再回到同一屏(旋转 / 拆页 / 双页 / 阅读方向) | 重解码,约 1.3 s | 命中,约 0.14 s |
两处都改掉了:正在显示的那一半在交给阅读器之前也复制一份进缓存(代价是每次跨页渲染多一次复制,实测约 0.12 s,日志里记为 keep),缓存容量从一张提到三张,按最近使用淘汰。
三这个数是推导出来的,不是拍出来的:站在任一半页上,能一步到达的屏只有三张——前面那一张、后面那一张,加上当前这张。所以三张覆盖所有方向;四张只是白占内存。
拆页渲染:切半和裁剪合并成一次拷贝
以前一次半页渲染是四趟拷贝:先把左半切出来、右半切出来,再各按裁剪框裁一次。同样一块像素搬两遍。
裁剪框一旦量过就会缓存下来,所以从第二次渲染起,可以直接从整张跨页裁到最终那一块——两趟。实测省下约 0.26 s。首次渲染仍要两趟(裁剪框是在切出来的那一半上量出来的,必须先有东西可量),但结果会存下来。日志行末标 (fused clip) 表示走了这条路。
修掉切「从右到左」之后修剪用错框
半页的裁剪框按「第几半」编号缓存,而切换阅读方向会改变这个编号指的是左半还是右半——于是切过去之后,会拿另一半量出来的框去裁当前这一半。现在切方向时一并清掉半页的裁剪框缓存(整页的不清,整张图不随方向移动)。
这个 bug 一直存在,只是要恰好在中途切方向、且开着自动裁剪才会看到。
日志:现在能看出卡顿是谁要的
- 渲染那行从三段计时扩到四段:
decode/cut/crop/keep(为缓存复制半页的耗时)。 - 新增
reload:行,记下每次「把当前屏整个重算」是谁要求的(改裁剪、拆页、双页、方向、旋转)。此前这些改动全是静默的——上面那 10.1 秒就是因为没有这一行而无法归因。
安装
解压后得到 opdsforcomic.koplugin 文件夹——名字已经是对的,不需要重命名。整个放进 KOReader 的 plugins/ 目录(Kobo 是 .adds/koreader/plugins/),完全退出 KOReader 再启动。
代价:常驻内存约 15 MB → 约 47 MB
缓存三张半页,每张是全分辨率的 24 位缓冲区,本机实测约 15 MB,所以多留两张就是多约 31 MB 常驻。加上一次跨页渲染时短暂存在的整张(约 36 MB)和两个未裁剪半页(各约 18 MB),单次渲染的瞬时峰值约 141 MB 的解码缓冲,而 KOReader 自身在读了一段时间漫画后通常占 30–140 MB。
在 512 MB 的设备上这仍然够用(KOReader 核心开发者给的经验值是涨到 200–300 MB 都没问题,超过 300–400 才开始崩),而且这次改动在一次会话里净省约 1.6 秒(付 0.82 s 的复制,换回 2.4 s 的重解码)。
如果你遇到内存告警,把 opdsforcomic_pse.lua 里的 STASH_DEPTH 从 3 调小(2 或 1)即可,其余逻辑不需要动。
已知限制
- 整页(横屏看跨页,或关掉拆页)没有任何缓存。 凡是把当前屏整个重算的操作——改设置、转屏——都要重新解码整张,实测约 0.88 s 一次。半页那套缓存在这里用不上:整页就是解码出来的那张本身,旁边没有「另一半」可以顺手留下。这是目前已知最大的一块可优化项,本次未处理
- 拆页模式下最贵的是第一次打开一张跨页:要整张解码才能知道它是不是跨页、才能切半(约 0.6 s 解码 + 约 0.55 s 切半与裁剪)。第二半、往回翻、设置来回切现在都由缓存接下
- 扫描时就转了 90° 的单页也是横的,会被切开。本地没有任何信息能把它和跨页区分开,解法只能是把这个开关关掉
- 预取仍是阻塞式的:KOReader 没有线程池,预取在主线程执行,最坏卡顿上限 15 秒。彻底的解法是分片非阻塞下载,尚未实现
- 未实现 HTTP 连接复用:LuaSocket 硬编码
Connection: close, TE且无条件重连