Skip to content

Commit 02819cb

Browse files
authored
chore: Easier way to provide exact version and environment info. (#2015)
1 parent 43c51b6 commit 02819cb

7 files changed

Lines changed: 98 additions & 27 deletions

File tree

.github/ISSUE_TEMPLATE/bug_report_form.yml

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,27 @@ body:
4343
description: Providing a minimal reproducible example can help a lot.
4444
validations:
4545
required: false
46-
- type: dropdown
47-
id: version
46+
- type: textarea
47+
id: environment
4848
attributes:
49-
label: Found in Version
50-
description: Which version of alphaTab are you using?
51-
options:
52-
- 1.4 (alpha)
53-
- 1.3
54-
- 1.2
55-
- Other
49+
label: Version and Environment
50+
description: |
51+
Please provide detailed information about your environment, like alphaTab version used, browser, device, .net runtime, Android version,..
52+
Since 1.5.0: You can call `alphaTab.Environment.printEnvironmentInfo()` and copy the printed info. Or enable [debug logs](https://www.alphatab.net/docs/reference/settings/core/loglevel) and they are always printed.
53+
Just grab them from the console/debugger/output/logcat output.
54+
placeholder: |
55+
[AlphaTab][VersionInfo] alphaTab 1.5.0
56+
[AlphaTab][VersionInfo] commit: 43c51b693438c54c0023ba729d7a7aa351e0f1fd
57+
[AlphaTab][VersionInfo] build date: 2025-04-13T12:44:25.644Z
58+
[AlphaTab][VersionInfo] High DPI: 1
59+
[AlphaTab][VersionInfo] Browser: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
60+
[AlphaTab][VersionInfo] Platform: BrowserModule
61+
[AlphaTab][VersionInfo] WebPack: false
62+
[AlphaTab][VersionInfo] Vite: false
63+
[AlphaTab][VersionInfo] Window Size: 1529x1152
64+
[AlphaTab][VersionInfo] Screen Size: 3840x1200
65+
66+
render: bash
5667
validations:
5768
required: true
5869
- type: dropdown
@@ -72,21 +83,7 @@ body:
7283
- Other
7384
validations:
7485
required: true
75-
- type: textarea
76-
id: environment
77-
attributes:
78-
label: Environment
79-
description: |
80-
examples:
81-
- **OS**: Windows 10 Pro
82-
- **Browser**: Chrome 92.0.4515.159
83-
value: |
84-
- **OS**:
85-
- **Browser**:
86-
- **.net Version**:
87-
render: markdown
88-
validations:
89-
required: true
86+
9087
- type: textarea
9188
id: further
9289
attributes:

src.compiler/typescript/AlphaTabGenerator.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import * as ts from 'typescript';
1+
import ts from 'typescript';
22
import cloneEmit from './CloneEmitter';
33
import { GENERATED_FILE_HEADER } from './EmitterBase';
44
import serializerEmit from './SerializerEmitter';
55
import transpiler from '../TranspilerBase';
6-
import * as fs from 'fs';
6+
import fs from 'fs';
77
import jsonDeclarationEmit from './JsonDeclarationEmitter';
8+
import { execSync } from 'child_process';
89

910
transpiler([{
1011
name: 'Clone',
@@ -21,11 +22,22 @@ transpiler([{
2122
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf-8'));
2223
const { version } = packageJson;
2324
const fileHandle = fs.openSync('src/generated/VersionInfo.ts', 'w');
25+
const commit = execSync('git rev-parse HEAD').toString().trim();
26+
2427
fs.writeSync(fileHandle, `\
2528
${GENERATED_FILE_HEADER}
29+
30+
2631
export class VersionInfo {
2732
public static readonly version: string = '${version}';
2833
public static readonly date: string = '${new Date().toISOString()}';
34+
public static readonly commit: string = '${commit}';
35+
36+
public static print(print: (message:string) => void) {
37+
print(\`alphaTab \${VersionInfo.version}\`);
38+
print(\`commit: \${VersionInfo.commit}\`);
39+
print(\`build date: \${VersionInfo.date}\`);
40+
}
2941
}
3042
`);
3143
ts.sys.exit(ts.ExitStatus.Success);

src.csharp/AlphaTab/Environment.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Runtime.InteropServices;
23
using System.Threading;
34
using System.Threading.Tasks;
45
using AlphaTab.Collections;
@@ -14,6 +15,14 @@ public static void PlatformInit()
1415

1516
}
1617

18+
private static void PrintPlatformInfo(System.Action<string> print)
19+
{
20+
print($".net Runtime: {RuntimeInformation.FrameworkDescription}");
21+
print($"Process: {RuntimeInformation.ProcessArchitecture}");
22+
print($"OS Description: {RuntimeInformation.OSDescription}");
23+
print($"OS Arch: {RuntimeInformation.OSArchitecture}");
24+
}
25+
1726
public static Action Throttle(Action action, double delay)
1827
{
1928
CancellationTokenSource? cancellationTokenSource = null;
@@ -39,4 +48,6 @@ private static void CreatePlatformSpecificRenderEngines(IMap<string, RenderEngin
3948
);
4049
renderEngines.Set("default", renderEngines.Get("skia")!);
4150
}
42-
}
51+
52+
53+
}

src.kotlin/alphaTab/android/src/main/java/alphaTab/EnvironmentPartials.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package alphaTab
22

33
import alphaTab.platform.android.AndroidCanvas
4+
import alphaTab.platform.android.AndroidEnvironment
5+
import android.os.Build
46
import kotlinx.coroutines.CoroutineScope
57
import kotlinx.coroutines.Dispatchers
68
import kotlinx.coroutines.Job
@@ -26,6 +28,15 @@ internal class EnvironmentPartials {
2628
internal fun platformInit() {
2729
}
2830

31+
internal fun printPlatformInfo(print: (message: String) -> Unit) {
32+
print("OS Name: ${System.getProperty("os.name")}");
33+
print("OS Version: ${System.getProperty("os.version")}");
34+
print("Device Brand: ${Build.MANUFACTURER}");
35+
print("Device Model: ${Build.MODEL}");
36+
print("SDK Version: ${Build.VERSION.SDK_INT}");
37+
print("Screen Size: ${AndroidEnvironment.screenWidth}x${AndroidEnvironment.screenHeight}");
38+
}
39+
2940
private val throttleScope = CoroutineScope(Dispatchers.Default)
3041
internal fun throttle(toThrottle: () -> Unit, delay: Double): () -> Unit {
3142
var job: Job? = null

src.kotlin/alphaTab/android/src/main/java/alphaTab/platform/android/AndroidEnvironment.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ internal class AndroidEnvironment {
1111
companion object {
1212
private var _isInitialized: Boolean = false
1313

14+
var screenWidth:Int = 0;
15+
var screenHeight:Int = 0;
16+
1417
@ExperimentalUnsignedTypes
1518
@ExperimentalContracts
1619
public fun initializeAndroid(context: android.content.Context) {
@@ -21,6 +24,9 @@ internal class AndroidEnvironment {
2124

2225
Environment.HighDpiFactor = context.resources.displayMetrics.density.toDouble()
2326

27+
screenWidth = context.resources.displayMetrics.widthPixels
28+
screenHeight = context.resources.displayMetrics.heightPixels
29+
2430
AndroidCanvas.initialize(context)
2531

2632
var bravuraBytes: ByteArray;

src/AlphaTabApiBase.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,8 @@ export class AlphaTabApiBase<TSettings> {
251251
uiFacade.initialize(this, settings);
252252
Logger.logLevel = this.settings.core.logLevel;
253253

254+
Environment.printEnvironmentInfo(false);
255+
254256
this.canvasElement = uiFacade.createCanvasElement();
255257
this.container.appendChild(this.canvasElement);
256258
if (

src/Environment.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ import { NoteOrnamentEffectInfo } from './rendering/effects/NoteOrnamentEffectIn
7373
import { RasgueadoEffectInfo } from './rendering/effects/RasgueadoEffectInfo';
7474
import { DirectionsEffectInfo } from './rendering/effects/DirectionsEffectInfo';
7575
import { BeatTimerEffectInfo } from './rendering/effects/BeatTimerEffectInfo';
76+
import { VersionInfo } from './generated/VersionInfo';
7677

7778
/**
7879
* A factory for custom layout engines.
@@ -855,4 +856,35 @@ export class Environment {
855856

856857
return WebPlatform.Browser;
857858
}
859+
860+
/**
861+
* Prints the environment information for easier troubleshooting.
862+
* @param force Whether to force printing.
863+
*/
864+
public static printEnvironmentInfo(force:boolean = true) {
865+
const printer:(message:string) => void = force ? (message) => {
866+
Logger.log.debug('VersionInfo', message);
867+
} : (message) => {
868+
Logger.debug('VersionInfo', message);
869+
}
870+
VersionInfo.print(printer);
871+
printer(`High DPI: ${Environment.HighDpiFactor}`);
872+
Environment.printPlatformInfo(printer);
873+
}
874+
875+
/**
876+
* @target web
877+
* @partial
878+
*/
879+
private static printPlatformInfo(print: (message:string) => void) {
880+
print(`Browser: ${navigator.userAgent}`);
881+
print(`Platform: ${WebPlatform[Environment.webPlatform]}`);
882+
print(`WebPack: ${Environment.isWebPackBundled}`);
883+
print(`Vite: ${Environment.isViteBundled}`);
884+
if(Environment.webPlatform !== WebPlatform.NodeJs) {
885+
print(`Window Size: ${window.outerWidth}x${window.outerHeight}`);
886+
print(`Screen Size: ${window.screen.width}x${window.screen.height}`);
887+
}
888+
889+
}
858890
}

0 commit comments

Comments
 (0)