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 341766 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #300
@TheQwertiest :
Hello TheQwerties,

I installed your new SMP ver 1.2.3-beta (kindly note that I did NOT removed the debug library from the user-component directory and did not disabled the Advanced settings I set for the debug of the ver 1.2.3-test). I was supposed to keep all this as-is not having had different instruction.

Then I edited the Library Tree ver 2.1.2 JS as instructed (replacing all the occurances). Attached is the modified JS in case you would check if I did all right.

And this is the outcome:
1) What's good is that not Library Tree can start-up with the default view, there are no crash.
2) What's bad is that as soon as I select the View by Folder Structure, Foobar UI freezes and it doesn't came back to live even waiting 1+ hour. So, I have to kill the process Foobar.
To be noted that after the kill, I can restart Foobar and the Library Tree JS results not loaded in the target SMP panel (that panel configuration is lost or deleted by the system).

I tried this 5 times and all runs went exactly the same.
Unfortunately I could not collect any console log because of Foobar freeze.

Kindly let me know if you need me to execute some other tests or collect debug info.
Thanks and regards, Andrea


Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #302
@TheQwertiest : I will try right away. I will let you know asap.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #303
@Qwertyiest
Tidying my script to process new tracks. In this script I get a list of handles to be processed and then I used to call
fb.RunContextCommandWithMetadb("Tagging/Remove all pictures",myHandles,8);
to delete all embedded images. I've replaced this with the RemoveAttachedImages method of the handles list and it works great.

I also want to optimise my files so I currently use a context menu command;
fb.RunContextCommandWithMetadb("Utilities/Optimize file layout + minimize file size",myHandles,8);
However this generates a popup information box that I have to close every time. Would it be possible to create another method such as myHandles.OptimizeAndMinimize on the list of handles to avoid the popup message?

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #304
Looks like our friend marc2k3 has implemented IMetadbHandleList OptimiseFileLayout in his foo_jscript_panel to address my request. Thanks marc2k3. Hopefully this will find it's way into the next foo_spider_monkey_panel.....please.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #305
@Black_Over_Bills_Mothers, sorry, I have quite a few things that I want (and need) to do in SMP, so it will have to wait for a bit. It is noted though, and I'll come back to it after I finish at least some of planned features.


Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #307
Hello @TheQwertiest, many thanks for promptly notifing me.
I immediately tested the new Spider Monkey Panel v1.2.3-beta+61085bf2.
It is working well and in my case it saves approximately 75MB or RAM (compared with the special build you gave me dated 6 of November).
Great job!
Kind regards, Andrea

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #308
Quote
saves approximately 75MB or RAM (compared with the special build you gave me dated 6 of November)
It's probably caused by the new SpiderMonkey (JavaScript engine), which was updated in the nightly builds =)

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #309
Quote
saves approximately 75MB or RAM (compared with the special build you gave me dated 6 of November)
It's probably caused by the new SpiderMonkey (JavaScript engine), which was updated in the nightly builds =)

@TheQwertiest : But I was not using V2 method. So, I think the 75MB savings is due to the new V2 method merged into the legacy V1.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #310
* double post removed *
I'm late

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #311
First time I ever see this kind of error:
Quote
Error: Spider Monkey Panel v1.2.2-preview+0db3c6a4 (test by davideleo)
Font failed:
WinAPI error: CreateFont failed with error (0x0): The operation completed successfully.

The code which generates the error is as simple as this:
Code: [Select]
this.font = gdi.Font("Segoe UI", 12);

The crash occurs only once every two times.


Any clue?



P.S.
As a test, I replaced the error generating line with the following:
Code: [Select]
this.font =  window.GetFontCUI(0);

The script still crashes once every two times, but for a different reason:
Quote
Error: Spider Monkey Panel v1.2.2-preview+0db3c6a4 (test by davideleo)
FillSolidRect failed:
GdiPlus error: FillRectangle failed with error (0x2): InvalidParameter

Once again, the error-generatng line is as innocent as it can get:
Code: [Select]
gr.FillSolidRect(this.x, this.y, this.width, this.height, colours.LightGray);
I'm late

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #312
@davideleo , can you try the latest nightly version and check if it has the same error?

As for `gr.FillSolidRect(this.x, this.y, this.width, this.height, colours.LightGray);` error, this usually happens when you supply invalid dimensions. E.g. zero height or width.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #313
Hi @TheQwertiest , I tested the script with the nightly build and it behaves in the exact same way, notifying the same errors.
Switching from one version to the other, I watched the behavior on startup, though, which I did not consider previously. The original script (the one with gdi.Font()) always crashes on startup and at the first attempt to reload it. Subsequent attempts alternate success and failure.
The "control" script (the one with window.GetFontCUI()) totally freezes foobar2000 on startup. I can hear the sound of the crash notification, but all I see is a blank window preview when I move the mouse over the taskbar icon (see the attached picture). I can start foobar2000 (albeit with a crash) only with the original script and replace it with the control script only once foobar2000 is running. The control script will than work and crash every other time.

Something I did not mention before is that it is not a proper crash: the code stops working, but the last painted window is not replaced by the "Aw, crashed :(" orange window (I have to manually resize the window to trigger that).


As for `gr.FillSolidRect(this.x, this.y, this.width, this.height, colours.LightGray);` error, this usually happens when you supply invalid dimensions. E.g. zero height or width.
For doubt's sake I outputted the FillSolidRect() arguments to the console and they are the same the one time it crashes and the one it works. 


P.S.
Maybe it's a clue, maybe not: I tried reverting to SMP v1.2.1 and found out that with this older version both scripts freeze foobar2000 on startup.
I'm late

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #314
Hello @TheQwertiest, I do not know why but yesterday I had again Out-of-memory errors (3 or 4 in a couple of hours) running Library Tree and the beta of SMP 1.2.3 dated (build 11 of November).
I do not remember to have done something different or unusual than the previous days...
The only big change in between is Windows 10 update from 1903 to 1909.
Kindly let me know if you need me collecting specific data/logs.
Regards, Andrea

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #315
Unresponsive script - Don't ask me again - Option NOT working

Hello @TheQwertiest, I noticed that even if I select the option "Don't ask me again", it doesn't work and every time I restart Foorbar I get the notifying window herein attached.

Kind regards, Andrea

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #316
Unresponsive script - Don't ask me again - Option NOT working
It's not supposed to persist between fb2k restarts, i.e. it's intentional. It only suppresses the warning in the current panel for the current fb2k instance.

Regarding OOM errors: not sure what I can do to help you. As I've said before, your library *is* huge and WilB's script is not designed for minimal memory usage (the performance of the script would have been likely worse if it was though - time-memory trade-off and all that). Maybe playing around with GC settings might help you (i.e. in preferences > advanced), but I have no specific suggestions :\

@davideleo , can you provide the script that reproduces the problem?

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #317
@TheQwertiest, many thanks for your kind reply.
All the best, Andrea

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #318
@davideleo , can you provide the script that reproduces the problem?

I tried reverting to the error-generating version of the script, but I made too many edits since my last post. However, I was able to move on when I found out that the error was generated by too many repeated gdi.Font methods (the crash would occur after around 2000 iterations),

The following is a very simplified script with the same logic, which reproduces the same error:
Code: [Select]
include(fb.ComponentPath + "samples\\complete\\js\\lodash.min.js");


var artists = list("artist");
var grid = new Grid(artists, 12);


function Cell(fontSize){
this.font = gdi.Font("Segoe UI", fontSize);
}


function Grid(list, fontSize){
this.cells = list.map(() => {
return new Cell(fontSize);
})
}


function list(tag, handle_list = fb.GetLibraryItems()){
var tags = [];
var items = fb.GetQueryItems(handle_list, tag + " PRESENT");
for (var i = 0; i < items.Count; i++) {
var handle = items[i];
var values = fb.TitleFormat("$meta_num(" + tag + ")").EvalWithMetadb(handle);
for (var j = 0; j < values; j++) {
tags.push(fb.TitleFormat("$meta(" + tag + "," + j + ")").EvalWithMetadb(handle));
}
}
    return _.uniq(tags.sort(), true);
}

I'm late

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #319
@davideleo , it seems that you've exhausted GDI handles. System can provide only so much GDI handles (the limit depends on the OS version and it's configuration). Since all GdiFont objects are being stored in the Grid/Cell, they can't be GC'd, thus GDI handles can't be freed. The resulting error report is weird though and I'll try to look into it.

That aside, you should reuse GdiFont objects whenever possible (instead of recreating them every time) for memory and performance sakes (and to avoid hitting GDI handle limit).

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #320
I need the width of the playing playlist name on start up. According to the console log, I only have one on_paint event to exploit after the playing playlist is resumed, but I'd rather not overload the on_paint() callback if not strictly needed. So, is there another way to trigger the code when the playback state has been resumed, or alternatively a good reason not to?
I'm late

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #321
I need the width of the playing playlist name on start up. According to the console log, I only have one on_paint event to exploit after the playing playlist is resumed, but I'd rather not overload the on_paint() callback if not strictly needed. So, is there another way to trigger the code when the playback state has been resumed, or alternatively a good reason not to?
Not sure I understand your scenario. For playback state tracking you can use `on_playback*` callbacks (e.g. `on_playback_pause`). If you want to reduce workload in `on_paint`, you can always cache results (i.e. calculate width only if the playlist name changed).

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #322
Not sure I understand your scenario.

The problem is only at startup. I use foobar2000 with the option to resume playback state checked and I never stop the player, I just  pause it. Therefore, foobar2000 starts with a playing playlist on. I have a drawtext function that takes the playing playlist name and the width of the playlist name, but the playing playlist name is not available until the very end of the startup process, when the only event left to use is the on_paint. So, is this the only option? I have no need to recalculate the width of the text at every on_paint, on_size would make more sense, but the last of the three on_size events at startup is before playlist initialization.
There is actually other stuff going on between the last on_size and the on_paint at startup, such as foo_enhanced_playcount being loaded, which makes me guess that I'd have the same issue if I were to retrieve scrobbling information at startup.
I kind of miss an on_startup_done() callback.
I'm late

 

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #323
Is there a way to temporary disable keyboard shortcuts?
I'm late

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #324
The problem is only at startup. I use foobar2000 with the option to resume playback state checked and I never stop the player, I just  pause it. Therefore, foobar2000 starts with a playing playlist on. I have a drawtext function that takes the playing playlist name and the width of the playlist name, but the playing playlist name is not available until the very end of the startup process, when the only event left to use is the on_paint. So, is this the only option? I have no need to recalculate the width of the text at every on_paint, on_size would make more sense, but the last of the three on_size events at startup is before playlist initialization.
There is actually other stuff going on between the last on_size and the on_paint at startup, such as foo_enhanced_playcount being loaded, which makes me guess that I'd have the same issue if I were to retrieve scrobbling information at startup.
I kind of miss an on_startup_done() callback.

Regretfully, fb2k does not provide `on_startup_done` callback and I can't implement it myself.

I have no need to recalculate the width of the text at every on_paint
As I've said, you can *cache* the value. Or just use a simple boolean guard
Code: [Select]
var isInitialized = false;
function on_paint()
{
  if (!isInitialized )
  {
    CalculateSmth();
    isInitialized =true;
  }
}

Quote
Is there a way to temporary disable keyboard shortcuts?
fb2k API does not provide such functionality.