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

Firefox extension does not get MIDI interface state change events #4

Open
jeffgca opened this issue Apr 7, 2021 · 5 comments
Open

Comments

@jeffgca
Copy link
Contributor

jeffgca commented Apr 7, 2021

Chromium based browsers reliably propagate MIDI interface state changes, however Firefox + the web midi extension do not seem to get events when MIDI interfaces are added to or removed from the host system.

Browser version: Firefox 87, macOS 10.15.7, latest versions of the JAZZ plugin and web-midi extension.

To reproduce:

  1. load the Codepen linked below in Firefox and Chrome, and ensure that the built in devtools consoles are open
  2. open macOS Audio / MIDI setup utility
  3. toggle a single port IAC Loopbac Driver interface on and off
  4. observe if these connect / disconnect events are logged in the console.

Results:

Chrome: all events are logged
Firefox: no events are logged, except a single event is logged if the page is refreshed.

The location bar icon for the Jazz MIDI plugin displays the following text:

Module not found.

Please (re)install the Jazz-Plugin!

Aside: is there logging available for crashes in the underlying Jazz compiled code?

Test code:

navigator.requestMIDIAccess({sysex: true}).then((access)  => {
  console.log('sysexEnabled', access.sysexEnabled);
  
  setTimeout(function() {
     document.querySelector('#answer')
       .textContent = access.sysexEnabled ? "⚡️Yes! 🎹⚡️" : "🚫 NO 🚫";
  }, 750); 

  access.onstatechange = function(e) {
    // Print information about the (dis)connected MIDI controller
    let s = `Changed: ${e.port.name} ${e.port.manufacturer} ${e.port.state}\n`;
    console.log(e.port.name, e.port.manufacturer, e.port.state);
    document.querySelector('#last-event').textContent = s;
  };
});

( Codepen here )

@jeffgca
Copy link
Contributor Author

jeffgca commented Apr 7, 2021

An additional thing I observe when debugging this. If I disable, then re-enable the two extensions in Firefox I get these "refresh" events printed to the page:

[
  "refresh",
  {
    "ins": [
      {
        "name": "NewName",
        "manufacturer": "Unknown",
        "version": "0.0"
      }
    ],
    "outs": [
      {
        "name": "Apple DLS Synth",
        "manufacturer": "Apple",
        "version": "1.0"
      },
      {
        "name": "NewName",
        "manufacturer": "Unknown",
        "version": "0.0"
      }
    ]
  }
]

These seem to be coming from the underlying extension?

@jazz-soft
Copy link
Owner

The JSON above comes from the jazz-midi extension

@jeffgca
Copy link
Contributor Author

jeffgca commented Apr 9, 2021

The JSON above comes from the jazz-midi extension

Yeah I was able to discover this using the debugger. Should these messages not be printed to the browser console instead?

@jazz-soft
Copy link
Owner

This is the way jazz-midi communicates with JZZ. On some systems this is the only solution. JZZ deletes the text immediately after it is published.

@jeffgca
Copy link
Contributor Author

jeffgca commented Apr 9, 2021

I definitely see that - I'm just wondering if the generic Web MIDI extension needs to be adjusted to bring the behaviour closer to what developers see on a browser with native web midi support. The extra messages printed to the page aren't really the point - @jazz-soft I was wondering about your thoughts on whether it is possible to get the Firefox / Jazz combination to reliably propagate MIDI interface change events as per the spec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants