Skip to content
This repository has been archived by the owner on Apr 2, 2023. It is now read-only.

Cannot read property type of undefined #181

Open
dhruvp opened this issue Jun 12, 2017 · 2 comments
Open

Cannot read property type of undefined #181

dhruvp opened this issue Jun 12, 2017 · 2 comments

Comments

@dhruvp
Copy link

dhruvp commented Jun 12, 2017

Hi!

First of all thank you so much for creating and maintaining annotorious for the broader public. It has been a joy to use and has made our lives so much better!

One issue we've been seeing every so often is when we hit edit on an annotation, we get a javascript error in annotorious:

Uncaught TypeError: Cannot read property 'type' of undefined
    at http://127.0.0.1:8080/js/annotorious.min.js:215:107
    at Da (http://127.0.0.1:8080/js/annotorious.min.js:7:92)

I've done my best at understanding why that happens and it seems to me that it corresponds to the code here:

https://github.com/annotorious/annotorious/blob/b3a1db3bf21abccd8b44b3e0c6c2b6479b11b1a9/src/mediatypes/image/image.viewer.js#L245-L248

What's happening is shape is a null object as passed in. This happens because the given shape is for some reason not in self._shapes as in this code snippet:

      self._draw(self._shapes[annotorious.shape.hashCode(annotation.shapes[0])]);

This seems to happen somewhat randomly - most annotations in the same image work but the odd annotation will cause this error.

Would you please be able to help us debug this?

Thank you!

Dhruv

@dhruvp
Copy link
Author

dhruvp commented Jun 13, 2017

One more thing - I think it's related to the fact that self._currentAnnotation is undefined in the pass through this code block:

  goog.array.forEach(this._annotations, function(annotation) {
	if (annotation != self._currentAnnotation)
      self._draw(self._shapes[annotorious.shape.hashCode(annotation.shapes[0])]);
  });

As such, we try to draw the annotation that's being edited which I think is causing the issue? Still trying to figure out how self._currentAnnotation is set.

@dhruvp
Copy link
Author

dhruvp commented Jun 13, 2017

Ok I found the issue. It happens when you have two keypoints in the exact same position. This is because we delete from an array (this._annotations) leaving one item still in that array, but the dictionary self._shapes no longer has it. Not sure if it's worth addressing or not but seems like an edge case potentially worth addressing.

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

No branches or pull requests

1 participant