qgis / qgis-js

QGIS core ported to WebAssembly to run it on the web platform

Home Page:https://qgis.github.io/qgis-js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Loading expressions throws RuntimeError

wonder-sk opened this issue · comments

When using a QGIS project containing vector tiles layer with a couple of styling rules, it failed to load with this RuntimeError:

qgis-js.wasm:0x56fcf5 Uncaught (in promise) RuntimeError: memory access out of bounds
    at QgsExpressionNodeFunction::QgsExpressionNodeFunction(int, QgsExpressionNode::NodeList*) (qgis-js.wasm:0x56fcf5)
    at exp_parse(expression_parser_context*) (qgis-js.wasm:0x54bcd8)
    at parseExpression(QString const&, QString&, QList<QgsExpression::ParserError>&) (qgis-js.wasm:0x54e28d)
    at QgsExpression::QgsExpression(QString const&) (qgis-js.wasm:0x55145b)
    at QgsProperty::loadVariant(QVariant const&) (qgis-js.wasm:0x9d9bd2)
    at QgsPropertyCollection::loadVariant(QVariant const&, QMap<int, QgsPropertyDefinition> const&) (qgis-js.wasm:0x9dfd97)
    at QgsAbstractPropertyCollection::readXml(QDomElement const&, QMap<int, QgsPropertyDefinition> const&) (qgis-js.wasm:0x9dce89)
    at QgsSymbolLayerUtils::loadSymbolLayer(QDomElement&, QgsReadWriteContext const&) (qgis-js.wasm:0x447961)
    at QgsSymbolLayerUtils::loadSymbol(QDomElement const&, QgsReadWriteContext const&) (qgis-js.wasm:0x4455a1)
    at QgsSymbolLayerUtils::loadSymbols(QDomElement&, QgsReadWriteContext const&) (qgis-js.wasm:0x45d3f7)

QgsExpressionNodeFunction tries to lock a recursive mutex, maybe that's the reason (possibly related to #3 which also fails when locking mutex, but with a different error message)

FYI: @andreasneumann hit that issue too and provided me a test project. I'm currently looking into this.

The old patch to get the QGIS expressions "working" in a debug build was way too aggressive. Basically removing all expression functions, which made the whole expression evaluation useless/failing 🙈

This is now fixed with afbdda9 which adds the needed flag (forcing optimization in debug builds) only to expression/qgsexpressionfunction.cpp in QGIS (see also the upstream emscripten issue). QgsExpressions are now working with all build types in Chormium/Firefox 🥳

The fix is also published to the temporary demo site. The test project form @andreasneumann seems to work fine. Please report back so we can close this issue.

@boardend and @wonder-sk - looks good. I tested with my project and it loads fine.

There are a few issues with this project still (text size too small, cut-off-labels), but for these we should open separate issues.

Thanks for your feedback. See #8 and feel free to open a new issue for the cut-off-labels.