Wicklets / wick-editor

A free and open-source tool for creating games, animations and everything in-between!
https://www.wickeditor.com
GNU General Public License v3.0
642 stars 110 forks source link

[BUG]_transformbounds "cannot get properties of null" #356

Open Kortenbach opened 2 years ago

Kortenbach commented 2 years ago

Describe the bug When running a wick file converted to html in an iframe I get the error:

wickpagina-html:13030 Uncaught TypeError: Cannot read properties of null (reading '_transformBounds')
    at CanvasView.getBounds (wickpagina-html:13030:42)
    at CanvasView.getCenter (wickpagina-html:13086:15)
    at CanvasView.setZoom (wickpagina-html:13101:9)
    at Wick.View.Project._renderSVGCanvas (wickpagina-html:63116:28)
    at Wick.View.Project.render (wickpagina-html:62938:10)
    at Wick.Project.tick (wickpagina-html:51536:15)
    at wickpagina-html:51495:24

To Reproduce Steps to reproduce the behavior:

  1. I'm embedding the Wick file in an iframe:
    
    <div class="box" id="htmlgraphics-iframe">
      <iframe src="http://127.0.0.1:1880/wickpagina-html" width="640" height="480"></iframe>
    </div>

2. Now, the iframe is actually inside of a Grafana panel (can be reproduced using the textpanel and the htmlGraphics panel), but that shouldn't be of much influence.
3. In some situations (after leaving the htmlGraphics panel editor) the page stops rendering (white page) and the error repeats every tick of the wick engine.

**Expected behavior**
I expect the page to appear instead of seeing a white screen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
 - OS: Windows
 - Browser Chrome

**Do you have a suggested solution to this issue? (ex. has another program fixed this bug a certain way? Are you familiar with where in the code base someone would need to fix this issue?)**
I searched for the error and found that it is inside of PaperJS and has a known work-around. It seems to be related tot zooming:
[https://github.com/paperjs/paper.js/issues/1433]

**Additional context**
Add any other context about the problem here.