Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Spider Monkey Panel (foo_spider_monkey_panel) (Read 341846 times) previous topic - next topic
0 Members and 3 Guests are viewing this topic.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #875
One thing to be aware of is that Windows is VERY forgiving about file names, but foobar isn't quite as forgiving. You can save a .jpg and call it a .png or .gif and Windows will display it just fine. Foobar seems to be able to load .jpgs as .pngs and vice versa, but if one of those is a gif it doesn't work.

Can't speak for the album art functions but gdi.Image shouldn't care about the file extension. It uses IStream / SHCreateStreamOnFileEx to create an IStream object which is then passed as an arg to the Gdiplus::Bitmap constructor. It has no clue about the file extension at that point...

https://github.com/marc2k3/foo_jscript_panel/blob/f03851583d109c39a5b4aafc942deacd87c2f7a7/src/Helpers/Image.h#L60-L61

Pretty sure SMP does exactly the same as the code was inherited from WSH panel mod.

edit: tested just to make sure. These are 5 gif files renamed with different extensions...


is JScript Panel going to add Direct2D or more efficient image drawing, loading...etc support so we don't have to get stuck with gdi?

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #876
one weird behaviour I'm seeing is that, on pretty much every startup, I'm getting below error, but everything works if I just click Reload. it seems that something broken only during fb2k startup, but not after fb2k had started
Code: [Select]
Error: Spider Monkey Panel v1.4.1 (Thumbs: Thumbs by marc2003)
Resize failed:
Failed to create GdiPlus object (0x2): InvalidParameter

File: thumbs.js
Line: 540, Column: 122
Stack trace:
  iter_image_load_resize@thumbs.js:540:122
  c@lodash.min.js:6:348
  tu@lodash.min.js:67:168
  _thumbs/this.update@thumbs.js:544:25
  _thumbs/this.metadb_changed@thumbs.js:171:14
  on_metadb_changed@<main>:25:9
  _panel/this.item_focus_change@panel.js:11:4
  @<main>:12:7

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #877
is JScript Panel going to add Direct2D or more efficient image drawing, loading...etc support so we don't have to get stuck with gdi?

Nope. I wouldn't know where to start even I wanted to. And I don't.... :P

Your use case is very much non standard and it's not really worth the effort it would take anyone else trying to it solve for you. Your super huge images might give you a warm fuzzy feeling inside but what's the point? Even my largest 3000x3000 album art is no bigger than 4MB. Even fb2k itself defaults to ignoring images over 8MB (yes, I'm aware that can be overridden in the advanced preferences).

Regarding your error above, are you using the latest official build?? IIRC Mordred provided a supposedly optimised build a few weeks ago but it was in fact buggy and would cause that error.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #878
one weird behaviour I'm seeing is that, on pretty much every startup, I'm getting below error, but everything works if I just click Reload. it seems that something broken only during fb2k startup, but not after fb2k had started
Code: [Select]
Error: Spider Monkey Panel v1.4.1 (Thumbs: Thumbs by marc2003)
Resize failed:
Failed to create GdiPlus object (0x2): InvalidParameter

File: thumbs.js
Line: 540, Column: 122
Stack trace:
  iter_image_load_resize@thumbs.js:540:122
  c@lodash.min.js:6:348
  tu@lodash.min.js:67:168
  _thumbs/this.update@thumbs.js:544:25
  _thumbs/this.metadb_changed@thumbs.js:171:14
  on_metadb_changed@<main>:25:9
  _panel/this.item_focus_change@panel.js:11:4
  @<main>:12:7
Something similar happened to me on startup because I adjusted fontsize according to window size and gdi font size was 0 at that point. It obviously worked right after startup when I reloaded the panel because window size was != 0. I reported it here some weeks ago.

Check you are not doing the same with gdi image at some point, since it always crashes as soon as width or height is zero, which may happen at startup if you are setting them according to window size.

It may well draw nothing in both cases but...

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #879
one weird behaviour I'm seeing is that, on pretty much every startup, I'm getting below error, but everything works if I just click Reload. it seems that something broken only during fb2k startup, but not after fb2k had started
Code: [Select]
Error: Spider Monkey Panel v1.4.1 (Thumbs: Thumbs by marc2003)
Resize failed:
Failed to create GdiPlus object (0x2): InvalidParameter

File: thumbs.js
Line: 540, Column: 122
Stack trace:
  iter_image_load_resize@thumbs.js:540:122
  c@lodash.min.js:6:348
  tu@lodash.min.js:67:168
  _thumbs/this.update@thumbs.js:544:25
  _thumbs/this.metadb_changed@thumbs.js:171:14
  on_metadb_changed@<main>:25:9
  _panel/this.item_focus_change@panel.js:11:4
  @<main>:12:7
Something similar happened to me on startup because I adjusted fontsize according to window size and gdi font size was 0 at that point. It obviously worked right after startup when I reloaded the panel because window size was != 0. I reported it here some weeks ago.

Check you are not doing the same with gdi image at some point, since it always crashes as soon as width or height is zero, which may happen at startup if you are setting them according to window size.

It may well draw nothing in both cases but...

I think I hit your described issue where SMP is telling me Win size of 0, but in a different way. looks like size of 1 is not valid for resize... SMP doc also doesn't say what's the min size for resize

my code already handles Win size of 0 when I hit this crash. I added some console logging to see what's going on
Code: [Select]
let w_height = Math.max(window.Height,1), w_width = Math.max(window.Width,1);
let gbmp = _img(image_path);
if(!gbmp) {
    console.log("Image load Failed=" + image_path );   // SUPERCOOLMAN
    //console.log("Image utils.IsFile=" + utils.IsFile(image_path) );   // SUPERCOOLMAN
    //console.log("Image _isFile=" + _isFile(image_path) );   // SUPERCOOLMAN
    return;
} // end if
let bmp_height = Math.max(gbmp.Height,1), bmp_width = Math.max(gbmp.Width,1);
let height_ratio = Math.ceil(bmp_height/w_height),width_ratio = Math.ceil(bmp_width/w_width);
    console.log(`Image load Failed Win.width=${w_width}\tWin.height=${w_height}`);   // SUPERCOOLMAN
    console.log(`Image load Failed BMP.width=${bmp_width}\tBMP.height=${bmp_height}`);   // SUPERCOOLMAN
    console.log(`Image load Failed width_ratio=${width_ratio}\theight_ratio=${height_ratio}`);   // SUPERCOOLMAN
    console.log(`Image load Failed resized width=${Math.ceil(bmp_width/height_ratio)}\theight=${Math.ceil(bmp_height/height_ratio)}`);   // SUPERCOOLMAN
    console.log(`Image load Failed resized width=${Math.ceil(bmp_width/width_ratio)}\theight=${Math.ceil(bmp_height/width_ratio)}`);   // SUPERCOOLMAN
return (height_ratio >= width_ratio) ? gbmp.Resize(Math.ceil(bmp_width/height_ratio),Math.ceil(bmp_height/height_ratio),0x1): gbmp.Resize(bmp_width/width_ratio,bmp_height/width_ratio,0x1);
result when crashed
Code: [Select]
Image load Failed Win.width=1	Win.height=1
Image load Failed BMP.width=7596 BMP.height=3767
Image load Failed width_ratio=7596 height_ratio=3767
Image load Failed resized width=3 height=1
Image load Failed resized width=1 height=1
foo_spider_monkey_panel:
Error: Spider Monkey Panel v1.4.1 (Thumbs: Thumbs by marc2003)
Resize failed:
Failed to create GdiPlus object (0x2): InvalidParameter

File: thumbs.js
Line: 545, Column: 144
Stack trace:
  iter_image_load_resize@thumbs.js:545:144
  c@lodash.min.js:6:348
  tu@lodash.min.js:67:168
  _thumbs/this.update@thumbs.js:549:25
  _thumbs/this.metadb_changed@thumbs.js:171:14
  on_metadb_changed@<main>:25:9
  _panel/this.item_focus_change@panel.js:11:4
  @<main>:12:7

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #880
Can't speak for the album art functions but gdi.Image shouldn't care about the file extension. It uses IStream / SHCreateStreamOnFileEx to create an IStream object which is then passed as an arg to the Gdiplus::Bitmap constructor. It has no clue about the file extension at that point...

...

edit: tested just to make sure. These are 5 gif files renamed with different extensions...
I tried it before posting with a jpg I renamed a gif and *something* didn't load the image... although it's possible I was filtering out .gifs. I was tired this morning. :)

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #881
is JScript Panel going to add Direct2D or more efficient image drawing, loading...etc support so we don't have to get stuck with gdi?
Odds of this are very low. I looked into it to see how difficult it would be... and it seems to be beyond my powers. It sucks, but for most people doing normal things, gdi is fine. There's no way to get around the processing time required to load very large images. Best to debounce those if you can to avoid everything grinding to a halt, or just... don't have such large images.

 

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #882
found a couple more issues with SMP
  • Promise.allSettled is not available in SMP
  • Promise object returned by LoadImageAsyncV2 seemed to still get resolved even when image failed to load. I had expected rejected

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #883
Async methods for loading images aren't really doing you many favours. It's a very cheap operation. It's the resizing that's always going to be a problem.

For example, I can use the recursive utils.ListFiles method in JSP to read 2000 images totalling nearly 5GB in size in less than 1 second.

Code: [Select]
var total_size = 0;

var images = utils.ListFiles("z:\\blah", true).toArray().map(function (item) {
total_size += utils.GetFileSize(item);
return gdi.Image(item);
});

console.log(images.length);
console.log(utils.FormatFileSize(total_size));

Code: [Select]
1919
4.94 GB
JScript Panel v2.6.0.1 (id:3016108): initialised in 747 ms




Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #884
found a couple more issues with SMP
  • Promise.allSettled is not available in SMP
This isn't an "issue". FSM uses SM68 as the execution engine which corresponds to Firefox v68 as you might expect which was released in July 2019. Promise.allSettled was added to SM in release 78 (in v71 for Firefox). I asked last year after 78 was released but apparently upgrading the SM engine is not just a dependency update so unfortunately it's not just a quick thing Qwertiest can do.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #885
Async methods for loading images aren't really doing you many favours. It's a very cheap operation. It's the resizing that's always going to be a problem.

For example, I can use the recursive utils.ListFiles method in JSP to read 2000 images totalling nearly 5GB in size in less than 1 second.

Code: [Select]
var total_size = 0;

var images = utils.ListFiles("z:\\blah", true).toArray().map(function (item) {
total_size += utils.GetFileSize(item);
return gdi.Image(item);
});

console.log(images.length);
console.log(utils.FormatFileSize(total_size));

Code: [Select]
1919
4.94 GB
JScript Panel v2.6.0.1 (id:3016108): initialised in 747 ms
with async image load, I can continue for now, then check back later (from time to time per timer) and only draw/update when the image loading is done without freezing fb2k for long

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #886
found a couple more issues with SMP
  • Promise.allSettled is not available in SMP
This isn't an "issue". FSM uses SM68 as the execution engine which corresponds to Firefox v68 as you might expect which was released in July 2019. Promise.allSettled was added to SM in release 78 (in v71 for Firefox). I asked last year after 78 was released but apparently upgrading the SM engine is not just a dependency update so unfortunately it's not just a quick thing Qwertiest can do.
then I use reflect, but the hit the second behaviour causing the array Promise.all resolved to contain whole bunch of nulls resulting crashes if I don't handle these nulls

from the debug, I feel that the few out of many images failing to load is probably due to loading those somehow requires too much memory while the already load&resized images' original, despite only save resized copy in memory at the moment, hasn't been garbage collected resulting out of memory without crash and the symptom shows up as those images somehow needing lots of memory failed to load while many subsequent images needing way less memory loading without problem. why do smaller file size & dimension png images in from the same scan requires significant more memory is beyond me. perhaps the png compression worked well to compress them to smaller file size

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #887
then I use reflect, but the hit the second behaviour causing the array Promise.all resolved to contain whole bunch of nulls resulting crashes if I don't handle these nulls

from the debug, I feel that the few out of many images failing to load is probably due to loading those somehow requires too much memory while the already load&resized images' original, despite only save resized copy in memory at the moment, hasn't been garbage collected resulting out of memory without crash and the symptom shows up as those images somehow needing lots of memory failed to load while many subsequent images needing way less memory loading without problem. why do smaller file size & dimension png images in from the same scan requires significant more memory is beyond me. perhaps the png compression worked well to compress them to smaller file size
If you were running out of memory, you'd most likely see the out of memory popup which would kill your script. I think the threshold is ~1TB.

When dealing with images, it's not the file size on disk that matters, as these all get loaded in memory as bitmaps. Think of a standard 8bpc jpg/png is going to take 32 bits (8x4 channels) per pixel. If your image was 2000x2000 that's ~16MB of memory, plus whatever overhead is required for the GdiBitmap class (probably not much here). A 4000x4000 image is 64MB in memory. Don't need to load too many of those and you're bumping up against the memory cap. Obviously you can't predict when GC is going to run either, but you can try and provide opportunities for it to run by debouncing your image loading, batching them into setTimeout calls, etc. Anything you can do to essentially pause the script from doing stuff and return control to FSM component itself. I shouldn't need to point out that trying to rely on this is a bad idea.

