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

Don't render children of collapsed blocks #4264

Merged
merged 8 commits into from
Sep 18, 2020

Conversation

moniika
Copy link
Contributor

@moniika moniika commented Sep 9, 2020

The basics

  • I branched from develop
  • My pull request is against develop
  • My code follows the style guide

The details

Resolves

Part of #4229

Proposed Changes

  • Sets rendered state of children of collapsed blocks to false, so they are not re-rendered when the block is moved.
  • Checks if child is rendered before recursively calling updateDisabled on children in updateDisabled.

Reason for Changes

Improves performance.

Test Coverage

Tested scenario descibed in #4229 and saw improvement in performance while testing with chrome performance tool.

Tested that issues #3784 was still fixed.

Tested issue #1967 in playground using xml:

<xml xmlns="https://developers.google.com/blockly/xml">
  <block type="controls_repeat_ext" x="88" y="138">
    <value name="TIMES">
      <shadow type="math_number">
        <field name="NUM">10</field>
      </shadow>
    </value>
    <statement name="DO">
      <block type="text_print">
        <value name="TEXT">
          <shadow type="text">
            <field name="TEXT">already here 1</field>
          </shadow>
        </value>
        <next>
          <block type="text_print">
            <value name="TEXT">
              <shadow type="text">
                <field name="TEXT">already here 2</field>
              </shadow>
            </value>
          </block>
        </next>
      </block>
    </statement>
  </block>
  <block type="text_print" x="88" y="288">
    <value name="TEXT">
      <shadow type="text">
        <field name="TEXT">connected while collapsed</field>
      </shadow>
    </value>
  </block>
</xml>

And repro code:

  var ws = Blockly.getMainWorkspace();
  var blocks = ws.getTopBlocks();
  blocks[0].setCollapsed(true);
  blocks[0].getInput('DO').connection.connect(blocks[1].previousConnection);
  // Check that attached block is hidden/not rendered
  blocks[0].setCollapsed(false);
  // Check that all blocks are un-hidden/rendered

Tested on:

  • Desktop Chrome

Additional Information

n/a

@moniika moniika marked this pull request as draft September 9, 2020 23:47
@moniika moniika marked this pull request as ready for review September 9, 2020 23:50
@moniika moniika marked this pull request as draft September 10, 2020 00:07
@BeksOmega
Copy link
Collaborator

I think I might have changed this because of #1967 but I can't exactly remember.

@moniika moniika force-pushed the collapsed-performance branch from ba3248e to cad7efa Compare September 17, 2020 22:56
@moniika moniika force-pushed the collapsed-performance branch from 40aec8d to c99384e Compare September 18, 2020 20:13
@moniika moniika marked this pull request as ready for review September 18, 2020 20:36
Comment on lines +463 to +466
var parentInput = parentBlock.getInputWithBlock(childBlock);
if (parentInput && !parentInput.isVisible()) {
childBlock.rendered = true;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm worried about whether this may have unintended side effects.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it looks good! Because if the block is top-level it should definitely be visible right? As long as the nested disconnection test is passing it should be fine.

I'm going to tag this with #4288 though cuz I know that .rendered is kinda crazy wrt collapsed blocks.

@moniika moniika merged commit 96e8fc7 into google:develop Sep 18, 2020
moniika added a commit that referenced this pull request Sep 21, 2020
moniika pushed a commit that referenced this pull request Sep 21, 2020
@moniika moniika deleted the collapsed-performance branch September 21, 2020 19:59
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

Successfully merging this pull request may close these issues.

3 participants