finos / morphir-elm

Tools to work with the Morphir IR in Elm.
https://package.elm-lang.org/packages/finos/morphir-elm/latest
Apache License 2.0
46 stars 65 forks source link

Develop Insight freezes when trying to visualize a decision tree with 22 branches #1142

Closed nwokafor-choongsaeng closed 9 months ago

nwokafor-choongsaeng commented 9 months ago

Describe the bug When trying to visualize a decision with over 20 branches on the develop UI, the browser stops responding.

To Reproduce To reproduce this behavior, setup a Morphir project and try visualizing this function.

longDecisionTree: String -> Int
longDecisionTree string = 
    if string == "1" then 
        1
    else if string == "2" then
        2
    else if string == "3" then
        3
    else if string == "4" then
        4
    else if string == "5" then
        5
    else if string == "6" then
        6
    else if string == "7" then
        7
    else if string == "8" then
        8
    else if string == "9" then
        9
    else if string == "10" then
        10
    else if string == "11" then
        11
    else if string == "12" then
        12
    else if string == "13" then
        13
    else if string == "14" then
        14
    else if string == "15" then
        15
    else if string == "16" then
        16
    else if string == "17" then
        17
    else if string == "18" then
        18
    else if string == "19" then
        19
    else if string == "20" then
        20
    else if string == "21" then
        21
    else if string == "22" then
        22
    else if string == "23" then
        23
    else if string == "24" then
        24
    else 
        0

Expected behavior Expect longDecisionTree to visualize without any issues.

Environment

Additional context This problem doesn't occur in Morphir version 2.83.0, and even the current version (2.87.6) works fine for 15 branches or less but starts to show observable lags as branches increase above 17

bekand commented 9 months ago

This was caused by expensive functions producing UI content being evaluated even if that content is not being shown. I've opened a PR addressing the issue.

bekand commented 9 months ago

https://github.com/finos/morphir-elm/pull/1143 fixes this.