Skip to content

SVG DOM not fully loaded on alphatab.postRendered #303

@gburlet

Description

@gburlet

Your Environment

  • Version used: dev branch
  • Platform used: JavaScript
  • Rendering engine used: SVG
  • Browser Name and Version: Chrome 79.0.3945.79
  • Operating System and version (desktop or mobile): desktop mac os Mojave

Expected Results

Entire SVG loaded in .alphaTabSurface when alphatab.postRendered callback triggered

Observed Results

at.on("alphaTab.postRendered", function() {
    // jQuery selectors accessing SVG render of digital score fail to access entire score
    // Only grabs SVG elements for a subset of the systems (lines) because not all have loaded yet
});

currently, I'm have this workaround, although I hate timing-based solutions like this because they invoke race conditions and are fragile:

at.on("alphaTab.postRendered", function() {
    $('.alphaTabSurface').css("height", "100%");
        setTimeout(function() {
            // jQuery selectors here: e.g.,
            $("#alphaTab > .alphaTabSurface > svg.alphaTabSurfaceSvg > g[class^='b']")
        }, 50);
});

Basically waiting 50ms for the SVG to fully load. This probably has to do with web workers being enabled and loading the score asynchronously? In any case, I think the trigger alphaTab.postRendered should be called when all the systems are loaded and rendered in the DOM.

Steps to Reproduce (for bugs)

Print jQuery selector results to console in the postRendered callback

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions