Closed pgaskin closed 3 years ago
Done, but I haven't actually tested it yet.
Might not be directly related to this PR, but, I botched the syntax (forgot the extra
), and I'd also left the selection stuff uncommented, which meant I ended up with a Config parsing error.
Except, even if I fix it, NM tries to re-parse it (e.g., the ts change is detected, revision incremented and all that jazz), but it still fails to parse, and prints the line numbers from the old, broken file?
Okay, have now tried with random giant (as in, Forma-sized) PNGs (e.g., KOReader's icon), and it's quite likely crashing right after:
Dec 3 17:54:37 nickel: (NickelMenu) MainNavView::MainNavView(0x17271e8, (nil)) (src/nickelmenu.cc:220)
Dec 3 17:54:37 nickel: (NickelMenu) Adding main menu button in tab bar for firmware 4.23.15505+. (src/nickelmenu.cc:223)
Dec 3 17:54:37 nickel: (NickelMenu) Added button. (src/nickelmenu.cc:360)
warning: Can't read data for section '.eh_frame' in file '/usr/local/Kobo/imageformats/libnm.so'
0x2e5a3432 in ?? () from /usr/local/Qt-5.2.1-arm/lib/libQt5Gui.so.5
(gdb) bt full
#0 0x2e5a3432 in ?? () from /usr/local/Qt-5.2.1-arm/lib/libQt5Gui.so.5
No symbol table info available.
#1 0x2e5a8154 in QImage::convertToFormat(QImage::Format, QFlags<Qt::ImageConversionFlag>) const () from /usr/local/Qt-5.2.1-arm/lib/libQt5Gui.so.5
No symbol table info available.
#2 0x2e5c5718 in QRasterPlatformPixmap::createPixmapForImage(QImage&, QFlags<Qt::ImageConversionFlag>, bool) () from /usr/local/Qt-5.2.1-arm/lib/libQt5Gui.so.5
No symbol table info available.
#3 0x2e5c5844 in QRasterPlatformPixmap::fromImage(QImage const&, QFlags<Qt::ImageConversionFlag>) () from /usr/local/Qt-5.2.1-arm/lib/libQt5Gui.so.5
No symbol table info available.
#4 0x2e5c2d14 in QPlatformPixmap::fromFile(QString const&, char const*, QFlags<Qt::ImageConversionFlag>) () from /usr/local/Qt-5.2.1-arm/lib/libQt5Gui.so.5
No symbol table info available.
#5 0x2e5bd296 in QPixmap::load(QString const&, char const*, QFlags<Qt::ImageConversionFlag>) () from /usr/local/Qt-5.2.1-arm/lib/libQt5Gui.so.5
No symbol table info available.
#6 0x2e5bd384 in QPixmap::QPixmap(QString const&, char const*, QFlags<Qt::ImageConversionFlag>) () from /usr/local/Qt-5.2.1-arm/lib/libQt5Gui.so.5
No symbol table info available.
#7 0x2b82d044 in QuickTourWidget::QuickTourWidget(QWidget*) () from /usr/local/Kobo/libnickel.so.1
No symbol table info available.
#8 0x2b826eca in Ui_HomePageView::setupUi(QWidget*) () from /usr/local/Kobo/libnickel.so.1
No symbol table info available.
#9 0x2b8267de in HomePageView::HomePageView(QWidget*) () from /usr/local/Kobo/libnickel.so.1
No symbol table info available.
#10 0x2b81f4b0 in HomePageController::loadView() () from /usr/local/Kobo/libnickel.so.1
No symbol table info available.
#11 0x2b8efb22 in ?? () from /usr/local/Kobo/libnickel.so.1
No symbol table info available.
#12 0x2b8f129c in MainWindowController::push(AbstractController*, bool) () from /usr/local/Kobo/libnickel.so.1
No symbol table info available.
#13 0x2b8f24fc in MainWindowController::show(AbstractController*) () from /usr/local/Kobo/libnickel.so.1
No symbol table info available.
#14 0x2b8f2ed4 in MainWindowController::createHomePage() () from /usr/local/Kobo/libnickel.so.1
No symbol table info available.
#15 0x2b80335a in N3PostFTEWorkflowManager::endWorkflow() () from /usr/local/Kobo/libnickel.so.1
No symbol table info available.
#16 0x2b803418 in N3PostFTEWorkflowManager::progressWorkflow() () from /usr/local/Kobo/libnickel.so.1
No symbol table info available.
#17 0x2b80367e in N3PostFTEWorkflowManager::startWorkflow() () from /usr/local/Kobo/libnickel.so.1
No symbol table info available.
#18 0x2b8f4b56 in Nickel3Application::finishInitialization() () from /usr/local/Kobo/libnickel.so.1
No symbol table info available.
#19 0x2b8f69d2 in Nickel3Application::Nickel3Application(int&, char**) () from /usr/local/Kobo/libnickel.so.1
No symbol table info available.
#20 0x0001f172 in main ()
No symbol table info available.
Good news: it's 100% less explode-y when using smaller icons.
New problem, though: the scaling ^^.
(From 144x icons pilfered from https://github.com/koreader/koreader/pull/6937 ;p).
Also: the active variant is never displayed.
Also: the active variant is never displayed.
Note that this also applies to the default icon ^^
Unless I'm misunderstanding nickel, MainNavView.qss is expecting the icon to be a certain size:
Thanks for testing this!
(From 144x icons pilfered from koreader/koreader#6937 ;p).
Ooh, I like that icon. It fits well with the rest (I should have thought of the new material icons earlier). I might even make it the default in the future.
Also: the active variant is never displayed
That's why I set the defaults for it as I did :) .
Unless I'm misunderstanding nickel, MainNavView.qss is expecting the icon to be a certain size:
I guess I could parse the scale from MainNavView.qss or one of the existing icons, then dynamically resize the pixmap. This would also allow me to easily add an option for SVG icons in the future, which would be a requirement for me to add a custom icon since I try to keep NM as forward-compatible as possible.
Okay, have now tried with random giant (as in, Forma-sized) PNGs (e.g., KOReader's icon), and it's quite likely crashing right after:
I'll have to look into that crash to ensure I understand the requirements properly.
Might not be directly related to this PR, but, I botched the syntax (forgot the extra), and I'd also left the selection stuff uncommented, which meant I ended up with a Config parsing error.
Except, even if I fix it, NM tries to re-parse it (e.g., the ts change is detected, revision incremented and all that jazz), but it still fails to parse, and prints the line numbers from the old, broken file?
Huh. That shouldn't be possible unless there's a bug somewhere or one of my assumptions with menu behaviour was incorrect. Do the logs shown NM re-injecting the config error after the updated config files are parsed, or is it staying with the old one?
I guess I could parse the scale from MainNavView.qss or one of the existing icons, then dynamically resize the pixmap. This would also allow me to easily add an option for SVG icons in the future, which would be a requirement for me to add a custom icon since I try to keep NM as forward-compatible as possible.
Just FYI... MainNavView doesn't contain the exact icon size it contains a min-/max-height value of 2.5 x icon height (for model), to also include height of label (plus some vertical padding???). So taking size from existing icons might be more reliable in the long run.
Huh. That shouldn't be possible unless there's a bug somewhere or one of my assumptions with menu behaviour was incorrect. Do the logs shown NM re-injecting the config error after the updated config files are parsed, or is it staying with the old one?
Here's the full log:
I guess I could parse the scale from MainNavView.qss or one of the existing icons, then dynamically resize the pixmap. This would also allow me to easily add an option for SVG icons in the future, which would be a requirement for me to add a custom icon since I try to keep NM as forward-compatible as possible.
Just FYI... MainNavView doesn't contain the exact icon size it contains a min-/max-height value of 2.5 x icon height (for model), to also include height of label (plus some vertical padding???). So taking size from existing icons might be more reliable in the long run.
The stupid workaround I can think of is simply load the default one, and ask Qt about its size ;p.
Except, even if I fix it, NM tries to re-parse it (e.g., the ts change is detected, revision incremented and all that jazz), but it still fails to parse, and prints the line numbers from the old, broken file?
What did you do to attempt to fix the broken file?
I started by commenting out the not-supported-in-this-build stuff (e.g., the two selection menu items that it was tripping on @ L19).
Then I fixed the actual extra
syntax for the icons stuff.
Then I just added LFs a couple of times to try to see if that would help :D. (aka. muppet flail ^^)
FWIW, the config was untouched between that log, and the next Nickel restart, where it imploded (https://github.com/pgaskin/NickelMenu/pull/98#issuecomment-738135999).
@NiLuJe, I couldn't reproduce your issue, but I found a related regression which might have hidden the real cause of the parsing error you saw. See #99.
Ready for testing.
Code looks ok, once I figured out what it was doing. Just a minor comment.
The giant PNGs test still implodes Nickel (but I do get the scaling notification from NM first). At a quick glance, GDB was fairly unhelpful, but it probably had a bit of trouble tracking threads properly.
The sane PNG test was successful, and it does indeed get scaled properly ;).
The giant PNGs test still implodes Nickel (but I do get the scaling notification from NM first). At a quick glance, GDB was fairly unhelpful, but it probably had a bit of trouble tracking threads properly.
The sane PNG test was successful, and it does indeed get scaled properly ;).
I wonder if this bug report is applicable here?
The safer thing to do might be to load the image file using QImage, scale it down and save it. Then it can be sure that QPixmap is never opening a large image.
They're not that big, but, who knows, I did see mention of the pixmap cache in one of the least useless tracebacks...
resources/kfmon.png PNG 1440x1920 1440x1920+0+0 8-bit Gray 16c 106946B 0.000u 0:00.000
resources/plato.png PNG 1404x1872 1404x1872+0+0 8-bit Gray 16c 15108B 0.000u 0:00.000
Everything should be fixed now.
Alas, giant PNGs still implode Nickel ;/.
Not that it should matter, but this is what's generated by QImage:
Image:
Filename: /tmp/nm_menu.png
Format: PNG (Portable Network Graphics)
Mime type: image/png
Class: DirectClass
Geometry: 31x42+0+0
Resolution: 104.33x103.94
Print size: 0.297134x0.404079
Units: PixelsPerCentimeter
Colorspace: sRGB
Type: Grayscale
Base type: Undefined
Endianness: Undefined
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
e.g., a standard PNG24. It displays just fine via FBInk FWIW.
Trying to only set a single icon instead of both (normal + active) doesn't help either.
I'm going to look into this more myself tomorrow. If I can't figure out the cause, I'll probably leave this feature for after v0.5.0.
Good news: I'm an idiot.
Of course, if I'm pointing to icons that are being watched by KFMon... it'll trip their watch. So by using the KOReader icon, I was actually launching KOReader in the middle of Nickel's boot... -_-".
Suffice it to say, if I copy the icons elsewhere, everything's peachy :).
So by using the KOReader icon, I was actually launching KOReader in the middle of Nickel's boot... -_-".
That would probably do it. :rofl: How did that cause it to crash instead of terminating cleanly, though?
Suffice it to say, if I copy the icons elsewhere, everything's peachy
So this is ready to be merged?
That would probably do it. rofl How did that cause it to crash instead of terminating cleanly, though?
Because nickel doesn't have a SIGTERM handler ;).
So this is ready to be merged?
Yep!
Yep!
One last question: did the failsafe trip properly, or did you need to manually remove NM? I'm asking since if it was too late for the failsafe, I'll add another for critical operations like this.
No, it tripped just fine ;).
Done. I'll make a release sometime before the end of this week.
closes #84