Opened 5 years ago

Closed 4 years ago

Last modified 10 months ago

#11193 closed defect (fixed)

XO-1.75: Scratch & Etoys freeze when playing audio

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


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 (2)

sqUnixSoundALSA.c (20.7 KB) - added by godiard 5 years ago.
sqUnixSoundALSA.diff (2.7 KB) - added by godiard 5 years ago.

Download all attachments as: .zip

Change History (20)

comment:1 Changed 5 years ago by Quozl

  • Action Needed changed from never set to diagnose
  • Blocked By 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.

comment:2 Changed 5 years ago by Quozl

  • Action Needed changed from diagnose to test in build

Please test in os6.

comment:3 Changed 5 years ago by greenfeld

  • Action Needed changed from test in build to diagnose

Still broken in os7; same -11 error.

comment:4 Changed 5 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

comment:5 Changed 5 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

comment:6 Changed 5 years ago by greenfeld

  • Cc saadia added

comment:7 Changed 5 years ago by martin.langhoff

  • Cc erikos godiard added; saadia removed
  • Owner changed from bert to saadia

comment:8 Changed 5 years ago by bert

  • Blocking 11454 added

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

comment:9 Changed 5 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/

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:

comment:10 Changed 5 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...

comment:11 Changed 5 years ago by Quozl

Tested, kernel e3f6aac does fix.

comment:12 Changed 5 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

comment:13 Changed 5 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 5 years ago by godiard

Changed 5 years ago by godiard

comment:14 Changed 5 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.

comment:15 Changed 4 years ago by martin.langhoff

  • Action Needed 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.

comment:16 Changed 4 years ago by greenfeld

  • Action Needed changed from test in build to no action
  • Resolution set to fixed
  • Status changed from new to closed

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.

comment:17 Changed 4 years ago by godiard

  • Cc greenfeld added

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

comment:18 Changed 10 months ago by Quozl

  • Milestone 1.75-software deleted

Milestone 1.75-software deleted

Note: See TracTickets for help on using tickets.