1

Is it possible at all, or traces are part of the API which is not avalible from background Worker?

Consider this code:

public class Main extends Sprite {
  public function Main(container : DisplayObjectContainer = null) 
  {  
    if(Worker.current.isPrimordial) {
      trace("isPrimordial");
      var m_worker : Worker = WorkerDomain.current.createWorker(this.loaderInfo.bytes);
      m_worker.start();
    }
    else {
      trace("is NOT Primordial");
    }
  }

The string "is NOT Primordial" does not appear, however I do see that m_worker.state is "WorkerState.RUNNING".

Some UPDATE: The main thread works and racts to events, however it appears like the backgroung worker does not start until I desconnect the debugger.

And if it is possible, how do I setup the fdb to show these logs?

PS. Im using flash standalone debug player 13 with latest FDT and Apache Flex 4.12.1 SDK.

Paul E
  • 137
  • 7
  • Where do you put this code? Maybe this part of code is just not executed at all inside worker thread. – Vesper Jun 23 '14 at 08:30
  • For example in the constructor of main Sprite class. It appears like the background worker does not start at all when the debugger attahced, and it starts to work in the moment I detach the debugger. – Paul E Jun 23 '14 at 09:33

2 Answers2

2

Ok, so the results for now are:

The background thread (Worker) can write traces with no problems at all if the debugger is not attached, for example if we are using flashlog.txt for the output (output to file).

What is required is: flash debug player (me used v. 14 stand alone and firefox versions).

The setup for using text file as output discussed here: http://helpx.adobe.com/flash-player/kb/configure-debugger-version-flash-player.html http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7fc9.html

Correct location of mm.cfg on modern operating systems (and not on Win95!) discussed here: https://forums.adobe.com/thread/1218258

For me the output to file started to work only after the flashlog.txt file was created by some 3rd party tool (I used Vizzy), but probably it is a permission problem of flasho n windows 8 and the file just can be created manually.

Detailed discussion of the flash traces topic (althoug a little old, but mostly still relevant) is here: See trace() of Flash when running in browser

Thanks everyone for help.

Community
  • 1
  • 1
Paul E
  • 137
  • 7
0

Create a static Log class that output it's log to trace. Use this log class in your main thread and in your worker. Only the main thread log definition will be used allowing to trace from anywhere.

BotMaster
  • 2,253
  • 1
  • 11
  • 16
  • Thanks for the proposal. I already have tryed some similar approach: created a MessageChannel between two threads. However with debugger attached to debug player (to actually see traces), the background worker does not start to run at all. So my main problem is starting the background worker without detaching the debugger. – Paul E Jun 24 '14 at 07:01
  • That's still the answer to your question. After your edit your question is different. – BotMaster Jun 24 '14 at 11:11
  • It's still not the answer. After many tests, I got some intermediate results. The background thread (Worker) can produce to traces with no problems at all, for example if using flashlog.txt as the output. – Paul E Jun 30 '14 at 08:44
  • @BotMaster Paul E's answer is perfect. Put here your code, so everybody will see if it works. Voted down: too broad! – helloflash Jan 13 '15 at 18:22