Ticket #11193 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

XO-1.75: Scratch & Etoys freeze when playing audio

Reported by: bert Owned by: saadia
Priority: high Milestone: 1.75-software
Component: etoys-activity Version: 1.75-B1
Keywords: Cc: erikos, godiard, corbet@…, greenfeld
Action Needed: no action Verified: no
Deployments affected: Blocked By: #10831
Blocking: #11454

Description

To reproduce, launch Etoys, click the red car icon on the top-right, click the yellow exclamation mark button next to "Car make sound: croak".

Etoys freezes, and fills its log file with gazillions of entries reading:

snd_pcm_writei returned -11

Build 19 / q4b08

Attachments

sqUnixSoundALSA.c (20.7 kB) - added by godiard 3 years ago.
sqUnixSoundALSA.diff (2.7 kB) - added by godiard 3 years ago.

Change History

Changed 3 years ago by Quozl

  • next_action changed from never set to diagnose
  • blockedby 10831 added

Etoys freeze when playing data is probably related to #10831, if it only occurs on XO-1.75 and not on XO-1 not XO-1.5.

Changed 3 years ago by Quozl

  • next_action changed from diagnose to test in build

Please test in os6.

Changed 3 years ago by greenfeld

  • next_action changed from test in build to diagnose

Still broken in os7; same -11 error.

Changed 3 years ago by erikos

Scratch has the same issue and the same error:

- launch Scratch

- on the left select 'Sound' as category

- click on 'play sound [meow]'

sound_Start: snd_pcm_hw_params: Invalid argument
snd_pcm_writei returned -11

Changed 3 years ago by greenfeld

  • priority changed from normal to high
  • summary changed from XO-1.75: Etoys freezes when playing audio to XO-1.75: Scratch & Etoys freeze when playing audio

Changed 3 years ago by greenfeld

  • cc saadia added

Changed 3 years ago by martin.langhoff

  • cc erikos, godiard added; saadia removed
  • owner changed from bert to saadia

Changed 3 years ago by bert

  • blocking 11454 added

(In #11454) Most likely another symptom of #11193

Changed 3 years ago by saadia

  • cc corbet@… added

I usually reproduce it in Scratch, by clicking the Sound toolbox, and then "play sound (meow)". The snd_pcm_writei error appears in ~olpc/.sugar/default/logs/edu.mit.media.ScratchActivity-1.log

I tried debugging this in sound/core/pcm_native.c. At one point (after turning on the RULES_DEBUG flag in that file) I thought it had to do with the RATE hw param but I'm not sure.

The code from the Squeak sound driver that is making the snd_pcm_write_i is here: http://squeakvm.org/cgi-bin/viewcvs.cgi/trunk/platforms/unix/vm-sound-ALSA/sqUnixSoundALSA.c?rev=2168&view=auto

Changed 3 years ago by corbet

11 is EAGAIN. There seems to be a clear bug in the squeak code; it is asking for non-blocking I/O, but it is not prepared for an EAGAIN return.

That said, the reason it's getting EAGAIN is because something is clogging up in the sound driver. If I turn off non-blocking behavior, it just wedges. Figuring that one out seems like a logical next step...

Changed 3 years ago by Quozl

Tested, kernel e3f6aac does fix.

Changed 3 years ago by saadia

One thing to note is there are some warnings on the console: [ 124.063794] snd_pcm_update_hw_ptr0: 110 callbacks suppressed [ 129.133711] snd_pcm_update_hw_ptr0: 118 callbacks suppressed [ 134.189602] snd_pcm_update_hw_ptr0: 119 callbacks suppressed [ 139.245962] snd_pcm_update_hw_ptr0: 119 callbacks suppressed [ 144.303130] snd_pcm_update_hw_ptr0: 116 callbacks suppressed [ 149.318714] snd_pcm_update_hw_ptr0: 118 callbacks suppressed [ 154.375691] snd_pcm_update_hw_ptr0: 118 callbacks suppressed [ 159.431626] snd_pcm_update_hw_ptr0: 119 callbacks suppressed [ 164.487347] snd_pcm_update_hw_ptr0: 118 callbacks suppressed

Changed 3 years ago by godiard

I am trying to test the proposal of changes to squeak by Jonathan Corbet

with os12 and os11 (without changes in the kernel),

to see if we can solve the problem from the side of squeak.

os12 + scratch without changes, playing sound works, a little crispy, recording gives a error: "sound StartRecording: snd_pcm_hw_params: Invalid argument"

os12 + scratch with changes (*), playing sound works ok, recording show a error: "unable to find control Capture, 0"

os11 + scratch with changes, scratch frozen like without changes.

Attached is a diff with the changes I did (I hope I understood Jon proposal) and the original code.

A quick note: in the code we have

snd(pcm_nonblock(output_handle, 1), "sound_Start: snd_pcm_nonblock"); snd(async_add_pcm_handler(&output_handler, output_handle, output_callback, 0), "soundStart: snd_add_pcm_handler");

I have replaced 1 by 0 [1], but I don't know what to do with async_add_pcm_handler

Changed 3 years ago by godiard

Changed 3 years ago by godiard

Changed 3 years ago by godiard

Derek O'Connell, squeak developer said:

Hi all,

I last looked at ALSA code over three years ago for the Nokia tablets and elected to bypass ALSA altogether, primarily because it and the PCM lower level code was not handling EINTR/EAGAIN properly. The resulting Squeak plug-in was later reworked to create the PulseAudio plug-in. So I can't help other than to suggest using the Piano Keyboard morph to test since that will make any excessive latency obvious where-as simply playing a single sound will not.

Changed 3 years ago by martin.langhoff

  • next_action changed from diagnose to test in build

On the 11.3.1 stream, OS12 and later have a kernel-side workaround, so please test-in-build.

We are working with upstreams to get the right fix into the activities too -- see #11500 for eToys and #11501 for Scratch.

Changed 3 years ago by greenfeld

  • status changed from new to closed
  • next_action changed from test in build to no action
  • resolution set to fixed

We no longer freeze eToys or Scratch when playing audio in 11.3.1 os18. However the sample sounds in Scratch play back a bit scratchy, and recording audio in Scratch still does not work.

Changed 3 years ago by godiard

  • cc greenfeld added

Sam: if you close this ticket, please open one about sound quality and another about recording.

Note: See TracTickets for help on using tickets.