Skip to main content
Topic: Spider Monkey Panel (foo_spider_monkey_panel) (Read 75786 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #500
You sure? Just tested and it works exactly as expected with () in the filename.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #501
Hi snotlicker
Thanks for the quick response. You are correct and I'm guilty of such a stupid js school-boy error. Too embarrassed to tell what I'd done wrong. All working now. Thanks.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #502
BTW, I stupidly had clicked the "don't show me this again" checkbox. Is deleting the foo_spider_monkey.dll.cfg good enough to reset that? It didn't reset the panel configuration so some data is being stored elsewhere at least.

"don't show me this again" options is fb2k-instance-local. Meaning that it only affects the current process of fb2k and it does not persist across different fb2k launches.

@ your "hanging" problem: I'm trying to make "Slow script" dialog async, so that it would not halt the script execution. But I don't think I can do anything other than that.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #503
Does that mean you could also hide the dialog again, once things become responsive again, or no? Even if not it'd be a big improvement since users would be able to see the theme load behind the dialog.


Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #505
I'm trying  to process selected files from a playlist. Firstly I want to convert them and I'm using:
fb.RunContextCommandWithMetadb("Convert/mp3 tablet",handle_list);
then I want to embed the album cover. My problem is the the RunContextCommand doesn't block so I need an event that is raised when all the files have been converted. Any ideas?


Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #507
I'm trying  to process selected files from a playlist. Firstly I want to convert them and I'm using:
fb.RunContextCommandWithMetadb("Convert/mp3 tablet",handle_list);
then I want to embed the album cover. My problem is the the RunContextCommand doesn't block so I need an event that is raised when all the files have been converted. Any ideas?
In general you could use something like the code below. You need to replace <get handleList> and <do the processing for metaDb> with valid code and you might need to play a little bit with the timings.
Code: [Select]
const handleList= <get handleList>;                                         

fb.RunContextCommandWithMetadb("Convert/mp3 tablet",handleList);
 
const processItem=() => {
  if(!handleList.Count) return false;
     
  const metaDb=handleList[0];

  <do the processing for metaDb>

  handleList.RemoveById(0);

  return Boolean(handleList.Count);
};

() => {
   if(!processItem()) return;
   
   setTimeout(arguments.callee,20);
}();

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #508
That seems dangerous to me. You're essentially just guessing that each file will be written in 20ms. If HDDs need to spin back up, or a file is huge, this will fail just like B_O_B_M's original case.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #509
That seems dangerous to me. You're essentially just guessing that each file will be written in 20ms. If HDDs need to spin back up, or a file is huge, this will fail just like B_O_B_M's original case.
No, it's not dangerous. You just need to make additional tests during the processing and return false return true, if the file, which needs to be processed is not ready. Additionally a guard should be implemented to avoid endless processing.

Edit: Corrected and extended the answer.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #510
@All. Thanks for your replies. My best effort was to create an autoplaylist targeted at the destination for the converted files. I made a note of the file total and tested the playlist index of the autoplaylist and file count in the 'on_playlist_items_added(playlistIndex)' event. When I had all the files in the destination folder, I continued and embedded the album image in them all. Seems to work so far.

Thanks for your valuable time spent in helping me on this.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #511
@MordredKLB , I've tinkered around a bit . Regretfully, it seems that it's impossible to make `slow script` dialog asynchronyous (without writing/using a new GUI stack): the problem is that GUI handling/processing is performed on the main thread, so if the main thread is stuck (e.g. in the infinite loop in JS), then no GUI messages can be processed making it impossible to interact with any dialogs (including `slow script` dialog).

While I understand your problem, I just don't know what can be done without removing the `slow script` check. I will try to extend the time limit a bit for the script on fb2k startup (in case there's some async stuff that hogging up the CPU), but it's still won't be a universal solution and it might not help much in your case.

[EDIT] Welp, no idea how to check that fb2k has loaded everything. Hence decided to make `slow script` time limit configurable (Advanced > SMP > Performance > Execution time limit).

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #512
@MordredKLB , I've tinkered around a bit . Regretfully, it seems that it's impossible to make `slow script` dialog asynchronyous (without writing/using a new GUI stack): the problem is that GUI handling/processing is performed on the main thread, so if the main thread is stuck (e.g. in the infinite loop in JS), then no GUI messages can be processed making it impossible to interact with any dialogs (including `slow script` dialog).

While I understand your problem, I just don't know what can be done without removing the `slow script` check. I will try to extend the time limit a bit for the script on fb2k startup (in case there's some async stuff that hogging up the CPU), but it's still won't be a universal solution and it might not help much in your case.

[EDIT] Welp, no idea how to check that fb2k has loaded everything. Hence decided to make `slow script` time limit configurable (Advanced > SMP > Performance > Execution time limit).
Thanks for investigating and I was afraid that might be the issue.

In further thinking, I might play around with async loading, just to see if maybe that can help. It all depends on what's actually happening behind the scenes with FB freezes trying to read from the HDD. i.e. do the other threads completely get locked out while that's happening, or are they just processing very slowly. If it's the first (which seems likely) then there's nothing to be done, but if it's the second, it might make this issue harder to encounter. It's weird though that SMP can still display the dialog.

Honestly this seems like a FB issue, and I'm wondering if we should report to @Peter .

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #513
It's weird though that SMP can still display the dialog.
SMP can display a modal `slow script` dialog during JS execution, because this dialog is invoked during JS interruption callback (i.e. it actually stops JS execution, thus it no longer stalls the main thread). The dialog could not have been displayed if the main thread was stalled by smth not JS related (this `not JS related` stuff might slow-down JS execution enough to trigger the `slow script` though).

If you have a debugger (e.g. visual studio), you may try to diagnose the issue by attaching to fb2k and breaking during the freeze. It will at least show the `.dll` on which fb2k is stuck.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #514
Well this is my confusion. Are you saying SMP executes the JS in the main thread then? In that case I would have thought that the interruption handler wouldn't have been able to work since it's also on the main thread, unless I'm misunderstanding how that even works.

I might try the debugger trick, or maybe just wait and see if I'm the only one actually running into the issue. It's a pain in the ass to get conditions right to even occur naturally (although I haven't messed with HDD spin-down times yet...)

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #515
Are you saying SMP executes the JS in the main thread then?
Yep. Most of the JS stuff is executed on the main thread. A lot (most?) of GC is performed on worker threads though (memory deallocation is not cheap, so it gives a good performance boost).

In that case I would have thought that the interruption handler wouldn't have been able to work since it's also on the main thread, unless I'm misunderstanding how that even works.
I didn't look in the Spider Monkey internals too much, but it probably looks smth like this:

Code: [Select]
// SM internals
// Everything here is executed on the main thread

void JSMachineRunner()
{
  while (hasStuffToDo)
  {
    auto currentPart = GetNewPart();
    ExecuteJSMaybe(currentPart);
  }
}

void ExecuteJSMaybe(JSPart part)
{
  if (interruptRequested)
  {
    InvokeInterruptCallback();
  }
  ExecuteJS(part);
}

I.e. in JS engine itself the JS code is not monolithic, but split in parts that are fed in a JS runner (even an infinite loop like `while(true){}`). Thus making the interruption (and `slow script` dialog) possible.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #516
Got it. Well, i'll give the async script loading a shot. Wrap every file in a await promise with setTimeout(() => {}, 1) and see if that improves the situation.

 

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #517
problem 1: Artist Images (thumbs.js)

help to configure the paths for displaying the covers in the "covers" folder, the problem is that sometimes I place this folder in the album, it is one level higher (in the case of a two-disc edition) - I just can't configure the second option. I want the code to look for the "covers" folder first in the lower directory, then, not finding it there, went up one level, and so on

problem 2: last.fm similar artists + user charts + recent tracks

similar unicode characters are not displayed correctly (bands in German, French)

problem 3: last.fm

I can not configure the folder for uploading photos from last.fm to the same directory as the artist

problem 4: musicbrainz

the discography is sorted by year in reverse order and I want to increase

 
SimplePortal 1.0.0 RC1 © 2008-2020