Jump to content


Photo

Webworkers (SMS 2.2.2)


  • Please log in to reply
4 replies to this topic

#1 Nortg

Nortg
  • Members
  • 4 posts
  • Professional Edition

Posted 08 July 2017 - 03:52 PM

Hey,
looking at the WebWorkers demo (..\Smart Mobile Projects\Demos\Featured Demos\API\WebWorker), it seems to only work because the "worker.js"
("..\API\WebWorker\www\") file was compiled with a different compiler version.

If I actually recompile the worker project with the 2.2.2 compiler the demo then fails and reports the following error : "Uncaught ReferenceError: window is not defined [line #193]".

Project options are set to deploy the compiled file in the "output" folder and not the "www" where all the files are located, as such it is the outdated worker.js file that is served to the browser instead of the freshly compiled.

Steps to reproduce :

1. Open Worker.sproj (..\Smart Mobile Projects\Demos\Featured Demos\API\WebWorker)
2. Compile project
3. Move "worker.js" from \output folder to \www folder
4. run index.html or execute the main project through IDE
  • ielite and Nico Wouterse like this

#2 Dennis07

Dennis07
  • Administrators
  • 23 posts
  • LocationBerlin, Germany
  • Enterprise Edition

Posted 31 July 2017 - 10:30 PM

Hey Nortg, sorry for the late response! I am not sure whether you have the latest version installed. But I could not reproduce your error. For me, it worked without problems. Are there maybe any specific compiler settings? What is your SMS version installed?

#3 Nortg

Nortg
  • Members
  • 4 posts
  • Professional Edition

Posted 06 August 2017 - 09:58 AM

Hey Dennis,my SMS version is that available on the website


Smart Mobile Studio 2.2.2
April 18th, 2016


if you follow my steps to reproduce you should run into the same issue, but let me expand,


the webworker demo involves two projects (sproj), "Main Application.sproj" and "Worker.sproj". If you only run the main application then everything will work because inside the /www folder in the same directory, a pre-compiled worker.js already exists. The problem is that this pre-compiled js file was not compiled with the 2.2.2 version. If you actually start the Worker.sproj and compile it, it will drop a fresh worker.js file in the /output folder, and this is the important thing, the project is set to create the file in the output folder and not the www folder of the main project so on it's face you might not see this and think that it works. Simply copy the worker.js file from the output folder to the www folder overwritting the old worker.js file with the new one. Then launch the main application and you will see that it does not work and reports previously mentioned error.

Best Regards

#4 Laksekjønn

Laksekjønn
  • Members
  • 440 posts

Posted 07 August 2017 - 05:21 PM

IMHO this project is buggy, there's an workaround, some minor changes but unfortunately I couldn't attach any file here anymore, it looks like they updated the forum theme to fix the nasty message on FF, and now some wysiwyg features are missing for me.

#5 Laksekjønn

Laksekjønn
  • Members
  • 440 posts

Posted 07 August 2017 - 11:12 PM

This project SMS_INSTALL_FOLDER\projects\Featured Demos\API\WebWorker\ is buggy with the current SMS 2.2.2.4543. Please fix it.

We have to construct/wrapping the main code with exception handling, like this:
uses  workerthread;  

var mTemp: TThread;  
try      
  mTemp := TThread.Create;  
except      
  on e: Exception do ;  
end;
...this is weird, we have to wrap the main code with try..except, then the compiler will emit the expected Exception information in the Worker project.

---> Exception information <---
var Exception={	$ClassName: "Exception",	
$Parent: TObject,	
$Init: function () { FMessage="" },	
Create: function (s,Msg) { s.FMessage=Msg; return s }}
There are another minour issues, in the "Main Application" project it seems like we have an issue with window.postMessage HTML5 method to allow safe communication between window/frames.
TWebWorkerThread.PostMessage <> window.postMessage. An workaround would be renaming the method to work as expected.

Anyway, here is the fixed project: https://www.dropbox....Worker.rar?dl=0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users