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

_getStrokeMatrix and placed symbols #1014

Closed
JaapSuter opened this issue Mar 16, 2016 · 8 comments
Closed

_getStrokeMatrix and placed symbols #1014

JaapSuter opened this issue Mar 16, 2016 · 8 comments

Comments

@JaapSuter
Copy link

Hello,

I apologize for not sending a pull request instead, but I don't have a decent git setup on my current computer. At any rate, I'm using placed symbols, and I'm getting an invalid null error with the following stack:

TypeError: Cannot read property 'getViewMatrix' of null at Path._getStrokeMatrix (_bundle.js:31297:28) at Function.getStrokeBounds (_bundle.js:36905:35) at Path._getBounds (_bundle.js:36865:23) at Path._getCachedBounds (_bundle.js:31283:22) at SymbolItem._getBounds (_bundle.js:33321:16) at SymbolItem._getCachedBounds (_bundle.js:31283:22) at SymbolItem.getBounds (_bundle.js:31233:22) at SymbolItem.getPosition (_bundle.js:31190:14) at SymbolItem.setPosition (_bundle.js:31196:55)

The definition of _getStrokeMatrix is as follows:

_getStrokeMatrix: function(matrix, options) { return this.getStrokeScaling() ? matrix : (options && options.internal ? this : this._parent).getViewMatrix().invert()._shiftless(); },

I believe the reference to this._parent should be (this._parent || this._parentSymbol.getItem())...

I base that merely on a hunch, having seen this pattern in other parts of paper.js -- and also, my code no longer runs into that error, and works as expected.

But, I admit I haven't really dug into this too deep, so perhaps I'm wrong. I'm posting this in the hope that you'll say: "whoops, yeah -- oversight, thanks for catching that." But if instead you're not immediately convinced that's a proper fix, let me know and I'll do a proper deep dive, get a minimal repro, and find the actual problem (which may well be my fault entirely).

Kind regards,

Jaap Suter - http://jaapsuter.com

@lehni
Copy link
Member

lehni commented Mar 16, 2016

Could you please share the code that produces the error so we can reproduce it? Thanks.

@lehni
Copy link
Member

lehni commented Mar 27, 2016

Pinging again, as a test-case is required for me to be able to say what the situation is here, and is actually much more important than a PR, because the issues should be understood fully first before attempting a fix.

@JaapSuter
Copy link
Author

My apologies for not getting back to this. Unfortunately I'm no longer using the code-path that led me to originally encounter this problem, nor do I have time right now to try and create a small reproducable test case. If or when I do encounter this again, I'll revisit the issue, but for now I'll close it. Sorry for using up your time. Thanks for paper.js, it's all around fantastic!

@lehni
Copy link
Member

lehni commented Mar 28, 2016

Let's keep this open for now, as it does sound like something that can happen in other situations. I'll look at the code and try to understand what might have produced it.

@lehni lehni reopened this Mar 28, 2016
@lehni
Copy link
Member

lehni commented Mar 28, 2016

Out of curiosity: You were working with symbols, correct?

@georeith
Copy link
Contributor

@lehni I get this error using paperJS in node when trying to access any Item.strokeBounds if the Item hasn't been inserted.

This is using PaperScope.settings.insertItems = false and calling PaperScope#setup() without any arguments to create the scope under which the items are created. If I explicitly tell the items to insert it works fine.

@breed85
Copy link

breed85 commented May 9, 2016

@lehni I'm also running into this and I'm able to reproduce it.

It happens specifically when you try to get the bounds of a placed symbol with a stroke setting and stroke scaling set to false.

I tried to get around this using @JaapSuter 's suggestion, but while the error went away, the bounds reported for the symbol were completely wrong. I can't reproduce that yet, but essentially what should have been a 4x4 square came back with a bounding rect that was 320x93.

For now, I'm going to avoid using symbols as regular paths don't seem to have this problem. Let me know if I can help any more.

Simple Reproduction

@lehni
Copy link
Member

lehni commented May 22, 2016

Related: #856

@lehni lehni closed this as completed in 948a8af May 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants