This page is no longer maintained — Please continue to the home page at www.scala-lang.org

actors in applets: problem if return to the page

8 replies
Rob Dickens
Joined: 2008-12-20,
User offline. Last seen 42 years 45 weeks ago.
Dear all,

I'm encountering a problem if I return to a web page containing an applet that's using actors.

For a demonstration, the following page has the applet links:
http://lafros.com/Misc/actors-applet

There is also a problem if I reload the page, although this appears to be confined to the JDK 1.5 browser plug-in.

If anyone has any ideas about how to fix this, please could they respond.

The following tickets have been created:

actors cannot tolerate page reloads in JDK 1.5 plug-in applets
https://lampsvn.epfl.ch/trac/scala/ticket/1688

actors cannot tolerate returning to JDK 1.5 or 1.6 plug-in applet pages
https://lampsvn.epfl.ch/trac/scala/ticket/1848

Thanks,
--
Rob, Lafros.com
tolsen77
Joined: 2008-10-08,
User offline. Last seen 1 year 38 weeks ago.
Re: actors in applets: problem if return to the page
I guess you'll have to manually reference all actors and do a cleanup when your applet exit or is there a simple "kill-switch" for them? I retried my applet with browsing back and forth and the old actors also responds when I communicate from Javascript.

On Thu, Apr 2, 2009 at 4:08 PM, Rob Dickens <arctic.bob@googlemail.com> wrote:
Dear all,

I'm encountering a problem if I return to a web page containing an applet that's using actors.

For a demonstration, the following page has the applet links:
http://lafros.com/Misc/actors-applet

There is also a problem if I reload the page, although this appears to be confined to the JDK 1.5 browser plug-in.

If anyone has any ideas about how to fix this, please could they respond.

The following tickets have been created:

actors cannot tolerate page reloads in JDK 1.5 plug-in applets
https://lampsvn.epfl.ch/trac/scala/ticket/1688

actors cannot tolerate returning to JDK 1.5 or 1.6 plug-in applet pages
https://lampsvn.epfl.ch/trac/scala/ticket/1848

Thanks,
--
Rob, Lafros.com

Rob Dickens
Joined: 2008-12-20,
User offline. Last seen 42 years 45 weeks ago.
Re: actors in applets: problem if return to the page
Trond,

Okay will try maintaining a reference, and have the destroy() use it to tell the actor to exit().

Thanks,

Rob

2009/4/2 Trond Olsen <tolsen77@gmail.com>
I guess you'll have to manually reference all actors and do a cleanup when your applet exit or is there a simple "kill-switch" for them? I retried my applet with browsing back and forth and the old actors also responds when I communicate from Javascript.

On Thu, Apr 2, 2009 at 4:08 PM, Rob Dickens <arctic.bob@googlemail.com> wrote:
Dear all,

I'm encountering a problem if I return to a web page containing an applet that's using actors.

For a demonstration, the following page has the applet links:
http://lafros.com/Misc/actors-applet

There is also a problem if I reload the page, although this appears to be confined to the JDK 1.5 browser plug-in.

If anyone has any ideas about how to fix this, please could they respond.

The following tickets have been created:

actors cannot tolerate page reloads in JDK 1.5 plug-in applets
https://lampsvn.epfl.ch/trac/scala/ticket/1688

actors cannot tolerate returning to JDK 1.5 or 1.6 plug-in applet pages
https://lampsvn.epfl.ch/trac/scala/ticket/1848

Thanks,
--
Rob, Lafros.com


tolsen77
Joined: 2008-10-08,
User offline. Last seen 1 year 38 weeks ago.
Re: actors in applets: problem if return to the page
Updated my own code with a Exit() message for manual release of all the actors and the applet now exits properly with back-forward on history.

On Thu, Apr 2, 2009 at 5:58 PM, Rob Dickens <arctic.bob@googlemail.com> wrote:
Trond,

Okay will try maintaining a reference, and have the destroy() use it to tell the actor to exit().

Thanks,

Rob

2009/4/2 Trond Olsen <tolsen77@gmail.com>
I guess you'll have to manually reference all actors and do a cleanup when your applet exit or is there a simple "kill-switch" for them? I retried my applet with browsing back and forth and the old actors also responds when I communicate from Javascript.

On Thu, Apr 2, 2009 at 4:08 PM, Rob Dickens <arctic.bob@googlemail.com> wrote:
Dear all,

I'm encountering a problem if I return to a web page containing an applet that's using actors.

For a demonstration, the following page has the applet links:
http://lafros.com/Misc/actors-applet

There is also a problem if I reload the page, although this appears to be confined to the JDK 1.5 browser plug-in.

If anyone has any ideas about how to fix this, please could they respond.

The following tickets have been created:

actors cannot tolerate page reloads in JDK 1.5 plug-in applets
https://lampsvn.epfl.ch/trac/scala/ticket/1688

actors cannot tolerate returning to JDK 1.5 or 1.6 plug-in applet pages
https://lampsvn.epfl.ch/trac/scala/ticket/1848

Thanks,
--
Rob, Lafros.com



Rob Dickens
Joined: 2008-12-20,
User offline. Last seen 42 years 45 weeks ago.
Re: actors in applets: problem if return to the page
Still can't get it to work, even doing the following:

* applet init: actor = new MyActor; actor.start()

* applet destroy: actor ! cmds.exit; actor = null

* class MyActor: breaks out of receive loop on receipt of cmds.exit, and calls exit

When I return to the page, and actor.start() is called, I get the following:

new instance created
init()
java.lang.IllegalThreadStateException
    at java.lang.ThreadGroup.add(ThreadGroup.java:846)
    at java.lang.Thread.start(Thread.java:596)
    at scala.actors.FJTaskRunnerGroup.signalNewTask(Unknown Source)
    at scala.actors.FJTaskRunnerGroup.execute(Unknown Source)
    at scala.actors.FJTaskScheduler2.execute(FJTaskScheduler2.scala:164)
    at scala.actors.Scheduler$.execute(Scheduler.scala:91)
    at scala.actors.Actor$class.start(Actor.scala:782)
    at com.lafros.MyActor.start(ActorsApplet.scala:30)
    at com.lafros.ActorsApplet.init(ActorsApplet.scala:13)
    at sun.applet.AppletPanel.run(AppletPanel.java:424)
    at java.lang.Thread.run(Thread.java:619)

2009/4/3 Trond Olsen <tolsen77@gmail.com>
Updated my own code with a Exit() message for manual release of all the actors and the applet now exits properly with back-forward on history.

On Thu, Apr 2, 2009 at 5:58 PM, Rob Dickens <arctic.bob@googlemail.com> wrote:
Trond,

Okay will try maintaining a reference, and have the destroy() use it to tell the actor to exit().

Thanks,

Rob

2009/4/2 Trond Olsen <tolsen77@gmail.com>
I guess you'll have to manually reference all actors and do a cleanup when your applet exit or is there a simple "kill-switch" for them? I retried my applet with browsing back and forth and the old actors also responds when I communicate from Javascript.

On Thu, Apr 2, 2009 at 4:08 PM, Rob Dickens <arctic.bob@googlemail.com> wrote:
Dear all,

I'm encountering a problem if I return to a web page containing an applet that's using actors.

For a demonstration, the following page has the applet links:
http://lafros.com/Misc/actors-applet

There is also a problem if I reload the page, although this appears to be confined to the JDK 1.5 browser plug-in.

If anyone has any ideas about how to fix this, please could they respond.

The following tickets have been created:

actors cannot tolerate page reloads in JDK 1.5 plug-in applets
https://lampsvn.epfl.ch/trac/scala/ticket/1688

actors cannot tolerate returning to JDK 1.5 or 1.6 plug-in applet pages
https://lampsvn.epfl.ch/trac/scala/ticket/1848

Thanks,
--
Rob, Lafros.com




tolsen77
Joined: 2008-10-08,
User offline. Last seen 1 year 38 weeks ago.
Re: actors in applets: problem if return to the page
Not sure what that error is, but I did notice that the tray icon for Java goes away when I now go back-forward. I'm only using the latest 1.6 release though.

Here's the code that I used
// my exit case class
object Application {
  case class Exit()
}

// on applet.destroy
myActor ! Application.Exit()

// message handling loop in the actors
loop {
    try {
        react {
            case Application.Exit() => exit
            case msg @ _ => error("Unhandled actor message " + msg + " found")
        }
    }
    catch {
        case exp: Exception => // error handling
        case exp: java.lang.NullPointerException => // error handling
    }
}


On Fri, Apr 3, 2009 at 11:54 AM, Rob Dickens <arctic.bob@googlemail.com> wrote:
Still can't get it to work, even doing the following:

* applet init: actor = new MyActor; actor.start()

* applet destroy: actor ! cmds.exit; actor = null

* class MyActor: breaks out of receive loop on receipt of cmds.exit, and calls exit

When I return to the page, and actor.start() is called, I get the following:

new instance created
init()
java.lang.IllegalThreadStateException
    at java.lang.ThreadGroup.add(ThreadGroup.java:846)
    at java.lang.Thread.start(Thread.java:596)
    at scala.actors.FJTaskRunnerGroup.signalNewTask(Unknown Source)
    at scala.actors.FJTaskRunnerGroup.execute(Unknown Source)
    at scala.actors.FJTaskScheduler2.execute(FJTaskScheduler2.scala:164)
    at scala.actors.Scheduler$.execute(Scheduler.scala:91)
    at scala.actors.Actor$class.start(Actor.scala:782)
    at com.lafros.MyActor.start(ActorsApplet.scala:30)
    at com.lafros.ActorsApplet.init(ActorsApplet.scala:13)
    at sun.applet.AppletPanel.run(AppletPanel.java:424)
    at java.lang.Thread.run(Thread.java:619)

2009/4/3 Trond Olsen <tolsen77@gmail.com>
Updated my own code with a Exit() message for manual release of all the actors and the applet now exits properly with back-forward on history.

On Thu, Apr 2, 2009 at 5:58 PM, Rob Dickens <arctic.bob@googlemail.com> wrote:
Trond,

Okay will try maintaining a reference, and have the destroy() use it to tell the actor to exit().

Thanks,

Rob

2009/4/2 Trond Olsen <tolsen77@gmail.com>
I guess you'll have to manually reference all actors and do a cleanup when your applet exit or is there a simple "kill-switch" for them? I retried my applet with browsing back and forth and the old actors also responds when I communicate from Javascript.

On Thu, Apr 2, 2009 at 4:08 PM, Rob Dickens <arctic.bob@googlemail.com> wrote:
Dear all,

I'm encountering a problem if I return to a web page containing an applet that's using actors.

For a demonstration, the following page has the applet links:
http://lafros.com/Misc/actors-applet

There is also a problem if I reload the page, although this appears to be confined to the JDK 1.5 browser plug-in.

If anyone has any ideas about how to fix this, please could they respond.

The following tickets have been created:

actors cannot tolerate page reloads in JDK 1.5 plug-in applets
https://lampsvn.epfl.ch/trac/scala/ticket/1688

actors cannot tolerate returning to JDK 1.5 or 1.6 plug-in applet pages
https://lampsvn.epfl.ch/trac/scala/ticket/1848

Thanks,
--
Rob, Lafros.com





Ricky Clarkson
Joined: 2008-12-19,
User offline. Last seen 3 years 2 weeks ago.
Re: actors in applets: problem if return to the page
    catch {
        case exp: Exception => // error handling
        case exp: java.lang.NullPointerException => // error handling 
    }
  I haven't really read this thread, but I'm guessing you want to swap those two cases around.
tolsen77
Joined: 2008-10-08,
User offline. Last seen 1 year 38 weeks ago.
Re: actors in applets: problem if return to the page
That's just something I hacked onto the message loop. They are handled the same (just logged) in my code. The NullPointerException went uncatched so I just added it.

If there are any better way to add a "catch-em-all" of exceptions to the message loop I'd be interested in a solution.

On Sun, Apr 5, 2009 at 7:01 PM, Ricky Clarkson <ricky.clarkson@gmail.com> wrote:
    catch {
        case exp: Exception => // error handling
        case exp: java.lang.NullPointerException => // error handling 
    }
  I haven't really read this thread, but I'm guessing you want to swap those two cases around.

tolsen77
Joined: 2008-10-08,
User offline. Last seen 1 year 38 weeks ago.
Re: actors in applets: problem if return to the page
Nevermind, it shouldn't matter.

On Mon, Apr 6, 2009 at 5:09 AM, Trond Olsen <tolsen77@gmail.com> wrote:
That's just something I hacked onto the message loop. They are handled the same (just logged) in my code. The NullPointerException went uncatched so I just added it.

If there are any better way to add a "catch-em-all" of exceptions to the message loop I'd be interested in a solution.

On Sun, Apr 5, 2009 at 7:01 PM, Ricky Clarkson <ricky.clarkson@gmail.com> wrote:
    catch {
        case exp: Exception => // error handling
        case exp: java.lang.NullPointerException => // error handling 
    }
  I haven't really read this thread, but I'm guessing you want to swap those two cases around.


Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland