Skip to content

[flutter_svg] Use a lot of memory to compile svgs on iOS #184564

Open

Description

@xuantungdev0401

Steps to reproduce

Run code in profile mode, iOS, open memory tool, press button
Image

Expected results

Do not use too much memory to compile svg

Actual results

Use a lot of memory (1.3 GB) and the process is very slow

Code sample

Code sample
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';

class TestApp extends StatefulWidget {
  const TestApp({super.key});

  @override
  State<TestApp> createState() => _TestAppState();
}

class _TestAppState extends State<TestApp> {
  bool show = false;
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        floatingActionButton: FloatingActionButton(
          onPressed: () {
            setState(() {
              show = !show;
            });
          },
        ),
        body: !show ? SizedBox() : SingleChildScrollView(
          child: Column(
            children: List.generate(40, (e) {
              return SvgPicture.network('https://icons.getbootstrap.com/assets/icons/building-fill-exclamation.svg?v=$e');
            }),
          ),
        ),
      ),
    );
  }
}

flutter_svg: 2.2.4

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.41.5, on macOS 26.3.1 25D2128 darwin-arm64, locale en-VN)
[!] Android toolchain - develop for Android devices (Android SDK version 36.1.0)
    ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[✓] Xcode - develop for iOS and macOS (Xcode 26.2)
[✓] Chrome - develop for the web
[✓] Connected device (4 available)
    ! Error: Browsing on the local area network for iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as
      this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
    ! Error: Browsing on the local area network for iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as
      this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources

! Doctor found issues in 1 category.

Activity

  1. saurabh-mirajkar commented on Apr 6, 2026

    @saurabh-mirajkar
    Contributor

    @xuantungdev0401 Thanks for the detailed report.

    I notice the SVG URL includes a changing query param (?v=$e), which prevents caching and forces each SVG to be downloaded and compiled separately. This could significantly increase memory usage.

    To help us investigate further:

    • Can you confirm if the issue persists when using the same URL (without ?v=$e)?
    • Does this reproduce with asset SVGs instead of network images?
    • Please share a DevTools memory snapshot or performance trace if possible.

    Keeping this open for further investigation once we have the above details.

  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    and removed
    in triagePresently being triaged by the triage team
    on Apr 6, 2026
  3. xuantungdev0401 commented on Apr 6, 2026

    @xuantungdev0401
    Author

    Hi @saurabh-mirajkar

    If only 1 url is used, the memory is not increased so much.
    But we usually have many svg icons in 1 screen so the problem is still there.

    Does this reproduce with asset SVGs instead of network images?

    Yes

    Please share a DevTools memory snapshot or performance trace if possible.

    I cannot capture snapshot but I have a image here

    Image
  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Apr 6, 2026
  5. saurabh-mirajkar commented on Apr 6, 2026

    @saurabh-mirajkar
    Contributor

    Thanks for the additional details. Labelling for team-engine to investigate further.

  6. added
    platform-iosiOS applications specifically
    engineflutter/engine related. See also e: labels.
    c: performanceRelates to speed or footprint issues (see "perf:" labels)
    a: imagesLoading, displaying, rendering images
    and removed
    in triagePresently being triaged by the triage team
    on Apr 6, 2026
  7. added
    P2Important issues not at the top of the work list
    on Apr 6, 2026
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

    P2Important issues not at the top of the work lista: imagesLoading, displaying, rendering imagesc: performanceRelates to speed or footprint issues (see "perf:" labels)engineflutter/engine related. See also e: labels.platform-iosiOS applications specificallyteam-engineOwned by Engine teamtriaged-engineTriaged by Engine team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions