Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

index.html not rendering or showing what gama_client.js is supposed to show #2

Closed
xiaofanliang opened this issue Feb 8, 2023 · 17 comments

Comments

@xiaofanliang
Copy link

xiaofanliang commented Feb 8, 2023

Hi great people!

Thanks for investing in my issues.

I found the GAMA headless server https://gama-platform.org/wiki/HeadlessServer#hello-world-visualization-in-mapbox and tried to run a copy on my local machine. I had not been successful yet (elaboration below). I assume this server and the JS client allow me to run and show GAMA simulation results on the web. Have there been any successful examples deployed on the web that I can click and see?

For the issue I ran into, here is an elaboration:

I am using a MacOS M1 Chip computer, with a M1 chip GAMA installation. I followed the steps in this webpage: https://gama-platform.org/wiki/HeadlessServer#hello-world-visualization-in-mapbox to start a headless server and try to run the HellowWorld Visualization in Mapbox (JS client).
 
To start the server, I entered the following codes in my terminal:

cd Gama.app/Contents/headless
bash gama-headless.sh -socket 6868

The server seems to start fine:
Screen Shot 2023-02-08 at 11 31 06 AM

Then, I go to the gama.client.js to modify the path of the library model file (highlighted). The path is found by opening the specific library model in local GAMA software, going to File -> Properties -> Location.

I uncommented the example that is on road traffic and commented out all other examples (see below).

Screen Shot 2023-02-08 at 11 32 58 AM

Then in the same gama_client.js, I modify the local path to Websocket to ws://localhost:6868/, because that is the port in the server.

Screen Shot 2023-02-08 at 11 35 00 AM

That are ALL the changes I made. Then, I opened the index.html file in my browser and it shows this: The base map is rendered correctly, but no simulation is rendered (I am expecting something from gama_client.js).

Screen Shot 2023-02-08 at 11 38 57 AM

Once I loaded the index.html, the terminal says:
0:0:0:0:0:0:0:1 entered the room!
 
And there are no other error messages. I am not sure how to interpret the error warnings in the browser inspector.
 
I tried the following approaches, and it did not solve the problem:
-       Change to a different port
-       Change to a different html (e.g., syntax.html)
-       Change to a different browser
 
Any idea of what to go next will be appreciated because I am clueless. Thanks!

@hqnghi88
Copy link
Member

hqnghi88 commented Feb 9, 2023

Please try again with my new commit (of course with the latest alpha version of GAMA).

@xiaofanliang
Copy link
Author

xiaofanliang commented Feb 9, 2023

Hi! @hqnghi88 thanks for updating. I re-downloaded the alpha version of the GAMA, clone the new repo, and repeat my steps above, but the same issues persist. There are no error messages on the browser or the terminal.

This is the view when I opened index.html on my browser. Am I supposed to see the simulation running from gama_client.js? Are my steps above the right way to load the examples?

Screen Shot 2023-02-09 at 3 31 42 PM

@hqnghi88
Copy link
Member

hqnghi88 commented Feb 9, 2023

Your steps are right, what is in console tab (you are showing network, please see in console)?

@xiaofanliang
Copy link
Author

xiaofanliang commented Feb 9, 2023

You can see the console tab output on the bottom right of the image. It did not report any error message. Not sure if this has any impact, but I open the index.html by double-clicking the file in the local folder, with a path like file:///~/gama.client/index.html rather than ws://localhost:6868/. In fact, ws://localhost:6868/ will not load on the browser (it says sites cannot be reached).

@hqnghi88
Copy link
Member

hqnghi88 commented Feb 9, 2023

Yes it is supposed to open index.html , ws is a websocket and browser address cant process that kind. Nothing in the terminam where gamaserver launched?

@hqnghi88
Copy link
Member

hqnghi88 commented Feb 9, 2023

You should pull gama.client repo, i changed the code in that repo, not the gama repo (just be sure you are using the latest alpha)

@xiaofanliang
Copy link
Author

xiaofanliang commented Feb 10, 2023

Yes, I pulled the gama.client repo, not the GAMA repo, and installed the alpha version: GAMA_1.9.0_MacOS_M1_02.09.23_4b82ffc7.dmg. There is no error message on the terminal where gamaserver is launched. It just says: 0:0:0:0:0:0:0:1 entered the room!

@hqnghi88
Copy link
Member

Send me your gamaclient.js

@xiaofanliang
Copy link
Author

xiaofanliang commented Feb 10, 2023

Do you need to have JAVA or Eclipse installed or configured in a specific way? I just restarted my computer fresh and rerun the process on my Mac M1 and my friend's window system (both installed with Alpha version. I installed GAMA_1.9.0_MacOS_M1_02.09.23_4b82ffc7.dmg and he installed GAMA_1.9.0_Windows_with_JDK_02.09.23_4b82ffc7.exe). I configured path to the model through the application, and he configured the path to the model through git version of GAMA. both of us ran into JAVA-related issues in the server.

My error starts even before GAMA can listen on the port:
screenshot

His error starts after the listening:
329840276_1367576724061970_74724495388094605_n

I attached my gamaclient.js in case you still want to take a look:
https://drive.google.com/file/d/1FyDZ6c16nNATJv3YclFd_vSX7H6yeHvI/view?usp=sharing

Thanks for digging into this rabbit hole. I tried reinstalled GAMA and start all the process fresh again and now the JAVA errors persist. They did not show up before.

@hqnghi88
Copy link
Member

Hi i will see your js. The windows machine must have admin right access or it will alway return randomly error….

@hqnghi88
Copy link
Member

I checked your js and it's perfect, do you have any changes in GAMA.js so that it is not updated? Even if the path it should show a message as:
Screenshot 2023-02-10 at 15 08 44
Regarding the 2 error message, it is relate with the path and access right, please try with the highest priviledges on each OS (sudo or administrator)

@neo
Copy link

neo commented Feb 10, 2023

I think the Could not find or load main class org... error could be because you didn't run the bash script from the headless directory?

@xiaofanliang
Copy link
Author

xiaofanliang commented Feb 10, 2023

@hqnghi88 I saw that that error message (Invalid LngLat object) shows up at one point in my trial at the window computer. It never shows in Mac. I will try to set the privileges and see if that works.

@xiaofanliang
Copy link
Author

I think the Could not find or load main class org... error could be because you didn't run the bash script from the headless directory?

It shows the same error even if I start in the headless directory.
screen

@neo
Copy link

neo commented Feb 10, 2023

It seems like realpath was introduced in this commit gama-platform/gama@240559e in gama-headless.sh but it's actually only available in linux but not in mac?

@xiaofanliang
Copy link
Author

xiaofanliang commented Feb 10, 2023

I think @neo is right. I switched my GAMA back to 1.8 version and the server can start fine without the JAVA issue (but then the rendering issues loop back to what I had at the very beginning, which is no error messages whatsoever but cannot load simulation).

I followed @neo's suggestion and go to my sh file and change this line (it is essentially revert the commit mentioned above)
if ! "$( dirname $( realpath "${BASH_SOURCE[0]}" ) )"
back to the previous commit
if ! "$( dirname "${BASH_SOURCE[0]}" )"

and then start the server with GAMA 1.9 version, and the index.html is running smoothly like below
s

and syntax.html is reporting statistics
ss

and SimpleGUI_new.html is functional except for a few toy examples. It also requires tweaking the absolute and model path. Right now the way the path is programmed requires users to download GAMA github version (https://github.com/gama-platform/gama). I did that, but there are still some examples that cannot be run. For example, Simple Traffic Model.gaml reported the following errors.
sss

In conclusion, this gama.client can only run on 1.9 version, and need a few tweaks in gama-headless.sh for Mac users (may not need it for Linux) to start the server. Some library examples cannot be run in the SimpleGUI_new.html.

@hqnghi88
Copy link
Member

Hi,
I am not really a pro user mac but im currently can launch the bash headless.sh on m1. So may be you can open an issue on gama repository if you think the scripts must be changed.
The syntax.html is not pre-defined statistics but it s a real simulation on an example server.
Regarding simpleGUI , it is as you tested, some specific model cannot launch for the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants