Closed Bug 819852 Opened 12 years ago Closed 11 years ago

Background music intermittently plays while the phone is ringing because looped <audio> doesn't occupied the channel the whole time

Categories

(Firefox OS Graveyard :: General, defect, P2)

ARM
Gonk (Firefox OS)
defect

Tracking

(blocking-basecamp:+, firefox19 wontfix, firefox20 wontfix, firefox21 fixed, b2g18 fixed)

VERIFIED FIXED
B2G C4 (2jan on)
blocking-basecamp +
Tracking Status
firefox19 --- wontfix
firefox20 --- wontfix
firefox21 --- fixed
b2g18 --- fixed

People

(Reporter: alive, Assigned: mchen)

References

Details

Attachments

(1 file, 2 obsolete files)

STR:
1. Open Music app
2. Play a song.
3. Call in by another phone.

Expected:
1. The music is totally muted or paused.

Actual:
1. The music plays intermittently when the ringing sound stops.(Before next ring)

Note:
This is not dupe of bug 819849.
blocking-kilimanjaro: --- → ?
OS: Mac OS X → Gonk (Firefox OS)
Hardware: x86 → ARM
Wrong flag.
blocking-basecamp: --- → ?
blocking-kilimanjaro: ? → ---
BB+, P2 - severe usability issue
blocking-basecamp: ? → +
Priority: -- → P2
Assignee: nobody → dkuo
Target Milestone: --- → B2G C3 (12dec-1jan)
Bug 815569 won't actually help here. The only thing that will help is to use a looping audio rather than repeatedly calling .play().

Bug 815569 would just mean that we'd play a different set of snippets of music between the rings than we do now.
No longer depends on: 815569
(In reply to Jonas Sicking (:sicking) from comment #3)
> Bug 815569 won't actually help here. The only thing that will help is to use
> a looping audio rather than repeatedly calling .play().
> 
> Bug 815569 would just mean that we'd play a different set of snippets of
> music between the rings than we do now.

Dominic, would you give some updates on your proposed fix?
I just took a look at the code of Dialer, and found out the audio element does use loop = true to play a ringtone.

I guess it might be an issue of the implementation on looping an audio in gecko, looks like while we are looping an audio in Dialer, it does not always occupy the mozAudioChannel, it releases mozAudioChannel after every cycle when the ringtone ends, so Music in background will play intermittently in the interval of end and start of that ringtone.

If my guessing is right, it should be possible to fix this bug, but a workaround actually.

Here is my proposal:
1. Listen to timeupdate event of audio element.

2. Check if audio.currentTime is smaller then audio.duration,
like (this.audio.currentTime >= this.audio.duration - 1), cannot be equal cause we don't want the audio to reach to the end, then trigger mozAudioChannel change.

3. Seek audio.currentTime to 0 so it will just like a restart of the ringtone.

And I think Music app cannot do anything to help this bug, since Music shouldn't do anything to audio element when mozAudioChannel changes, except the UI works.
If the music app is already using looping, then I think we should fix this in the platform. I.e. no changes should be needed in the app, instead the platform should ensure to occupy the "ringer" channel as long as the element is looping.

Matthew, is this something you could take? Or Dominic, would you be able to?
This is now a platform audio bug, according to comment 6.

Marco, can you help? Thanks.
Assignee: dkuo → nobody
Component: Gaia → General
Flags: needinfo?(mchen)
Summary: Background music intermittently plays while the phone is ringing → Background music intermittently plays while the phone is ringing because looped <audio> doesn't occupied the channel the whole time
yep, I take this.
Assignee: nobody → mchen
Flags: needinfo?(mchen)
Andrea can take this.
Assignee: mchen → amarchesini
Actually, why don't we give this to someone that doesn't have a big pile of B2G bugs already :)
Assignee: amarchesini → kinetik
QA Contact: jshih
Hi kinetik,

I want to help here because there is no Christmas Eve here.
Assignee: kinetik → mchen
Attached patch Patch v1 (obsolete) — Splinter Review
To modify the UpdateAudioChannelPlayingState() as below.

If media element is not in pause state and attribute of Loop is true, then it means this media element will be continued to play again when it is in end of the stream.

So we keep audio channel state as playing in case above in order to prevent other sound fires in that gap.
Attachment #695920 - Flags: review?(kinetik)
Attached patch Patch v2 (obsolete) — Splinter Review
Attachment #695920 - Attachment is obsolete: true
Attachment #695920 - Flags: review?(kinetik)
Attachment #695921 - Flags: review?(kinetik)
is :kinetik available to review this bug? if not, will someone else be able to?
Target Milestone: B2G C3 (12dec-1jan) → B2G C4 (2jan on)
Would this patch change the timing to fire audio-channel-changed event?
Which event is that?

It only changes behavior for looping elements, at least.
it's an event that the AudioChannelService fires on Gaia whenever the currently active audio channel changes. I.e. when we switch from "normal" to "alarm" or to "none".
Since media element with loop property doesn't release the audio channel until it is paused, the audio-channel-changed event will be held to this media element's channel (if it is highest one now).
Wait for green lights from try server then check in patch.
https://tbpl.mozilla.org/?tree=Try&rev=72960020c8ec
1. Pass the try server and ask for checkin-needed.
2. Add reviewer and a=blocking-basecamp.
Attachment #695921 - Attachment is obsolete: true
Attachment #698560 - Flags: review+
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/0f42175818fe
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Depends on: 827961
Gaia:
  Rev     7fdd1dd731ccdcf09e0c51aeefc361adc4bfc11a
BuildID   20130124114510
Version   18.0

Verified.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: