Conversation
| self._bb = _bb | ||
| else | ||
| -- Icon is from https://freesvg.org/tango-system-search-icon-vector-drawing | ||
| self._bb = RenderImage:renderImageFile("resources/icons/system-search.svg", false, 200, 200) |
There was a problem hiding this comment.
We already have a magnifying glass icon ;).
|
I'm not sure I necessarily like returning nil in bb:copy and delaying the crash, but, eeeeh. (Also: / 1024 ;)). |
I also don't like that (as I don't like crashes at all). But I think the danger for crashes from that side are not so big (at least I haven't seen that assertion up to now.) And we have the source of the crash in the log. BTW: Is it a good choice to use
No problem, but then "KiB" :p |
| self._bb = RenderImage:scaleBlitBuffer(self._bb, bb_w * self.scale_factor, bb_h * self.scale_factor, self._bb_disposable) | ||
| local _bb = RenderImage:scaleBlitBuffer(self._bb, bb_w * self.scale_factor, bb_h * self.scale_factor, self._bb_disposable) | ||
| if _bb then | ||
| self._bb = _bb | ||
| else | ||
| self._bb = RenderImage:renderImageFile("resources/icons/src/appbar.magnify.zoom.svg", false, 200, 200) | ||
|
|
||
| local InfoMessage = require("ui/widget/infomessage") | ||
| UIManager:show(InfoMessage:new{ | ||
| show_icon = true, | ||
| text = _("Maximum zoom reached. Please zoom out again."), | ||
| }) | ||
| end | ||
|
|
There was a problem hiding this comment.
The blank lines are a bit uneeded (they are used in the outer context to separate steps - no need to add them here as there are not really steps of processing).
Also, I'm not sure it's really needed for such a low level ImageWidget to use UIManager:show(InfoMessage).
I would either:
- have a .svg with that message or symbol :)
- or just keep using any previous self._bb : the user will continue trying to zoom in and see nothing changeing, and will guess maximum zoom is reached.
If going with the first solution, cleaner to not use local _bb:
self._bb = RenderImage...
+ if not self._bb then
+ -- couldn't make a bb: probably not enough memory for such a large bb
+ self._bb = RenderImage:renderImageFile("resources/icons/src/appbar.magnify.zoom.svg", false, 200, 200)
+ endThere was a problem hiding this comment.
Also, I'm not sure it's really needed for such a low level ImageWidget to use UIManager:show(InfoMessage). I would either:
* have a .svg with that message or symbol :)
Good point.
* or just keep using any previous self._bb : the user will continue trying to zoom in and see nothing changeing, and will guess maximum zoom is reached.
Would be possible, but as there is no feedback, that maximum zoom is reached, the user could try to zoom in further. The zoom factor gets bigger and bigger with each try. If the user decides to zoom out again, on the first zoom out nothing happens ...
So I think it is better to have a message (svg-image with the message in).
If going with the first solution, cleaner to not use local _bb:
self._bb = RenderImage... + if not self._bb then + -- couldn't make a bb: probably not enough memory for such a large bb + self._bb = RenderImage:renderImageFile("resources/icons/src/appbar.magnify.zoom.svg", false, 200, 200) + end
OK
There was a problem hiding this comment.
Yeah, the "no visible feedback" thing was what made me tweak the onZoom handlers because it was confusing as hell in practice.
|
Thinking again, multiple remarks:
In that case, ImageViewer should reset the zoom factor to the previous value if it didn't manage to get a bb for the wished zoom factor. |
No, I am currently testing with the cover images of my regular e-pubs (png or jpg). Thanks for the rest of your hints. I will sleep over it. |
Alright. And I was wrong: with SVG images, no copy is done - except for SVG cover images where the copy is done in cre.cpp - and there, I don't even check if the malloc succeeds :/ So, probably a few other places to visit and see if we can have them behave the same way on malloc failure. |
The thought crossed my mind, but I don't think we have anything better for a plain module that's only essentially used as a toolbox of functions (as opposed to an instantiated class like framebuffer than inherits a dbg pointer from front that points to logger.dbg). |
Ooh, making bb:new & bb:copy return a pointer or nil, error or nil tuple sounds good, yeah. |
|
I have looked into As I will have not much time in the next few weeks, I will to let this PR to you. Please overtake it or close it, as you like. |
|
I think the only thing we really needed help for was the actual zoom scaling logic, we can probably deal with the rest one way or another ;). |
|
Jepp, but I for my feelings the zoom scalimg feature works well, except the crashes. I never felt it does not work as expctd. Ok I dont use it often. So closing this |
|
On a mildly related note, I'm slightly curious to know on what kind of input images and output devices you've managed to trigger these OOM crashes, because I tested a lot of pinches & spreads on quite a few devices when working on GestureDetector and I never saw it crash ;). (In general, when we get OOM crash reports, they're either a kernel OOM-kill on Kindle or 256/512MB devices; or k2pdfopt processing related on difficult input). |
|
I get the crashes on my mobile and my Sage.
Maybe you can reproduce it with https://allesebook.de/ebooks-kostenlos/Krieg-und-Frieden-Leo-N-Tolstoi.epub
Am 16. September 2022 23:58:52 MESZ schrieb NiLuJe ***@***.***>:
On a mildly related note, I'm slightly curious to know on what kind of input images and output devices you've managed to trigger these OOM crashes, because I tested *a lot* of pinches & spreads on quite a few devices and I never saw it crash ;).
(In general, when we get OOM crash reports, they're either a kernel OOM-kill on Kindle or 256/512MB devices; or k2pdfopt processing related on difficult input).
--
Reply to this email directly or view it on GitHub:
#9524 (comment)
You are receiving this because you modified the open/close state.
Message ID: ***@***.***>
--
Diese Nachricht wurde von meinem Android-Gerät mit K-9 Mail gesendet.
|
|
Is that a particularly large image file? Btw, I'm not sure if we're talking about malloc here or within LuaJIT itself? Strictly within LuaJIT we're limited to 2 GB atm, although we could build with the 64-bit flag on select platforms. |
|
This is not a big image. The cover is more or less a blue background with some text in it.
Open the cover with a long tap on the cover image and zoom in and in and in
... crash even on my 6GB mobile.
Its a malloc priblem in blitbuffer line 1905.
|
|
Hm, if I zoom in 5 or 6 times it's extremely blurry and it doesn't seem to want to zoom in any further if you try. (Also I didn't even realize you could zoom in, heh.) |
|
Okay, actually looking at the Sage crash you posted in #9510 (comment), a 131MB alloc failing is... kinda low, but still on the upper range of what I would consider acceptable. As @Frenzie mentioned, we're limited by the 32bit architecture on how much we can alloc (at once and in total), so the actual device matters much less than expected in the end. The Sage happens to be a fairly bad example because it suffers from higher memory pressure than other Kobo devices because of the terrible sunxi driver reserving a large chunk of memory, and NTX cheaping out on giving it the same amount of RAM than the Elipsa ;). Anyway, I'm going to check if we're not simply leaking temporary bbs somewhere (and/or releasing 'em too late), and I plan to make the scaling cap dynamic: instead of being fixed factors, I want to make 'em dynamic based on the screen size, limiting zoom outs to a hundreth of the screen's area, and zoom in to ten times the screen's area. EDIT: I can't maths. Numbers subject to alterations ;p. |
Like I said there is It wouldn't make a difference in the standard Android build regardless of course. |
|
I'm... not entirely sure this would be safe on aarch32 ;). |
|
I don't know what would happen if you tried to enable it on 32-bit but I only mean on (currently) some of the Debian builds. Hence not on Android. |
With this PR and the following patch of
base/ffi/blitbuffer.luathe crash is gone.If the user zooms in too much an icon with a magnifying glass and an infomessage with the request to zoom out is shown.
Both crashes mentioned in #9510 (comment) are resolved.
Setting this as draft, as I think there will be a better solution (maybe just show the message and don't zoom further in).
This change is