It should be relatively easy to test if it's memory/size thing though. Find an image which is failing to load, and then load it by itself. If it doesn't work at least you've ruled out memory.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #888
then I use reflect, but the hit the second behaviour causing the array Promise.all resolved to contain whole bunch of nulls resulting crashes if I don't handle these nulls

from the debug, I feel that the few out of many images failing to load is probably due to loading those somehow requires too much memory while the already load&resized images' original, despite only save resized copy in memory at the moment, hasn't been garbage collected resulting out of memory without crash and the symptom shows up as those images somehow needing lots of memory failed to load while many subsequent images needing way less memory loading without problem. why do smaller file size & dimension png images in from the same scan requires significant more memory is beyond me. perhaps the png compression worked well to compress them to smaller file size
If you were running out of memory, you'd most likely see the out of memory popup which would kill your script. I think the threshold is ~1TB.

When dealing with images, it's not the file size on disk that matters, as these all get loaded in memory as bitmaps. Think of a standard 8bpc jpg/png is going to take 32 bits (8x4 channels) per pixel. If your image was 2000x2000 that's ~16MB of memory, plus whatever overhead is required for the GdiBitmap class (probably not much here). A 4000x4000 image is 64MB in memory. Don't need to load too many of those and you're bumping up against the memory cap. Obviously you can't predict when GC is going to run either, but you can try and provide opportunities for it to run by debouncing your image loading, batching them into setTimeout calls, etc. Anything you can do to essentially pause the script from doing stuff and return control to FSM component itself. I shouldn't need to point out that trying to rely on this is a bad idea.

It should be relatively easy to test if it's memory/size thing though. Find an image which is failing to load, and then load it by itself. If it doesn't work at least you've ruled out memory.

already done all of that debug hence confirming it's actually the memory usage causing images failed to load as resmon shows fk2b memory usage quickly blows up to 2GB or more during the image loads and cliff back down to as if nothing was loaded after image loading&re-size finished. all images loaded fine while memory usage is blowing up, but intermittent images load failures started to show up when memory usage reached ~2GB. I had moved to async image loads to return control back to the main thread (FSM?) immediately and all images loaded just fine. as part of my change few days ago, I had already created a function to perform load+return the resized image to array.map over all image file paths, so an array of original image would never have existed. otherwise, I don't think I would even be able to reach this issue as out of memory popups&crash would have occurred way earlier

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #889
does anyone know how can you draw text over a drawn image or how to erase a drawn image?

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #890
please ignore above question. I had set the wrong colour



Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #893
oops, I didn't notice it myself, I just fell several times, the first was the subject, now I looked at the logs - always different! What could it be?
Crash location:
Module: gdi32full
Offset: 59988h
Symbol: "TranslateCharsetInfo" (+20C8h)

Crash location:
Module: foo_dynamic_range
Offset: 1FB10h
Symbol: "foobar2000_get_interface" (+2DA0h)

Crash location:
Module: mozjs-68
Offset: 161D98h
Symbol: "JS::AddServoSizeOf" (+5DC8h)

etc


Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #894
You're on an old (and early) beta (1.6.5b2). Might want to try and upgrade to 1.6.6 final and see if that improves things.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #895
Foobar crashes when trying to open the package manager as soon as any package.json file at packages folder gets corrupted, is empty, some key is missing, etc. without more notice about what the problem is.

Wrong/incomplete packages should be skipped (or show a popup), but not totally crash foobar this way. Specially when you are not even trying to load the culprit

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #896
I'm having a strange issue using on_mouse_mbtn_up.  I have two portable installs, one is DUI with Georgia, and the other is CUI with Georgia-Re-BORN.  Both are on Foobar 1.6.6 and SMP 1.4.1.  With Georgia it works as expected, requiring only a single click.  But with Georgia-Re-BORN it requires a double click.  Any ideas?


Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #898
That was it.  Thank you very much.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #899
Foobar crashes when trying to open the package manager as soon as any package.json file at packages folder gets corrupted, is empty, some key is missing, etc. without more notice about what the problem is.

Wrong/incomplete packages should be skipped (or show a popup), but not totally crash foobar this way. Specially when you are not even trying to load the culprit
Can't reproduce on dev build.