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 341745 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #325
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;
  }
}

I see. Thanks, I actually needed to be reassured that a workaround is needed here. I guess I'll just save the playing playlist name to a file, Talking of workarounds, I found out that you can trigger a few playlist events before the initial on_paint by adding and removing items to a playlist on start up. It's probably the closest you can get to an on_start_up_done.
I'm late

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #326
@davideleo , I've got some info from Peter (https://hydrogenaud.io/index.php?topic=117208.msg977811#msg977811), which clarified some things:
- It *might* be possible to create on_start_up_done callback. No promises or ETA though.
- on_paint and on_size callbacks *might* (and often will) be called before the fb2k is fully initialized.
[Edit]:
- It *is* possible to suppress shortcuts. But no promises or ETA on that either.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #327
 8)  You are my favorite foobar2000 component developer ♥
I'm late

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #328
Haha, thanks =)
Though I don't think I deserve this title. There are far more qualified developers (e.g. musicmusic, CUI dev).

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #329
- on_paint and on_size callbacks *might* (and often will) be called before the fb2k is fully initialized.

What I refer to as "start up" is probably autoplaylist initialization really. The console log shows the start up time right after all autoplaylists are set, therefore I gathered that was the last stand of the start up process. This is my usual start up log:


Quote from:  console.log
components loaded
configuration read
on_size
Spider Monkey panel initialized
on_size (3 times)
UI initialized
foo_custom_database initialized
autoplaylist initialized
foo_enhanced_playcount loaded
start up done (at least start up time is written here in the console log) <-----------------
possible playlist events
on_paint


I'm late

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #330
Hello @TheQwertiest, hoping to find you well, I am getting to you just to have an idea of when you would release the new SMP with the v1 and v2 methods merged together.
I am waiting for it in order to use Library Tree (I have then to remove because of the too frequent out-of-memory crashes).
Kind regards, Andrea

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #331
@AndreaT, it's still quite far from release, but you can use Nightly version in the meantime (Nightly/beta doesn't mean "not stable" ), it has v2 sorting method integrated.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #332
@AndreaT, it's still quite far from release, but you can use Nightly version in the meantime (Nightly/beta doesn't mean "not stable" ), it has v2 sorting method integrated.

Hello @TheQwertiest, ... thanks ... but your last Nightly build I downloaded few hours ago cannot be installed.
I am getting an installation error. I tried 3 times.
If you need the error code, let me know and I will try to reinstall again.
Thanks and regards, Andrea

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #333
I am getting an installation error. I tried 3 times.
If you need the error code, let me know and I will try to reinstall again.
That's really weird. Is there a error message or smth like that?

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #334
Hello @TheQwertiest, this is the error I get during the installation process:
"Could not load component "foo_spider_monkey_panel.fb2k-component": bad allocation"

I downloaded right now the Nightly buid from your GitHub project page: https://github.com/TheQwertiest/foo_spider_monkey_panel
using the link you provided for the nightly build:
link https://ci.appveyor.com/api/projects/theqwertiest/foo-spider-monkey-panel/artifacts/_result%2FWin32_Release%2Ffoo_spider_monkey_panel.fb2k-component?branch=master&job=Configuration%3A%20Release

Regards, Andrea


Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #336
I need some clarification about memory usage. I'm monitoring the panel and the total memory usage of a one SMP only configuration and I was expecting the two values to coincide. Instead, panel memory usage reaches 52 MB before GC kicks in, while total memory usage is more or less stuck on 2 MB. How is that? Why is total memory usage lower than panel memory usage?
I'm late

 

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #337
Hello @TheQwertiest , I am getting the same error: Could not load component "foo_spider_monkey_panel.fb2k-component": bad allocation.

By the way, is it correct that this package is 57MB in size and that I had to rename the file removing the ending "_debug"?

Regards, Andrea

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #338
I need some clarification about memory usage. I'm monitoring the panel and the total memory usage of a one SMP only configuration and I was expecting the two values to coincide. Instead, panel memory usage reaches 52 MB before GC kicks in, while total memory usage is more or less stuck on 2 MB. How is that? Why is total memory usage lower than panel memory usage?
What smp version are you using?

Hello @TheQwertiest , I am getting the same error: Could not load component "foo_spider_monkey_panel.fb2k-component": bad allocation.
Hm... That's really weird. Can you check if installation of the latest release version (v1.2.2) works? I'm not even sure if it's a SMP error anymore...
Oh and what's your fb2k version?

By the way, is it correct that this package is 57MB in size and that I had to rename the file removing the ending "_debug"?
Yes, that's correct. Another user has informed me that I forgot to include some files though, so it wouldn't have worked even if your installation succeeded.


Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #340
v1.2.2-preview+0db3c6a4
Calculating total memory usage is actually not a `free` operation in terms of performance (compared to panel memory usage), so to minimize performance impact it uses cached value, which is updated every GC cycle. In some cases (e.g. yours) this might result in incorrect values. I'll see if smth can be done to make reported values more accurate.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #341
Thanks for the answer. Since it's a one-panel configuration, can I presume the total memory consumption to be that of the only panel, or does the component use more memory besides the panel shares?
I'm late

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #342
Thanks for the answer. Since it's a one-panel configuration, can I presume the total memory consumption to be that of the only panel, or does the component use more memory besides the panel shares?
SMP needs additional memory for JS engine and for internal usage, but it's safe to assume that panel is the one that contributes the most to memory usage (unless it contains nothing :P).
The memory impact of SMP will be close to zero (citation needed), if there are no SMP panels active.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #343
Hello @TheQwertiest, I am sorry, I have bad news: no way for me to install ever the v1.2.2-preview.
I am getting the same error.
I would like to try to remove the current version I have running:

Spider Monkey Panel v1.2.3-beta+61085bf2 by TheQwertiest
Based on JScript Panel by marc2003
Based on WSH Panel Mod by T.P. Wang

Build: 10:49:05, Nov 11 2019
Columns UI SDK Version: 6.5


But what about if then I cannot reinstall any?

Regards, Andrea

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #344
Created a basic website for SMP documentation - https://theqwertiest.github.io/foo_spider_monkey_panel
Notable features:
- Built-in script documentation (the one that is currently supplied with the component): https://theqwertiest.github.io/foo_spider_monkey_panel/docs/script_documentation/javascript_api
- Script showcase (more like `script list` currently, but I will work on that): https://theqwertiest.github.io/foo_spider_monkey_panel/docs/script_showcase

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #345
👍👍👍
I'm late

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #346
Quote from:  console.log
components loaded
configuration read
on_size
Spider Monkey panel initialized
on_size (3 times)       <=======
UI initialized
foo_custom_database initialized
autoplaylist initialized
foo_enhanced_playcount loaded
start up done (at least start up time is written here in the console log) <-----------------
possible playlist events
on_paint

One way or another, I always stumble on this multiple on_size() fire at start up. I never read other users having problems with it, so I wonder if I'm simply ignoring some document or some common good practice.
Some time ago I learnt that the full window width and height are not available until the last of the three events and consequently instructed my scripts to check the window size before making calculations on it. I relied on the assumption that the window size is either full or 0. But today I found out that the second on_size() sets the window to an intermediate measure, which my code was not expecting. Did the start up procedure change with one of the last updates? Or is it just me, finding out in dribs and drabs how things work ?
Working around such issues is quite easy, as long as I understand correctly what is going on under the hood. Clearly analyzing the console log and making guesses is not enough. Can anybody explain me once and for all how the panel initialization works and why? What is the safe way to initialize objects and variables with values relative to the window size?
I'm late

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #347
Maybe a stupid question (non-programmer btw)....
Is there any difference between SMP and JScript or WSH while rendering text with GdiDrawText? Feels like it is slightly different in details especially for CJK characters, actually SMP has much better effect.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #348
Here's a javascript puzzle not strictly related to SMP, I hope it is not too off topic.

I'm working on a nested objects system, where each object is an item in an array property of a container object. The methods of the container object execute the method with the same name in the nested objects. This is done by calling another method - the forward() method in the code below - so the container constructor function has the following structure:
Code: [Select]
function Container(){
this.items = [obj1, obj2, obj3...];
this.method1 = (...args) => {this.forward('method1', ...args)};
this.method2 = (...args) => {this.forward('method2', ...args)};
this.method3 = (...args) => {this.forward('method3', ...args)};
...
this.methodN = (...args) => {this.forward('methodN', ...args)};
this.forward = (method, ...args) => {
this.items.forEach((item) => {if (method in item) item[method](...args)});
}
}

Since the methods from 1 to N have the same pattern I thought I could make them perfectly alike and thus simply reference the forward() method for all. What I need is to ditch the "method" argument in the forward() method and retrieve it by code from the caller method's name. But it turns out it is harder than I thought. Ideally I would like to write something like:
Code: [Select]
function Container(){
this.items = [obj1, obj2, obj3...];
this.method1 = this.forward;
this.method2 = this.forward;
this.method3 = this.forward;
...
this.methodN = this.forward;
this.forward = ( ...args) => {
this.items.forEach((item) => {
let method = //...code to retrieve the caller*** method's name
if (method in item) item[method](...args)});
}
}

//***if this kind of code did work like I mean, the container's method would not be a caller anymore, just a reference.

It looks like such a typical scenario for javascript that I'm confident there must be a way, but everything I tried failed. Do you have any suggestion?
I'm late

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #349
It looks like such a typical scenario for javascript that I'm confident there must be a way, but everything I tried failed. Do you have any suggestion?
Retrieving caller information was deemed a problematic feature for multiple reasons:
- Makes some optimizations impossible.
- Easy to abuse to make code unreadable.
- (Web-specific) potential security vulnerabilities.

There is `Function.caller` (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/caller), which can be abused to get the name of the function. But this will not be performance friendly (constant regexp parsing) and this method is unavailable in strict mode anyway.

Maybe a stupid question (non-programmer btw)....
Is there any difference between SMP and JScript or WSH while rendering text with GdiDrawText? Feels like it is slightly different in details especially for CJK characters, actually SMP has much better effect.

No intentional changes on my side =)
The only thing I can think of, is that I target Windows 7 as a minimum supported OS, while WSH and JSP target Windows XP, so that could've affected the way GdiDrawText is called, theoretically.

Did the start up procedure change with one of the last updates?
Nope.

Working around such issues is quite easy, as long as I understand correctly what is going on under the hood. Clearly analyzing the console log and making guesses is not enough. Can anybody explain me once and for all how the panel initialization works and why?
Are you using SMP panel as a standalone CUI/DUI panel? Or is it a part of smth like PSS?