microsoft / pxt-microbit

A Blocks / JavaScript code editor for the micro:bit built on Microsoft MakeCode
https://makecode.microbit.org
Other
727 stars 638 forks source link

Audio recording length went from 4.5 seconds to 1.3 seconds in beta #5796

Closed microbit-carlos closed 3 months ago

microbit-carlos commented 3 months ago

This simple programme measures how long we can record audio until hitting the default limit:

image
let t = 0
input.onButtonPressed(Button.A, function () {
    t = input.runningTime()
    record.startRecording(record.BlockingState.Blocking)
    basic.showNumber(input.runningTime() - t)
})
input.onButtonPressed(Button.B, function () {
    record.playAudio(record.BlockingState.Blocking)
})

On MakeCode live it records around 4.5 seconds of audio: microbit-recording-live.hex.zip


On MakeCode beta less than 1.5 seconds: microbit-recording-beta.hex.zip

riknoll commented 3 months ago

is this on hardware or in the simulator?

abchatra commented 3 months ago

@carlosperate is this on hardware? Can CODAL update be the reason if on hardware?

microbit-carlos commented 3 months ago

This difference is on hardware.

It could be CODAL, but I can't think of something specific in the v0.2.63 to v0.2.67 transition that could cause this. We are using v0.2.67 in MicroPython and we don't have the same memory limitation (although MicroPython is using a lower level API).

The CODAL_DEFAULT_STREAM_RECORDING_MAX_LENGTH in StreamRecording is still set to 50K codal-core/inc/streams/StreamRecording.h#L9, which should result in the 4.5 seconds we see in MakeCode v6.

microbit-carlos commented 3 months ago

I've created a branch with MakeCode v6.0.28 and CODAL v0.2.67 (latest). The CI has created this test deployment:

On initial test it looks like it yields similar results to MakeCode v7 with the same latest CODAL. So it looks related to the CODAL update.

I've pushed branches with the in-between CODAL versions to see if we can narrow it down, but there has been several issues:

(Edit: Restarting everything that failed several times eventually worked, added the results in here to keep a single place with the summary.)

microbit-carlos commented 3 months ago

I've tried building locally the v0.2.66 branch and that worked: https://github.com/microsoft/pxt-microbit/commit/86cd987df1a4c53ad9287a2b13261041915cc539

Using pxt buildtarget --local and pxt buildtarget --cloud both finish successfully. pxt ci also run successfully.

Not sure why the pxt-buildpush is failing with: https://github.com/microsoft/pxt-microbit/actions/runs/10282431056/job/28454622812

waiting 8s for C++ build...
polling C++ build https://makecode.com/compile/3bec9d0618871b4b8c832c205460247f433817a995fb2b80d96a84a89416f387.json (attempt #31)
build log https://makecode.com/compile/3bec9d0618871b4b8c832c205460247f433817a995fb2b80d96a84a89416f387.log
build failed
Code: 504 / 504.0 GatewayTimeout
TypeError: Cannot read property 'length' of null
    at compressHex (/home/runner/work/pxt-microbit/pxt-microbit/node_modules/pxt-core/built/pxt.js:105209:37)
    at /home/runner/work/pxt-microbit/pxt-microbit/node_modules/pxt-core/built/pxt.js:105138:36
{
  sha: '3bec9d0618871b4b8c832c205460247f433817a995fb2b80d96a84a89416f387'
}
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async fillExtInfoAsync (/home/runner/work/pxt-microbit/pxt-microbit/node_modules/pxt-core/built/pxt.js:1[137](https://github.com/microsoft/pxt-microbit/actions/runs/10282431056/job/28454622812#step:5:138)73:51)
    at async MainPackage.getCompileOptionsAsync (/home/runner/work/pxt-microbit/pxt-microbit/node_modules/pxt-core/built/pxt.js:1[138](https://github.com/microsoft/pxt-microbit/actions/runs/10282431056/job/28454622812#step:5:139)19:33)
    at async /home/runner/work/pxt-microbit/pxt-microbit/node_modules/pxt-core/built/pxt.js:162510:19
    at async /home/runner/work/pxt-microbit/pxt-microbit/node_modules/pxt-core/built/pxt.js:99437:42
    at async Promise.all (index 0)
    at async promisePoolAsync (/home/runner/work/pxt-microbit/pxt-microbit/node_modules/pxt-core/built/pxt.js:99443:21)
    at async buildTargetCoreAsync (/home/runner/work/pxt-microbit/pxt-microbit/node_modules/pxt-core/built/pxt.js:162492:5)
    at async Object.ciAsync [as _callback] (/home/runner/work/pxt-microbit/pxt-microbit/node_modules/pxt-core/built/pxt.js:160821:9)

@riknoll is it possible the cloud compiler is still having sporadic issues?

(Edit: There seems to be some flakiness as well, restarting the CI jobs or trying to rebuild MakeCode project fails a few times in a row, but sometimes it succeeds.)

microbit-carlos commented 3 months ago

PR with the fix raised: