Problem with adding dynamic polygon collider 2d

When attaching a PolygonCollider2D to a Sprite with this line:

It adds a polygon collider of the same shape as the sprite.
For some reason this only works in the editor. On web or windows builds the colldier is messed up and usually much bigger or smaller.
Am I doing something wrong or is it just a bug?

I found the solution to this problem if someone still runs into it.
I checked my output log from the development build and it said:

Sprite outline generation failed -
could not read texture pixel data. Did
you forget to make the texture

You have to set your sprites’ type to Advanced and enable the Read/Write box. At least the ones on which you are going to put a Polygon Collider.