alphaTab
alphaTab copied to clipboard
AlphaTabApi does not work on Android OS <= 28
Is there an existing issue for this?
- [X] I have searched the existing issues
Current Behavior
After updating alphatab to the last stable version (1.2.2), the score sheet is not loaded anymore for all the android devices with a OS <= 28.
When we call to new alphaTab.AlphaTabApi(element, options)
we are getting this error: Uncaught TypeError: alphaTab.alphaTabApi is not a constructor
.
Another error that we are getting for this OS that we are seeing on above OS' is this one: "Uncaught ReferenceError: globalThis is not defined", source: file:///android_asset/alphatab/alphaTab.min.js (17)
, maybe this could help for seeing where the problem.
Whatever you need to see where the problem is, I'll help to :)
Expected Behavior
new alphaTab.AlphaTabApi(element, options) call should work for OS <= 28 as it was working on version 0.9.8 (it was the version that we were using before the update).
Steps To Reproduce
Make the call to AlphaTabApi with an android device with an OS <= 28 (I've used the Pixel 2 from Android Studio )
Link to jsFiddle, CodePen, Project
No response
Found in Version
1.2
Platform
Android (WebView)
Environment
- **OS**:Android 28
- **Browser**:
- **.net Version**:
Anything else?
No response
To give more context to the problem, rolling back to version 1.1.0 the problem disappears. So I could say that this bug was introduced in the version 1.2.0
There is a lot that can go wrong in such cases. Can you please provide an example project showing the issue? It is crucial to know what exact browser version you are using. Even with the WebView there are specifics to it (it's updated through play store in some cases). It is also important to know how you have configured the WebView.
The globalThis
is definitly the root cause for the next issues.
https://chromestatus.com/feature/6571514765770752
https://caniuse.com/?search=globalthis
But there is a error handling around the globalThis access, so I am still wondering where exactly this might be caused: https://github.com/CoderLine/alphaTab/blob/v1.2.2/src/Environment.ts#L163
Also please name the exact image you use for testing to be sure I can reproduce it. At the time when I was working on version 1.2 I was owning a real Pixel 2 XL and was testing with it. So it is unlikely a general issue.
Hi @Danielku15! The project where I'm using AlphaTab is Fretello. The issue it is not in production, so you'll cannot see it anyway.
As you have said, we are using a WebView for displaying alphaTab in our app. This is the configuration used in our app for the WebView (NotesViewClient extends WebViewClient):
The exact image was a Pixel 2 but with an Android OS 28, i.e., Android 9. I think that you are going to be capable of reproducing the issue with any device or virtual machine with an OS from 9 to below
I might have a look, but it likely takes time to setup a project similar to how Fretello uses alphaTab.
@kiketen The problem seems to be already fixed in 1.3. This line is to blame in 1.2.2 https://github.com/CoderLine/alphaTab/blob/v1.2.2/src/Environment.ts#L460
It would have been fixed as part of #570 but when backporting to 1.2.1 in d9c7834ef5b4a9f48a4b0586207847471ff0cab2 The affected code was not fully updated. I will fix it in 1.2.3. Until then you could patch the alphaTab file locally.
The unminimized file has the related code in line 36356 (change globalThis
to Environment.globalThis
)
The minimized file has the related code around offset 611412
I will mark this issue as closed as it is fixed in 1.3. Will try to get this also fixed in 1.2.x