Skip to content

Transformer doesn't work for assets with resolution-aware variants #13

@Albert221

Description

@Albert221

For assets that have their corresponding 2.0x/ variant, the transformer fails.

This may have something to do with the fact, that input and output paths is the same for all the resolution-aware variant files, command was ran with these params for logo_dark.png, 2.0x/logo_dark.png, and 3.0x/logo_dark.png:

input: /var/folders/mh/n8gr4_w94sndpqg3619xhxxh0000gn/T/flutter_tools.sUFfrh/logo_dark.png-transformOutput0.png output: /var/folders/mh/n8gr4_w94sndpqg3619xhxxh0000gn/T/flutter_tools.sUFfrh/logo_dark.png-transformOutput1.png
input: /var/folders/mh/n8gr4_w94sndpqg3619xhxxh0000gn/T/flutter_tools.sUFfrh/logo_dark.png-transformOutput0.png output: /var/folders/mh/n8gr4_w94sndpqg3619xhxxh0000gn/T/flutter_tools.sUFfrh/logo_dark.png-transformOutput1.png
input: /var/folders/mh/n8gr4_w94sndpqg3619xhxxh0000gn/T/flutter_tools.sUFfrh/logo_dark.png-transformOutput0.png output: /var/folders/mh/n8gr4_w94sndpqg3619xhxxh0000gn/T/flutter_tools.sUFfrh/logo_dark.png-transformOutput1.png

Reproduce

Change transformer args in example/pubspec.yaml to '--z=9', '--from_path' (so that the transformation takes enough time for the bug to occur.

When created an 2.0x/example_image.png in the example project inside this repository and building Web, this is the error output:

Target web_release_bundle failed: PathNotFoundException: Cannot copy file to 'build/web/assets/assets/images/2.0x/example_image.png', path = '/var/folders/mh/n8gr4_w94sndpqg3619xhxxh0000gn/T/flutter_tools.81PVsJ/example_image.png-transformOutput1.png' (OS Error: No such file or
directory, errno = 2)

So because the source and output files are the same, Flutter CLI also tries to copy the same file more than once which fails for all attempts except for the first one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions