Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Source/AlphaTab.JavaScript/Environment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ private static void PlatformInit()

RegisterJQueryPlugin();

Script.Write(
"untyped __js__(\"Math.log2 = Math.log2 || function(x) { return Math.log(x) * Math.LOG2E; };\");");
// polyfills
Script.Write("untyped __js__(\"Math.log2 = Math.log2 || function(x) { return Math.log(x) * Math.LOG2E; };\");");
Script.Write("untyped __js__(\"Int32Array.prototype.slice = Int32Array.prototype.slice || function(begin, end) { return new Int32Array(Array.prototype.slice.call(this, begin, end)) };\");");

// try to build the find the alphaTab script url in case we are not in the webworker already
if (Lib.Global.document)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,16 @@ public AlphaSynthWebWorkerApi(ISynthOutput player, string alphaSynthScriptFile,

try
{
_synth = new Worker(alphaSynthScriptFile);
HaxeString script = "importScripts('" + alphaSynthScriptFile + "')";
var blob = new Blob(Script.Write<object>("[ script ]"));
_synth = new Worker(URL.CreateObjectURL(blob));
}
catch
{
// fallback to blob worker
// fallback to direct worker
try
{
HaxeString script = "importScripts('" + alphaSynthScriptFile + "')";
var blob = new Blob(Script.Write<object>("[ script ]"));
_synth = new Worker(URL.CreateObjectURL(blob));
_synth = new Worker(alphaSynthScriptFile);
}
catch (Exception e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,32 @@ internal class AlphaTabWorkerScoreRenderer<T> : IScoreRenderer
public AlphaTabWorkerScoreRenderer(AlphaTabApi<T> api, Settings settings)
{
_api = api;
// first try blob worker
try
{
_worker = new Worker(settings.Core.ScriptFile);
HaxeString script = "importScripts('" + settings.Core.ScriptFile + "')";
var blob = new Blob(new[]
{
script
});
_worker = new Worker(URL.CreateObjectURL(blob));
}
catch
catch (Exception e)
{
// fallback to blob worker
// fallback to direct worker
try
{
HaxeString script = "importScripts('" + settings.Core.ScriptFile + "')";
var blob = new Blob(new[]
{
script
});
_worker = new Worker(URL.CreateObjectURL(blob));
_worker = new Worker(settings.Core.ScriptFile);
}
catch (Exception e)
catch
{
Logger.Error("Rendering", "Failed to create WebWorker: " + e);
// TODO: fallback to synchronous mode
}
}



_worker.PostMessage(new
{
cmd = "alphaTab.initialize",
Expand Down