3003h / Eros-FE

An e-hentai/exhentai app make on flutter
Apache License 2.0
2.83k stars 125 forks source link

Fix pre cache logic #306

Closed wh201906 closed 11 months ago

wh201906 commented 11 months ago

The first batch of images won't be cached since v1.4.9. This PR fixes this bug.

Logcat output before this fix (filtered with `package:com.honjow.fehviewer & (message:!!! | message:ser | message:showKey)`) ``` 2023-11-25 23:52:27.410 flutter com.honjow.fehviewer I │ [D] fetchImage ser:1 2023-11-25 23:52:27.464 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 1 2023-11-25 23:52:27.464 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): _processingSerSet contains ser. ser: 1 2023-11-25 23:52:27.464 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 2 2023-11-25 23:52:27.464 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): _processingSerSet contains ser. ser: 2 2023-11-25 23:52:27.464 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 3 2023-11-25 23:52:27.464 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): _processingSerSet contains ser. ser: 3 2023-11-25 23:52:27.465 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 4 2023-11-25 23:52:27.465 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): _processingSerSet contains ser. ser: 4 2023-11-25 23:52:27.465 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 5 2023-11-25 23:52:27.465 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): _processingSerSet contains ser. ser: 5 2023-11-25 23:52:27.468 flutter com.honjow.fehviewer I │ #1 GalleryPageController.fetchAndParserImageInfo (package:fehviewer/pages/gallery/controller/gallery_page_controller.dart:600:46) 2023-11-25 23:52:27.468 flutter com.honjow.fehviewer I │ [W] OOOOOOOld : showKey null, sourceId , isMpv false 2023-11-25 23:52:27.468 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 2 2023-11-25 23:52:27.468 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): _processingSerSet contains ser. ser: 2 2023-11-25 23:52:27.469 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 3 2023-11-25 23:52:27.469 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): _processingSerSet contains ser. ser: 3 2023-11-25 23:52:27.469 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 4 2023-11-25 23:52:27.469 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): _processingSerSet contains ser. ser: 4 2023-11-25 23:52:27.469 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 5 2023-11-25 23:52:27.469 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): _processingSerSet contains ser. ser: 5 2023-11-25 23:52:27.469 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 6 2023-11-25 23:52:27.470 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): _processingSerSet contains ser. ser: 6 2023-11-25 23:52:27.983 flutter com.honjow.fehviewer I │ #0 paraImage (package:fehviewer/common/parser/image_page_parser.dart:66:10) 2023-11-25 23:52:27.983 flutter com.honjow.fehviewer I │ [W] paraImage(): showKey hnwsjdsa4kf 2023-11-25 23:52:42.822 flutter com.honjow.fehviewer I │ [D] fetchImage ser:2 2023-11-25 23:52:42.830 flutter com.honjow.fehviewer I │ #1 GalleryPageController.fetchAndParserImageInfo (package:fehviewer/pages/gallery/controller/gallery_page_controller.dart:600:46) 2023-11-25 23:52:42.838 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 3 2023-11-25 23:52:42.838 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): _processingSerSet contains ser. ser: 3 2023-11-25 23:52:42.838 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 4 2023-11-25 23:52:42.838 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): _processingSerSet contains ser. ser: 4 2023-11-25 23:52:42.838 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 5 2023-11-25 23:52:42.838 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): _processingSerSet contains ser. ser: 5 2023-11-25 23:52:42.839 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 6 2023-11-25 23:52:42.839 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): _processingSerSet contains ser. ser: 6 2023-11-25 23:52:42.839 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 7 2023-11-25 23:52:42.915 flutter com.honjow.fehviewer I │ [W] 页码切换时的回调 预载图片 showKey: hnwsjdsa4kf 2023-11-25 23:52:42.922 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 2 2023-11-25 23:52:42.922 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): _processingSerSet contains ser. ser: 2 2023-11-25 23:52:42.923 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 3 2023-11-25 23:52:42.923 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): _processingSerSet contains ser. ser: 3 2023-11-25 23:52:42.923 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 4 2023-11-25 23:52:42.923 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): _processingSerSet contains ser. ser: 4 2023-11-25 23:52:42.923 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 5 2023-11-25 23:52:42.923 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): _processingSerSet contains ser. ser: 5 2023-11-25 23:52:42.923 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 6 2023-11-25 23:52:42.924 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): _processingSerSet contains ser. ser: 6 2023-11-25 23:53:05.581 flutter com.honjow.fehviewer I │ [D] fetchImage ser:3 2023-11-25 23:53:05.589 flutter com.honjow.fehviewer I │ #1 GalleryPageController.fetchAndParserImageInfo (package:fehviewer/pages/gallery/controller/gallery_page_controller.dart:600:46) 2023-11-25 23:53:05.593 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 4 2023-11-25 23:53:05.593 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): _processingSerSet contains ser. ser: 4 2023-11-25 23:53:05.594 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 5 2023-11-25 23:53:05.594 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): _processingSerSet contains ser. ser: 5 2023-11-25 23:53:05.594 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 6 2023-11-25 23:53:05.594 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): _processingSerSet contains ser. ser: 6 2023-11-25 23:53:05.595 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 7 2023-11-25 23:53:05.595 flutter com.honjow.fehviewer I │ [D] ser 7 已预载完成 跳过 2023-11-25 23:53:05.595 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 8 2023-11-25 23:53:05.678 flutter com.honjow.fehviewer I │ [W] 页码切换时的回调 预载图片 showKey: hnwsjdsa4kf 2023-11-25 23:53:05.680 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 3 2023-11-25 23:53:05.680 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): _processingSerSet contains ser. ser: 3 2023-11-25 23:53:05.681 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 4 2023-11-25 23:53:05.681 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): _processingSerSet contains ser. ser: 4 2023-11-25 23:53:05.681 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 5 2023-11-25 23:53:05.682 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): _processingSerSet contains ser. ser: 5 2023-11-25 23:53:05.682 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 6 2023-11-25 23:53:05.682 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): _processingSerSet contains ser. ser: 6 2023-11-25 23:53:05.683 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 7 2023-11-25 23:53:05.683 flutter com.honjow.fehviewer I │ [D] ser 7 已预载完成 跳过 2023-11-25 23:53:18.374 flutter com.honjow.fehviewer I │ [D] fetchImage ser:4 2023-11-25 23:53:18.379 flutter com.honjow.fehviewer I │ #1 GalleryPageController.fetchAndParserImageInfo (package:fehviewer/pages/gallery/controller/gallery_page_controller.dart:600:46) 2023-11-25 23:53:18.381 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 5 2023-11-25 23:53:18.381 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): _processingSerSet contains ser. ser: 5 2023-11-25 23:53:18.381 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 6 2023-11-25 23:53:18.382 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): _processingSerSet contains ser. ser: 6 2023-11-25 23:53:18.382 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 7 2023-11-25 23:53:18.382 flutter com.honjow.fehviewer I │ [D] ser 7 已预载完成 跳过 2023-11-25 23:53:18.382 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 8 2023-11-25 23:53:18.382 flutter com.honjow.fehviewer I │ [D] ser 8 已预载完成 跳过 2023-11-25 23:53:18.383 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 9 2023-11-25 23:53:18.496 flutter com.honjow.fehviewer I │ [W] 页码切换时的回调 预载图片 showKey: hnwsjdsa4kf 2023-11-25 23:53:18.503 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 4 2023-11-25 23:53:18.504 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): _processingSerSet contains ser. ser: 4 2023-11-25 23:53:18.504 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 5 2023-11-25 23:53:18.504 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): _processingSerSet contains ser. ser: 5 2023-11-25 23:53:18.504 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 6 2023-11-25 23:53:18.504 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): _processingSerSet contains ser. ser: 6 2023-11-25 23:53:18.504 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 7 2023-11-25 23:53:18.504 flutter com.honjow.fehviewer I │ [D] ser 7 已预载完成 跳过 2023-11-25 23:53:18.505 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 8 2023-11-25 23:53:18.505 flutter com.honjow.fehviewer I │ [D] ser 8 已预载完成 跳过 ```

(ser 2~6 are always uncached)

Logcat output after this fix (filtered with `package:com.honjow.fehviewer & (message:!!! | message:ser | message:showKey)`) ``` 2023-11-26 00:04:24.133 flutter com.honjow.fehviewer I │ [D] fetchImage ser:1 2023-11-26 00:04:24.249 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 1 2023-11-26 00:04:24.249 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): showKey is null, skip precache. ser: 1 2023-11-26 00:04:24.249 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 2 2023-11-26 00:04:24.250 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): showKey is null, skip precache. ser: 2 2023-11-26 00:04:24.250 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 3 2023-11-26 00:04:24.250 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): showKey is null, skip precache. ser: 3 2023-11-26 00:04:24.250 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 4 2023-11-26 00:04:24.250 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): showKey is null, skip precache. ser: 4 2023-11-26 00:04:24.250 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 5 2023-11-26 00:04:24.250 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): showKey is null, skip precache. ser: 5 2023-11-26 00:04:24.404 flutter com.honjow.fehviewer I │ #1 GalleryPageController.fetchAndParserImageInfo (package:fehviewer/pages/gallery/controller/gallery_page_controller.dart:600:46) 2023-11-26 00:04:24.404 flutter com.honjow.fehviewer I │ [W] OOOOOOOld : showKey null, sourceId , isMpv false 2023-11-26 00:04:24.405 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 2 2023-11-26 00:04:24.406 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): showKey is null, skip precache. ser: 2 2023-11-26 00:04:24.407 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 3 2023-11-26 00:04:24.408 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): showKey is null, skip precache. ser: 3 2023-11-26 00:04:24.408 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 4 2023-11-26 00:04:24.409 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): showKey is null, skip precache. ser: 4 2023-11-26 00:04:24.409 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 5 2023-11-26 00:04:24.409 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): showKey is null, skip precache. ser: 5 2023-11-26 00:04:24.409 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 6 2023-11-26 00:04:24.409 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): showKey is null, skip precache. ser: 6 2023-11-26 00:04:25.078 flutter com.honjow.fehviewer I │ #0 paraImage (package:fehviewer/common/parser/image_page_parser.dart:66:10) 2023-11-26 00:04:25.078 flutter com.honjow.fehviewer I │ [W] paraImage(): showKey k3uu882a4kg 2023-11-26 00:04:37.550 flutter com.honjow.fehviewer I │ [D] fetchImage ser:2 2023-11-26 00:04:37.566 flutter com.honjow.fehviewer I │ #1 GalleryPageController.fetchAndParserImageInfo (package:fehviewer/pages/gallery/controller/gallery_page_controller.dart:600:46) 2023-11-26 00:04:37.570 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 3 2023-11-26 00:04:37.664 flutter com.honjow.fehviewer I │ [W] 页码切换时的回调 预载图片 showKey: k3uu882a4kg 2023-11-26 00:04:37.668 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 2 2023-11-26 00:04:41.950 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 3 2023-11-26 00:04:41.998 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 4 2023-11-26 00:04:43.138 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 4 2023-11-26 00:04:43.138 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): _processingSerSet contains ser. ser: 4 2023-11-26 00:04:43.138 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 5 2023-11-26 00:04:47.023 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 5 2023-11-26 00:04:47.374 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 6 2023-11-26 00:04:47.962 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 6 2023-11-26 00:04:47.963 flutter com.honjow.fehviewer I │ [W] !!!:ehPrecacheImages(): _processingSerSet contains ser. ser: 6 2023-11-26 00:04:47.963 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 7 2023-11-26 00:04:52.717 flutter com.honjow.fehviewer I │ [D] fetchImage ser:3 2023-11-26 00:04:52.726 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 4 2023-11-26 00:04:52.726 flutter com.honjow.fehviewer I │ [D] ser 4 已预载完成 跳过 2023-11-26 00:04:52.727 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 5 2023-11-26 00:04:52.727 flutter com.honjow.fehviewer I │ [D] ser 5 已预载完成 跳过 2023-11-26 00:04:52.727 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 6 2023-11-26 00:04:52.727 flutter com.honjow.fehviewer I │ [D] ser 6 已预载完成 跳过 2023-11-26 00:04:52.727 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 7 2023-11-26 00:04:52.727 flutter com.honjow.fehviewer I │ [D] ser 7 已预载完成 跳过 2023-11-26 00:04:52.727 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 8 2023-11-26 00:04:52.804 flutter com.honjow.fehviewer I │ [W] 页码切换时的回调 预载图片 showKey: k3uu882a4kg 2023-11-26 00:04:52.805 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 3 2023-11-26 00:04:52.805 flutter com.honjow.fehviewer I │ [D] ser 3 已预载完成 跳过 2023-11-26 00:04:52.805 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 4 2023-11-26 00:04:52.805 flutter com.honjow.fehviewer I │ [D] ser 4 已预载完成 跳过 2023-11-26 00:04:52.806 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 5 2023-11-26 00:04:52.806 flutter com.honjow.fehviewer I │ [D] ser 5 已预载完成 跳过 2023-11-26 00:04:52.806 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 6 2023-11-26 00:04:52.806 flutter com.honjow.fehviewer I │ [D] ser 6 已预载完成 跳过 2023-11-26 00:04:52.806 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 7 2023-11-26 00:04:52.806 flutter com.honjow.fehviewer I │ [D] ser 7 已预载完成 跳过 2023-11-26 00:04:56.667 flutter com.honjow.fehviewer I │ [D] fetchImage ser:4 2023-11-26 00:04:56.677 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 5 2023-11-26 00:04:56.677 flutter com.honjow.fehviewer I │ [D] ser 5 已预载完成 跳过 2023-11-26 00:04:56.677 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 6 2023-11-26 00:04:56.677 flutter com.honjow.fehviewer I │ [D] ser 6 已预载完成 跳过 2023-11-26 00:04:56.677 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 7 2023-11-26 00:04:56.677 flutter com.honjow.fehviewer I │ [D] ser 7 已预载完成 跳过 2023-11-26 00:04:56.677 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 8 2023-11-26 00:04:56.678 flutter com.honjow.fehviewer I │ [D] ser 8 已预载完成 跳过 2023-11-26 00:04:56.678 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 9 2023-11-26 00:04:56.767 flutter com.honjow.fehviewer I │ [W] 页码切换时的回调 预载图片 showKey: k3uu882a4kg 2023-11-26 00:04:56.770 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 4 2023-11-26 00:04:56.770 flutter com.honjow.fehviewer I │ [D] ser 4 已预载完成 跳过 2023-11-26 00:04:56.771 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 5 2023-11-26 00:04:56.771 flutter com.honjow.fehviewer I │ [D] ser 5 已预载完成 跳过 2023-11-26 00:04:56.771 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 6 2023-11-26 00:04:56.772 flutter com.honjow.fehviewer I │ [D] ser 6 已预载完成 跳过 2023-11-26 00:04:56.772 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 7 2023-11-26 00:04:56.772 flutter com.honjow.fehviewer I │ [D] ser 7 已预载完成 跳过 2023-11-26 00:04:56.773 flutter com.honjow.fehviewer I │ [D] 开始预载 ser 8 2023-11-26 00:04:56.773 flutter com.honjow.fehviewer I │ [D] ser 8 已预载完成 跳过 ```

(Only ser 2 is not cached)


This bug is caused by the continue between _processingSerSet.add() and _processingSerSet.remove(), which should always be called in pairs.

honjow commented 11 months ago

thanks