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

add support for data:* URIs #31594

Closed
sigmundch opened this issue Dec 8, 2017 · 9 comments
Closed

add support for data:* URIs #31594

sigmundch opened this issue Dec 8, 2017 · 9 comments
Assignees
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. customer-bazel customer-vm P1 A high priority bug; for example, a single project is unusable or has many test failures

Comments

@sigmundch
Copy link
Member

The default FileSystem only supports file:* URIs, we should also support data:* URIs

@sigmundch sigmundch added area-front-end Use area-front-end for front end / CFE / kernel format related issues. customer-bazel customer-vm labels Dec 8, 2017
@keertip keertip added this to the 2.0-alpha milestone Dec 8, 2017
@keertip keertip added the P1 A high priority bug; for example, a single project is unusable or has many test failures label Dec 11, 2017
@keertip
Copy link
Contributor

keertip commented Dec 11, 2017

This is blocking internal testing of the VM+FE.

@sigmundch
Copy link
Member Author

sigmundch commented Dec 12, 2017

Peter and I had a quick discussion about this - we agreed that the support for data:* should be added at the file-system abstraction layer, but it will not be done in the physical file system. Instead there will be an additional file system added for this, which is only enabled by the VM's kernel-service (this is to keep dart2js/ddc as they work today without support for these URIs)

@kmillikin kmillikin changed the title add support for dart:* URIs add support for data:* URIs Jan 3, 2018
@kmillikin kmillikin assigned jensjoha and askeksa-google and unassigned kmillikin Jan 5, 2018
@kmillikin
Copy link

kmillikin commented Jan 5, 2018

From @sigmundch over chat:

It's a fairly simple change, basically the compiler doesn't need any changes, we just need to add a new FileSystem implementation to kernel-service. The compiler when it reads an URI it delegates to the file system to do the read, so the new file-system internally will distinguish the scheme and do UriData.decode(...) on it if it is a data URI.

@jensjoha jensjoha removed their assignment Jan 8, 2018
@peter-ahe-google
Copy link
Contributor

Aske and I discussed this at lunch today.

We'll extend PhysicalFileSystem to handle data-URIs.

dart:core provides support for data-URIs, both creating them and decoding them. The latter is done via Uri.data.

@sigmundch
Copy link
Member Author

@peter-ahe-google & @askeksa-google - just a point that Peter and I discussed a while back (not sure if you covered this during your conversation): we prefer not to put the logic together in the same PhysicalFileSystem implementation so we don't add support for data:* uris to ddc/dart2js as a result (see also the earlier comment above from a month ago).

My thinking was that we could compose the file system with something among these lines:

  • PhysicalFileSystem - like today, it just reads "file:" URIs
  • DataFileSystem - a file system that only reads "data:*" URIs
  • MixedSchemeFileSystem - a file system that delegates to other file systems based on the URI scheme. So the kernel-service would create one like: MixedSchemeFileSystem({'data': dataFS, 'file': physicalFS});

@askeksa-google
Copy link

What would be a good way to test that such a mixed file system works in the context of Fasta, i.e. for compiling a Dart program containing data: URIs? Is there a convenient way of specifying that this other file system should be used for a particular test case?

@sigmundch
Copy link
Member Author

That might depend on how much test coverage we want and how we want to test it.

To test it with the package:testing-chain, we can change the file system definition here:

PhysicalFileSystem.instance, false, dillTarget, uriTranslator);

However, since we are anyways going to be updating the vm kernel-service to use this, I'd be inclined to leverage the existing testing from VM tests. In particular:

  • After we change the default FS in kernel-service here:

    final FileSystem fileSystem = sourceFiles == null

  • We could add test files that use data URIs in a VM-only suite like tests/standalone_2

You may notice in that link above that the VM's uses a custom file system also for their own unit tests set up. This is to support adding in-memory source-files that they define in the tests. We use the HybridFileSystem for that today. Honestly, if the VM unit tests can be changed to use a custom URI scheme, then we could potentially get rid of the use of the hybrid file system there and instead use the MixedSchemeFileSystem for both purposes. It would now have 3 schemes, one for tests (which points to a memory file system), one for data-uris, and one for file-uris.

@askeksa-google
Copy link

Peter and I discussed this some more. :)

As the FileSystem abstraction is used currently, its function is to specify how URIs are handled in general, rather than to specify handling of specific schemes. Based on this observation, it makes most sense to replace PhysicalFileSystem by a StandardFileSystem (for the normal handling of standard URIs, including data) and then to replace/wrap that when special handling is required (as we already do with the MemoryFileSystem/HybridFileSystem).

@askeksa-google
Copy link

Missing piece of the argument: It seems we do want universal data URI support, contrary to some comments earlier in this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. customer-bazel customer-vm P1 A high priority bug; for example, a single project is unusable or has many test failures
Projects
None yet
Development

No branches or pull requests

6 participants