Skip to content

WINDOWS: MMSYSERR_ALLOCATED while trying to connect to same native device after Hot Restart #130

@juanoboif25

Description

@juanoboif25

Hi, i'm working on a personal project and noticed that when you hot restart (not hot reload) the app and try to connect to a previously connected native device, you get an OPEN ERROR(4): Resource already allocated message on the console. the issue comes from WindowsMidiDevice midiInOpen throwing MMSYSERR_ALLOCATED. Since the only thing that gets restarted it's the app's state and not the plugins/external resources, i'd assume that a memory freeing function could be exposed in the API and let the user handle the rest, or maybe clear the resources before trying a new connection.
I tried disconnectDevice after restart but it doesn't remember having any native device being previously connected so it does nothing, also tried teardown.

You can reproduce it on the example app by:

  1. Connecting to native device A
  2. Hot restarting the app
  3. Connecting to native device A

flutter doctor:
[√] Flutter (Channel master, 3.28.0-2.0.pre.38574, on Microsoft Windows [Version 10.0.22631.4317],
locale en-US)
[√] Windows Version (11 Pro 64-bit, 23H2, 2009)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Build Tools 2022 17.4.3)
[√] Android Studio (version 2024.1)
[√] VS Code (version 1.96.2)
[√] Connected device (3 available)
[√] Network resources

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions