Skip to content

SVG loading causes ArrayIndexOutOfBoundsException with some files #750

Closed

Description

@processing-bot

Created by: villares

Description

Loading some SVG files that used to work with loadShape() on Processing 3.5.4 will cause a message like this (the index varies):
ArrayIndexOutOfBoundsException: Index 128 out of bounds for length 128

Expected Behavior

image

Current Behavior

image

Steps to Reproduce

  1. Copy this SVG file to a data folder inside a new sketch:
    https://gist.github.com/villares/a5b028eaddf4c0e008f9783ea5dddb40

  2. Paste in and run this code:

void setup(){
 size(200, 200);
 PShape a = loadShape("a.svg");
 shape(a, 0, 0, 200, 200); // optional, will not be reached
}  

Environment

Processing version: Processing 4.2
Operating System and OS version: Manjaro 21.3 Kernel 5.15

More information / ideas

Looks similar to this issue with coordinates starting with .: #518 (comment)

But the offending coordinates seem to be 2.51259,6.5e-4, if I replace with 2.51259,0 it loads.

Activity

  1. processing-bot commented on Jul 28, 2023

    @processing-bot
    CollaboratorAuthor

    Created by: villares

    Thank you very much @behreajj!

  2. processing-bot commented on Dec 28, 2023

    @processing-bot
    CollaboratorAuthor

    Created by: SaumyaKarnwal

    hey @benfry ,
    I have resolved the issue and raised a PR.
    Please review :)

  3. processing-bot commented on Mar 21, 2024

    @processing-bot
    CollaboratorAuthor

    Created by: luis-c465

    Was getting this same issue when trying to parse this USA Map with Counties because it contains values like 3.5e-5, 3e-2 etc.

    Thank you, @SaumyaKarnwal! 🎉

    For the time being I made a simple python script to convert these values into proper decimals, so I can continue on my project 😄.

    https://gist.github.com/luis-c465/6c748e40b5c1b8899f5d1502228a5cd6

  4. processing-bot commented on Mar 21, 2024

    @processing-bot
    CollaboratorAuthor

    Created by: SaumyaKarnwal

    That's great! I'm glad you found a workaround for the parsing issue.

    On Thu, Mar 21, 2024 at 7:34 PM Luis Canada @.***>
    wrote:

    Was getting this same issue when trying to parse this USA Map with
    Counties
    https://commons.wikimedia.org/wiki/File:US_county_map,_blank,_w_territories.svg
    because it contains values like 3.5e-5, 3e-2 etc.

    Thank you, @SaumyaKarnwal https://github.com/SaumyaKarnwal! 🎉

    For the time being I made a simple python script to convert these values
    into proper decimals, so I can continue on my project 😄.

    https://gist.github.com/luis-c465/6c748e40b5c1b8899f5d1502228a5cd6

    —
    Reply to this email directly, view it on GitHub
    https://gitlab.com/Stefterv/processing4/-/issues/750#issuecomment-2012388799,
    or unsubscribe
    https://github.com/notifications/unsubscribe-auth/AXJATCHOOZAI6XPBEQRDX3DYZLSGNAVCNFSM6AAAAAA2LRPFISVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJSGM4DQNZZHE
    .
    You are receiving this because you were mentioned.Message ID:
    @.***>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions