adaptlearning/adapt-contrib-spoor

LZMA errors if run without Web Workers

Closed this issue · 1 comments

Subject of the issue/enhancement/features

If a course is run in an environment without Web Workers, e.g. offline via a mobile app, the course errors on load:
Uncaught TypeError: window.LZMAFactory is not a function

For some reason the LZMA library seems to have been modified to declare LZMAFactory, but hasn't implemented this for all possible conditions when the library is initialised.

Your environment

Proposed solution

Use the latest libraries files:

Modify https://github.com/adaptlearning/adapt-contrib-spoor/blob/master/js/serializers/SCORMSuspendData.js#L6 to use window.LZMA and prefix all LZMA compress and decompress references accordingly. Alternatively prefix these methods with window.LZMA directly and delete the LZMAWorker property.

Seems like lzma-min file was modified to add the LZMAFactory method so lzma-min-worker wouldn't override the LZMA method once loaded, which would prevent the use of Web Workers. Assigning LZMAFactory also maintains the ability for https://github.com/adaptlearning/adapt-contrib-spoor/blob/master/js/serializers/SCORMSuspendData.js#L1144 to be run synchronously.

Ideally the implementation would change to https://gist.github.com/danielghost/045520d0d04c9cef70f36386e78c9a9a, but this would then require deserialize to become asynchronous, causing breaking changes to other methods throughout the framework, so they expect a returned Promise.

For now we will just fix the missing LZMAFactory method when Web Workers are not implemented.