Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doenet Activity Freezing Seemingly at Random #211

Open
lynn0032 opened this issue Jul 9, 2024 · 0 comments
Open

Doenet Activity Freezing Seemingly at Random #211

lynn0032 opened this issue Jul 9, 2024 · 0 comments

Comments

@lynn0032
Copy link

lynn0032 commented Jul 9, 2024

I've been working working on a "tree maker" activity at https://www.doenet.org/portfolioviewer/_HBfeY77f1cGxdMYX5ES7G . It mostly works, except every once in a while the activity will freeze completely when I'm trying to make updates to the tree. I haven't been able to figure out any sort of consistency for when this happens, it seems to be at random as far as I can tell. I thought that it was an issue with the triggerSets updating hideButtonsNumber, but that doesn't seem to be the case, as I tried going back to an earlier version that didn't use this, and it still froze at some point.

Here's what I get in the console log when it freezes:
index-f554b9ea.js:2743 no xmlns of activity!
parseActivityDefinition @ index-f554b9ea.js:2743Understand this warning
CoreWorker-4e10b2b0.js:248 Uncaught (in promise) Error: Shouldn't have determine dependencies blocker after determining dependencies: /height, stateVariable, value, undefined
at DependencyHandler.resolveItem (CoreWorker-4e10b2b0.js:248:29236)
at async Core.getStateVariableValue (CoreWorker-4e10b2b0.js:1021:102864)
at async StateVariableDependency.getValue (CoreWorker-4e10b2b0.js:248:42713)
at async DependencyHandler.getStateVariableDependencyValues (CoreWorker-4e10b2b0.js:248:15960)
at async Core.getStateVariableDefinitionArguments (CoreWorker-4e10b2b0.js:1021:113991)
at async Core.getStateVariableValue (CoreWorker-4e10b2b0.js:1021:103219)
at async StateVariableDependency.getValue (CoreWorker-4e10b2b0.js:248:42713)
at async DependencyHandler.getStateVariableDependencyValues (CoreWorker-4e10b2b0.js:248:15960)
at async Core.getStateVariableDefinitionArguments (CoreWorker-4e10b2b0.js:1021:113991)
at async Core.getStateVariableValue (CoreWorker-4e10b2b0.js:1021:103219)

Here's the DoenetML in its current state, in case I make changes to the activity in the future:

<setup>
  <styleDefinitions>
    <styleDefinition styleNumber="11" markerSize="15"/>
    <styleDefinition styleNumber="12" fillColor="white"/>
  </styleDefinitions>

  <number name="height">4</number>
  <number name="maxNodes">2^($height+1)-1</number>
</setup>

<map name="nodesMap" hide>
    <template>
      <number name="level"><floor><number>log_2($n)</number></floor></number>
      <number name="x"><mod>$n <number>2^($level)</number></mod>/2^$level + 1/2^($level+1)</number>
      <number name="y">-1*$level</number>
      <point name="thisNode" hide="true" styleNumber="11">($x, $y)</point>
      <boolean name="editingThis">true</boolean>
      <text name="thisData" anchor="$thisNode" hide="true">0</text>
      <triggerSet triggerWhenObjectsClicked="thisNode">
        <!--<updateValue  target="hideButtons" newValue="false" type="boolean"/>-->
        <updateValue  target="hideButtonsNumber" newValue="-1"/>
        <updateValue target="current" newValue="$n"/>
      </triggerSet>
    </template>
    <sources alias="n">
      <sequence from="1" to="$maxNodes"/>
    </sources>
</map>

<map name="edgesMap" hide>
  <template>
    <lineSegment endpoints="$nodes[$n] $nodes[2*$n]" hide="true"/>
    <lineSegment endpoints="$nodes[$n] $nodes[2*$n+1]" hide="true"/>
  </template>
  <sources alias="n">
    <sequence from="1" to="2^$height - 1"/>
  </sources>
</map>

<p>Build the following tree:</p>
<ul>
  <li>The root is 5.</li>
  <li>2 is the left child of 5.</li>
  <li>8 is the right child of 5.</li>
  <li>3 is the right child of 2.</li>
  <li>6 is the left child of 8.</li>
  <li>10 is the right child of 8.</li>
  <li>4 is the right child of 3.</li>
</ul>

<triggerSet>
  <label>Start Tree</label>
  <updateValue target="nodes[1].hide" newValue="false" type="boolean"/>
  <updateValue target="data[1].hide" newValue="false" type="boolean"/>
  <updateValue target="hideButtonsNumber" newValue="0"/>
</triggerSet>

<p>After starting the graph, click on a node to edit its data, delete it, or add a left or right child.</p>



<number name="current" hide>1</number>
<boolean name="hideButtons" hide>$hideButtonsNumber > 0</boolean>
<number name="hideButtonsNumber" hide>1</number>
<boolean name="hideAddLC" hide>$hideButtons or not $nodes[2$current].hide</boolean>
<boolean name="hideAddRC" hide>$hideButtons or not $nodes[2$current+1].hide</boolean>
<boolean name="hideDelete" hide>$current < $maxNodes/2 and ($hideButtons or not $nodes[2$current].hide or not $nodes[2$current+1].hide)</boolean>

<graph name="g" displayXAxis="false" displayYAxis="false" showNavigation="false" showBorder="false" ymin="-1*$height - 1" ymax="1" xmin="-.1" xmax="1.1" size="large">

  <rectangle name="background" filled vertices="(-.2, -1*$height - 2) (1.2, 1.1)" styleNumber="12"></rectangle>
  
  <collect name="nodes" source="nodesMap" componentTypes="point"/>
  <collect name="data" source="nodesMap" componentTypes="text"/>
  <collect name="edges" source="edgesMap" componentTypes="lineSegment"/>


  <textInput anchor="$nodes[$current]" width="15px" hide="$hideButtons">$data[$current]</textInput>
  <triggerSet anchor="$nodes[$current]+(-0.02,-1.5/$height)" positionFromAnchor="left" hide="$hideAddLC">
    <label>+</label>
    <updateValue target="edges[2$current-1].hide" newValue="false" type="boolean"/>
    <updateValue target="nodes[2$current].hide" newValue="false" type="boolean"/>
    <updateValue target="data[2$current].hide" newValue="false" type="boolean"/>
    <updateValue target="hideButtonsNumber" newValue="1"/>
  </triggerSet>
  <triggerSet anchor="$nodes[$current]+(0,1.5/$height)" positionFromAnchor="center" hide="$hideDelete">
    <label>-</label>
    <updateValue target="nodes[$current].hide" newValue="true" type="boolean"/>
    <updateValue target="data[$current].hide" newValue="true" type="boolean"/>
    <updateValue target="data[$current]" newValue="0" type="text"/>
    <updateValue target="edges[$current-1].hide" newValue="true" type="boolean"/>
    <updateValue target="hideButtonsNumber" newValue="1"/>
    <updateValue target="current" newValue="1"/> <!-- maybe should go to parent? doesn't matter for now... -->
  </triggerSet>
  <triggerSet anchor="$nodes[$current]+(0.02,-1.5/$height)" positionFromAnchor="right" hide="$hideAddRC">
    <label>+</label>
    <updateValue target="edges[2$current].hide" newValue="false" type="boolean"/>
    <updateValue target="nodes[2$current+1].hide" newValue="false" type="boolean"/>
    <updateValue target="data[2$current+1].hide" newValue="false" type="boolean"/>
    <updateValue target="hideButtonsNumber" newValue="1"/>
  </triggerSet>
  
</graph>

<number name="updateHideButtonsNumber" hide><min>1 <number>$hideButtonsNumber+1</number></min></number>

<triggerSet triggerWhenObjectsClicked="background">
  <updateValue  target="hideButtonsNumber" newValue="$updateHideButtonsNumber"/>
</triggerSet>


<answer>
  <award>
    <when>
      <textList>$data</textList> = <textList>5 2 8 0 3 6 10 0 0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</textList>
      and $data[1].hide = false
      and $data[2].hide = false
      and $data[3].hide = false
      and $data[4].hide = true
      and $data[5].hide = false
      and $data[6].hide = false
      and $data[7].hide = false
      and $data[10].hide = true
      and $data[12].hide = true
      and $data[13].hide = true
      and $data[14].hide = true
      and $data[15].hide = true
      and $data[22].hide = true
      and $data[23].hide = true
    </when>
  </award>
</answer>

<!--
Notes:
button positioning?
allow increasing height past 5?
add data to nodes (text input)
-->


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant