fix(darwin): create MIDINetworkSession lazily, not at plugin init - #175
Merged
mortenboye merged 3 commits intoSep 3, 2026
Merged
Conversation
Touching MIDINetworkSession.default() in setup() makes iOS 14+ show the system 'Allow [app] to find devices on local networks' permission prompt at app startup, even though network MIDI is disabled by default. Apps that only use Bluetooth/USB/virtual MIDI get a confusing permission dialog before the first screen. Create the session lazily in setNetworkSessionEnabled(true) instead — the existing explicit opt-in for network (RTP) MIDI. Bluetooth/USB MIDI go through CoreMIDI without the network session and are unaffected. Verified on iOS simulator: prompt no longer appears at launch; BLE/USB device enumeration unchanged; setNetworkSessionEnabled(true) still enables the network session.
mortenboye
reviewed
Sep 3, 2026
Package changelogs in this repo are generated by `melos version` from conventional commits. A hand-written `## Unreleased` heading would be stranded above the next version section and ship to pub.dev permanently. The entry is generated from this PR's `fix(darwin):` commit at release time instead. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Drops the now-empty `#if os(iOS)` block from `setup()` and moves the rationale to `setNetworkSessionEnabled`, where the session is actually created. Without it, a later change can re-add `MIDINetworkSession.default()` to `setup()` and silently bring back the iOS 14+ local-network prompt at launch — a regression that only shows on a real device, not in CI. Also notes in the README that the system local-network prompt now appears on the first `setNetworkSessionEnabled(true)` rather than at app launch. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
|
Thank you for your contribution, this will go into the next reelase. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On iOS 14+, touching
MIDINetworkSession.default()insetup()makes the system show the "Allow [app] to find devices on local networks" permission prompt at app startup — even though the network session is disabled by default (isEnabled == false) and the app may only use Bluetooth/USB/virtual MIDI.Users see a confusing network-permission dialog before the first screen, with no way for the app to avoid it (the standard
NSLocalNetworkUsageDescriptionstring does not remove the prompt, it only changes the body text).Fix
Stop creating the session at plugin init. Create it lazily inside
setNetworkSessionEnabled(true)— which is already the documented, explicit opt-in for network (RTP) MIDI (see the iOS-specific API added in 0.4.15).Impact
setNetworkSessionEnabled(true): unchanged — the session is created at the same call, identical behavior afterwards.isNetworkSessionEnabled()still reportsfalsebefore any session exists, matching the disabled-by-default semantics.Testing
Verified on the iOS simulator with an app using this plugin:
setNetworkSessionEnabled(true)still creates and enables the network session.