Skip to content

[record_use] Implementation: JSON: Definition loading unit should be removed #2986

Closed

Description

@dcharkes

Currently, we serialize the loading unit with the definition:

  "recordings": [
    {
      "definition": {
        "identifier": {
          "name": "someStaticMethod2",
          "scope": "SomeClass",
          "uri": "basic.dart"
        },
        "loading_unit": "1"
      },
      "calls": [
        {
          "@": 0,
          "loading_unit": "1",
          "positional": [
            0
          ],
          "type": "with_arguments"
        }
      ]
    }
  ]

This doesn't really make sense. Instead we should say a definition has uses, and a definition ends up in a loading unit, two different maps. (And the Dart API should probably reflect that too: Two different queries: give me the calls to this definition, and give me the loading unit this definition ended up in.)

  "definitions": [
      "identifier": {
        "name": "someStaticMethod2",
        "scope": "SomeClass",
        "uri": "basic.dart"
      }
  ],
  "loading_units": {
    "0": "1"
  },
  "recordings": [
    {
      "definition": 0,
      "calls": [
        {
          "@": 0,
          "loading_unit": "1",
          "positional": [
            0
          ],
          "type": "with_arguments"
        }
      ]
    }
  ]

Activity

  1. changed the title [-][record_use] Implementation: JSON: The loading unit[/-] [+][record_use] Implementation: JSON: Definition loading unit should be on the side[/+] on Jan 20, 2026
  2. changed the title [-][record_use] Implementation: JSON: Definition loading unit should be on the side[/-] [+][record_use] Implementation: JSON: Definition loading unit should be removed[/+] on Jan 28, 2026
  3. dcharkes commented on Jan 28, 2026

    @dcharkes
    CollaboratorAuthor

    Notes from discussion with @biggs0125:

    • Definition loading units are not useful in the dart2js situation. If you have two calls from different loading units, you want to postpone loading the asset until one of those two loading units is loaded, not in the loading unit that is dominating those two loading units. (dart2js will use the cached asset when the second loading unit is loaded.)
      • So, a link hook outputting assets should then output a list of loading units an asset is used in.
      • Whether to package an asset in the dominating loading unit could be a decision of the SDK/embedder. Flutter might actually prefer shipping an asset in the dominating loading unit.
  4. self-assigned this
    on Feb 9, 2026
  5. moved this from Todo to In Progress in Native Assetson Feb 9, 2026
  6. moved this from In Progress to Done in Native Assetson Feb 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions