MapoMagpie / eh-view-enhance

Manga Viewer + Downloader, Focus on experience and low load on the site. Support: e-hentai.org | exhentai.org | pixiv.net | 18comic.vip | nhentai.net | hitomi.la | rule34.xxx | danbooru.donmai.us | gelbooru.com | twitter.com
MIT License
264 stars 8 forks source link

浏览时经常出现的报错,没有功能异常 #49

Closed kakuri2020 closed 4 months ago

kakuri2020 commented 4 months ago

Describe the bug A clear and concise description of what the bug is. 在此处描述问题 功能都正常,就是在调试的时候经常能看到类似的error 我使用的是 continuous 模式

Browser And Version Which Browser Do You Use? And Browser Version 你使用什么浏览器与版本? chrome 124.0.6367.60(正式版本) (64 位)

Log Press F12, Open Browser Console. Export or Copy Console Log. 打开浏览器控制台,导出或复制控制台日志,粘贴到此处。

Uncaught TypeError: Cannot read properties of undefined (reading 'offsetTop')
    at BigImageFrameManager.getRealOffsetTop (ultra-image-frame-manager.ts:395:20)
    at ultra-image-frame-manager.ts:382:29
    at Debouncer.addEvent (debouncer.ts:16:9)
    at BigImageFrameManager.consecutive (ultra-image-frame-manager.ts:355:20)
    at BigImageFrameManager.onScroll (ultra-image-frame-manager.ts:307:12)
    at frame.addEventListener.signal (ultra-image-frame-manager.ts:156:54)

Screenshots If applicable, add screenshots to help explain your problem. 如果可以,请提供安全的图片 image

MapoMagpie commented 4 months ago

应该是因为

      // delay to reduce the image element in big image frame;
      this.debouncer.addEvent("REDUCE", () => {
        const distance = this.getRealOffsetTop(this.elements.curr[0]!) - this.frame.scrollTop;
        if (this.tryReduce()) {
          this.restoreScrollTop(this.elements.curr[0]!, distance);
        }
      }, 500);

这里有个500毫秒后,移除视图外的大图的功能。 如果在500毫秒内退出了大图阅读模式,由于所有的大图都已经被删除了(this.hidden > this.resetElements)。 所以最后在这个功能被延迟执行的时候,this.elements.curr[0]!是undefind的,就报错了。(this.elements.curr[0]就是大图视图中最中心的图片) 这个移除视图外大图的功能,是为了防止太多的大图留在页面,增加渲染压力。(我猜的)

MapoMagpie commented 4 months ago

我再想想有什么更好的方式来提升性能,现在图片多了后会增加数倍的内存占用。

MapoMagpie commented 4 months ago

65c32f386026d1714f335821e39cb2dfe3407311