leaningtech / cheerpj-meta

Run Java 8 applications, libraries, applets, Java Web Start, and Oracle Forms on the web without legacy plugins.
https://labs.leaningtech.com/cheerpj
445 stars 21 forks source link

Compilation problems with two applets #132

Open DylanBorchert opened 2 years ago

DylanBorchert commented 2 years ago

I’m running into a problem compiling two separate applets on the same page that need to send commands between the two. I have tested them in internet explorer and it works as expected. When I attempt to run the same pair of applets in google chrome with the cheerpj extension it doesn’t work the same.

Here is the page that I’m trying to get running. It’s working fine in IE but not Chrome for some reason

Are there limitations to using the extension that might cause my applet to not work?

marsicplusplus commented 2 years ago

Hi @dborc610, thanks for the report.

How are the applets communicating with each other?

DylanBorchert commented 2 years ago

The applet was originally developed in Java 1.3. Both applets use frameset and frames and each applet would run in those frames. I thought it wasn't working cause frames are obsolete so I converted to iframes, but it still works in IE and not chrome with cheerpj.

The two applets are the three vector simulation and then the page browser applet which needs to communicate with three vector simulation applet so it knows when to change states.

applet.html

<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
WIDTH = "100%" HEIGHT = "100%"  codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0">
<PARAM NAME = CODE VALUE = "ca.ucalgary.phas.map.vectors.VectorApplet.class" >
<PARAM NAME = CODEBASE VALUE = "../../../../../Classes" >
<PARAM NAME = ARCHIVE VALUE = "ucalgaryjars/vectorclasses.jar,ucalgaryjars/utilities.jar,ucalgaryjars/page_browser.jar" >
<PARAM NAME = MAYSCRIPT VALUE = "true" >
<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3">
<PARAM NAME="scriptable" VALUE="false">
<PARAM NAME = "task" VALUE    = "addition3">
<PARAM NAME = "HIDE_TOOLS" VALUE    = "false">
<PARAM NAME = "HELP_URL" VALUE    = "../../../../../Classes/info/vectors/VectorApplet/addition3/applet_help.html">
<PARAM NAME = "APPLET_NAME" VALUE    = "Addition of Three Vectors">
</OBJECT>

page_browser.html

<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
WIDTH = "100%" HEIGHT = "100%"  codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0">
<PARAM NAME = CODE VALUE = "ca.ucalgary.phas.map.contentNavigator.PageBrowser.class" >
<PARAM NAME = CODEBASE VALUE = "../../../../../Classes" >
<PARAM NAME = ARCHIVE VALUE = "ucalgaryjars/vectorclasses.jar,ucalgaryjars/utilities.jar,ucalgaryjars/page_browser.jar" >
<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3">
<PARAM NAME="scriptable" VALUE="false">
<PARAM NAME = "VERBOSE" VALUE     = "false">
<PARAM NAME = "PAGE_COUNT" VALUE     = "4">
<PARAM NAME = "FRAME_COUNT" VALUE     = "2">
<PARAM NAME = "LOAD_FIRST_PAGE_ON_INIT" VALUE     = "false">
<PARAM NAME = "URL_BASE_RELATIVE_TO_DOC" VALUE          = "true">
<PARAM NAME = "URL_BASE_RELATIVE_TO_CODE" VALUE          = "false">
<PARAM NAME = "URL_BASE" VALUE          = "">
<PARAM NAME = "FRAME_NAMES" VALUE     = "Text,Applet">
<PARAM NAME = "FRAME_PAUSE_POLICY" VALUE     = "Text,Applet">
<PARAM NAME = "Text_FRAME_URLS" VALUE     = "page1.html,page2.html,page3.html,page4.html">
<PARAM NAME = "Applet_FRAME_URLS" VALUE     = "applet.html,applet.html,applet.html,applet.html">
<PARAM NAME = "Applet_FRAME_APPLET_NAMES" VALUE     = "addition3vectorapplet,addition3vectorapplet,addition3vectorapplet,addition3vectorapplet">
<PARAM NAME = "Applet_FRAME_APPLET_COMMANDS" VALUE     = "reset,drawvec,find_answer,show_answer">
<PARAM NAME = "PAGE_LIST_VISIBLE" VALUE     = "true">
<PARAM NAME = "PAGE_LIST_ENABLED" VALUE     = "false">
<PARAM NAME = "PAGE_COUNTER_VISIBLE" VALUE     = "false">
<PARAM NAME = "PREV_BUTTON_VISIBLE" VALUE     = "true"> <!--was originally false-->
<PARAM NAME = "NEXT_BUTTON_VISIBLE" VALUE     = "true">
<PARAM NAME = "NEXT_BUTTON_STARTS_ENABLED" VALUE     = "false">
<PARAM NAME = "RESET_BUTTON_VISIBLE" VALUE     = "true">
</OBJECT>

These commands are set in parameters of the page browser applet. Here are the jars three-vector-applets.zip for this applet. This applet is one of many so it's just the "addition of three vectors"

alexp-sssup commented 2 years ago

We have investigated the problem. To the best of our understanding the issue is that the 2 applets assume to be executed by the same Java virtual machine, since they expect to be able to share static variables.

This cannot work in CheerpJ currently, because the 2 applets are in different HTML frames, which correspond to completely independent execution contexts in the browser.

Since HTML frames are a legacy technology, and there is no commercial demand for this specific feature, we cannot commit resources to fix the problem right now.

Your best option forward seems to be restructuring the site to have both applet in the same HTML page.