debug: HB heartbeat 250ms + DISPATCH_ON truoc pushEvent + PUSH_SENT/PUSH_MIDI_TIMEOUT (race 800ms) cho bounce silent — phan biet main-thread block vs Rust hang
This commit is contained in:
@@ -133,16 +133,23 @@
|
||||
case 'PITCH_BEND': byteCmd = 0xE; break;
|
||||
default: byteCmd = cmd === 'NOTE_ON' ? 0x9 : 0x8; break;
|
||||
}
|
||||
window.__TAURI__.core.invoke('push_midi_event', {
|
||||
command: byteCmd,
|
||||
channel: channel,
|
||||
pitch: pitch,
|
||||
velocity: safeVelocity,
|
||||
data2: data2 === undefined ? 0 : data2,
|
||||
data3: data3 === undefined ? 0 : data3,
|
||||
sampleOffset: sampleOffset || 0,
|
||||
live: !!live
|
||||
}).then(function () {
|
||||
_pushSent = (_pushSent || 0) + 1;
|
||||
if (_pushSent % 100 === 0 && window.__sfDiag) window.__sfDiag('PUSH_SENT ' + _pushSent);
|
||||
// DIAG: Promise.race 800ms — invoke gửi đi nhưng không settle -> timeout
|
||||
// (phan biet main-thread block vs Rust hang).
|
||||
Promise.race([
|
||||
window.__TAURI__.core.invoke('push_midi_event', {
|
||||
command: byteCmd,
|
||||
channel: channel,
|
||||
pitch: pitch,
|
||||
velocity: safeVelocity,
|
||||
data2: data2 === undefined ? 0 : data2,
|
||||
data3: data3 === undefined ? 0 : data3,
|
||||
sampleOffset: sampleOffset || 0,
|
||||
live: !!live
|
||||
}),
|
||||
new Promise(function (_, rej) { setTimeout(function () { rej(new Error('timeout-800ms')); }, 800); })
|
||||
]).then(function () {
|
||||
_pushOk = (_pushOk || 0) + 1;
|
||||
if ((_pushOk + (_pushFail || 0)) % 100 === 0 && window.__sfDiag) window.__sfDiag('PUSH_MIDI ok=' + _pushOk + ' fail=' + (_pushFail || 0));
|
||||
}).catch(function (e) {
|
||||
|
||||
Reference in New Issue
Block a user