Closed Bug 1167465 Opened 9 years ago Closed 9 years ago

Exposing Allowed Audio Channels in System App's Window

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla44
Tracking Status
firefox44 --- fixed

People

(Reporter: evanxd, Assigned: baku)

References

Details

(Keywords: dev-doc-needed)

Attachments

(2 files)

      No description provided.
Blocks: 1165134
STR:
1. Install the below patches:
* For Gaia: https://github.com/evanxd/gaia/commit/9b56248655edcbf1e25fcf6a463b42270c4fc555
* For Gecko: The  debug-bug-1167465.patch attachment(https://bugzilla.mozilla.org/attachment.cgi?id=8609114)
2. Reboot FxOS.
3. Run `adb logcat | grep 1167465` to see the log.

Expected log:
I/GeckoConsole( 2043): Content JS LOG: Bug 1167465 - Send MozContentEvent to get audio channels 
I/GeckoDump( 2043): Bug 1167465 - Send audio channel list to System app
I/GeckoConsole( 2043): Content JS LOG: Bug 1167465 - Receive audioChannels: normal,notification,telephony

Actual log:
I/GeckoConsole( 2557): Content JS LOG: Bug 1167465 - Send MozContentEvent to get audio channels 
I/GeckoDump( 2557): Bug 1167465 - Send audio channel list to System app

The environment:
Build ID               20150521160241
Gaia Revision          1126d8bee559f7cde675df2fcc6c196da9cfeba1
Gaia Date              2015-05-21 21:23:56
Gecko Revision         https://hg.mozilla.org/mozilla-central/rev/3e737d30f842
Gecko Version          41.0a1
Device Name            flame
Firmware(Release)      4.4.2
Firmware(Incremental)  eng.cltbld.20141204.004231
Firmware Date          Thu Dec  4 00:42:42 EST 2014
Bootloader             L1TC00011880
Hi Kan-Ru,

Could you take a look?

Thanks.
Flags: needinfo?(kchen)
I haven't looked into this yet, but could you try to send the event after document "load"?
Blocks: 1166172
Can't reproduce. The output is correct

1087:I/GeckoConsole( 2316): Content JS LOG: Bug 1167465 - Send MozContentEvent to get audio channels 
1090:I/GeckoDump( 2316): Bug 1167465 - Send audio channel list to System app
1091:I/GeckoConsole( 2316): Content JS LOG: Bug 1167465 - Receive audioChannels: normal,notification,telephony 

Build ID               20150610181819
Gaia Revision          27e4c1af0be302150a5f6e428666e0e3daf2a4ea
Gaia Date              2015-06-10 09:46:07
Gecko Revision         n/a
Gecko Version          41.0a1
Device Name            flame
Firmware(Release)      4.4.2
Firmware(Incremental)  eng.cltbld.20150427.192938
Firmware Date          Mon Apr 27 19:29:49 EDT 2015
Bootloader             L1TC00011880
Flags: needinfo?(kchen)
gecko rev 516ac5b38c9ae90a5323b528ed9a09a4c87b1598
Maybe the issues is about the implementation of Audio Channel Management APIs. So we need a specific gecko rev to reproduce.

The below are the steps to install the gecko in the device.
How to enable the AudioChannelManager.
1. To install the gecko module to enable the APIs:
* Unzip the b2g.tar.gz attachment[1].
* Run `adb shell mount -o remount,rw /system` to have capability to write file system if you don't have it.
* Run `adb push path/to/the/attachment/directory/b2g /system/b2g/`
2. Restart the device.
3. Done.

[1]: https://drive.google.com/open?id=0B3MxK4_nj3bpcnZwUFdNWlM3Nkk&authuser=1
And I'll try to reproduce the bug again. If I can do it successfully, I'll do needinfo and let you know. Thanks for the help.
Flags: needinfo?(evanxd)
Blocks: 1180618
New STR:

1. Add the gaia patch[1]
2. Reboot FxOS.
3. Run `adb logcat | grep 1167465` to see the log.

Expected result:
See the log: `I/GeckoConsole( 2191): Content JS LOG: Bug 1167465: get audio channels: normal,content,notification,ringer`

Actual result:
Cannot see the log: `I/GeckoConsole( 2191): Content JS LOG: Bug 1167465: get audio channels: normal,content,notification,ringer`

If we wait for a while and send the content event with the patch[2], then we can see the excepted log.

[1]: https://github.com/evanxd/gaia/commit/e0387eab1227da58e2b88731dbf973937ba3ff11
[2]: https://github.com/evanxd/gaia/commit/74d42719472533ec491df4281613c4111ab2e249
Flags: needinfo?(evan)
The Comment 9 is based on the environment[1].

[1]:
Build ID               20150803150205
Gaia Revision          dbacf8364f4505d021b7d8fb9cabea325004dbcc
Gaia Date              2015-08-03 16:38:49
Gecko Revision         https://hg.mozilla.org/mozilla-central/rev/abc56d57f6e1
Gecko Version          42.0a1
Device Name            flame
Firmware(Release)      4.4.2
Firmware(Incremental)  eng.cltbld.20150622.193834
Firmware Date          Mon Jun 22 19:38:45 EDT 2015
Bootloader             L1TC00011880
Hi Kan-Ru,

We have a new STR in comment 9, and the reproduce-able environment is listed in comment 10. And this bug blocks bug 1180618.

Could you take a look? Thanks.
Flags: needinfo?(kchen)
Summary: Cannot send MozChromeEvent to System app before `MozAfterPaint` event is triggered in shell.js. → Cannot send MozChromeEvent to System app at startup time
https://github.com/mozilla-b2g/gaia/blob/4df9592/apps/system/js/core.js#L59-L64

"Note that shell.js starts listen for the mozContentEvent event at
 mozbrowserloadstart, which sometimes does not happen till window.onload."

So this had happened before. I think the problem is mozbrowserloadstart is a async message so the mozContentEvent fired before shell.js received loadstart and attached event listeners was lost. We need a better way for shell.js to listen to the mozContentEvent events.
Flags: needinfo?(kchen)
Thanks for Kan-Ru's investigate.

baku, would you like to take a look?
This bug is blocking a gaia fix[1] for audio channel management.

Thanks.

[1]: http://bugzil.la/1180618
Flags: needinfo?(amarchesini)
It's hard to avoid this races between shell.js and system app. shell.js can't notify system app because it doesn't know if system app is ready and vice versa. Hopefully a new API would solve this problem.
My advices is, don't send mozContentEvent until you have received your first mozChromeEvent. Currently this is after the "load" event.
Kan-Ru, thanks for the advice. I'll try that, hope it'll work.
> baku, would you like to take a look?
> This bug is blocking a gaia fix[1] for audio channel management.

Can this be fixed by exposing allowedAudioChannels array to the system app directly?
If yes, I don't think this will take too much work.
Flags: needinfo?(amarchesini) → needinfo?(evan)
Do you mean that we can do something like
```
console.log(window.allowedAudioChannels[0].name);
```
 to print a audio channel name in System App's window?

If so, we can fix the gaia bug[1].

[1]: http://bugzil.la/1180618
Flags: needinfo?(evan)
Yes, I was proposing something like this. If yes, and alwu agrees, I/we can go implementing it.
Flags: needinfo?(alwu)
Nice!

Just one more question, exposing allowedAudioChannels is only for System app, not for other apps, right?

It means that apps except System app still cannot access their allowedAudioChannels directly.
I have the same question as Evan's.
Can we expose the allowedAudioChannels only for system app? 
I agree if we can make sure this point.
Flags: needinfo?(alwu)
> Just one more question, exposing allowedAudioChannels is only for System
> app, not for other apps, right?

correct. How urgent is this?
We can have a custom permission just for this.
Attached patch foo.patchSplinter Review
This patch is not tested. But maybe you have time to give me a feedback.
Attachment #8654940 - Flags: feedback?(alwu)
Attachment #8654940 - Flags: feedback?(alwu) → feedback+
I don't see any tests for AudioChannelManager. Alastor, do you mind to review/test this patch next week in Taipei?
Sure!
Summary: Cannot send MozChromeEvent to System app at startup time → Exposing Allowed Audio Channels in System App's Window
Assignee: nobody → amarchesini
Attachment #8654940 - Flags: review?(fabrice)
Attachment #8654940 - Flags: review?(alwu)
Keywords: dev-doc-needed
Attachment #8654940 - Flags: review?(alwu) → review+
Comment on attachment 8654940 [details] [diff] [review]
foo.patch

Review of attachment 8654940 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/apps/PermissionsTable.jsm
@@ +497,5 @@
>                                trusted: DENY_ACTION,
>                                privileged: ALLOW_ACTION,
>                                certified: ALLOW_ACTION
>                             },
> +                           "allowed-audio-channels-in-window": {

I want to rename this to allow-audio-channels-in-app
After offline discuss with Baku, we still need to modify the permission, 

If we use "certified: DENY_ACTION", the system app can not use the allowedaudiochannel.
If we use "certified: ALLOW_ACTION", all certified apps can use this attribute, that is not we want.
Comment on attachment 8654940 [details] [diff] [review]
foo.patch

Review of attachment 8654940 [details] [diff] [review]:
-----------------------------------------------------------------

Holding on review based on https://bugzilla.mozilla.org/show_bug.cgi?id=1167465#c27
Attachment #8654940 - Flags: review?(fabrice)
I propose to rename the permission system-app-only-audio-channel-in-app.

If you agree, can you take a look at the patch again?
Flags: needinfo?(fabrice)
Comment on attachment 8654940 [details] [diff] [review]
foo.patch

Review of attachment 8654940 [details] [diff] [review]:
-----------------------------------------------------------------

r=me with the permission name change
Attachment #8654940 - Flags: review+
Flags: needinfo?(fabrice)
https://hg.mozilla.org/mozilla-central/rev/a729df0cb8b4
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla44
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: