[Bluetooth] bluetooth app support AMD for BT v2 API implementation

RESOLVED FIXED in Firefox OS master

Status

Firefox OS
Gaia::Settings
RESOLVED FIXED
4 years ago
3 years ago

People

(Reporter: iliu@mozilla.com, ianliu.moz@gmail.com, Assigned: iliu@mozilla.com, ianliu.moz@gmail.com)

Tracking

unspecified
2.2 S1 (5dec)
x86
Mac OS X
Dependency tree / graph

Firefox Tracking Flags

(b2g-master fixed)

Details

Attachments

(2 attachments)

Since we are going to implement BT v2 API in Bluetooth app, we have to make it supporting AMD. That will be more easy to re-organise the architecture.
(Assignee)

Updated

4 years ago
Blocks: 1070823
(Assignee)

Updated

4 years ago
Blocks: 1102798
(Assignee)

Updated

4 years ago
No longer blocks: 1070823
(Assignee)

Updated

4 years ago
Status: NEW → ASSIGNED
Target Milestone: --- → 2.2 S1 (5dec)
Created attachment 8535476 [details]
WIP for BT app with AMD

This is a WIP for support AMD in Bluetooth app. I find out some performance issue to block pairing dialog while receiving pairing request. If we load AMD module before show pairing dialog, it will spend 1 min. This situation is very bad for showing a dialog immediately.

I would like to skip supporting AMD in Bluetooth app. Then, we keep to implementation new code base for v2 API. If we want to support AMD in Bluetooth app, we have to overcome the performance issue first.

Arthur, would you have any suggestion here? Or you have any other idea for the performance issue. Thanks.
Attachment #8535476 - Flags: feedback?(arthur.chen)
** startup_pair.js is loaded @491.479166 **
I/Bluetooth Manager(14102): Content JS LOG: --> startup_pair(): 2.performance.now() = 491.479166 
I/Bluetooth Manager(14102):     at <anonymous> (app://bluetooth.gaiamobile.org/js/startup_pair.js:35:0)

** config/require.js is loaded @697.7844789999999 ** (There is no any script here beside of console.log.) 
I/Bluetooth Manager(14102): Content JS LOG: --> startup_pair(): 4.performance.now() = 697.7844789999999 
I/Bluetooth Manager(14102):     at <anonymous> (app://bluetooth.gaiamobile.org/js/config/require.js:1:0)

** require(['config/require'], function() {  // be executed @1486.1558850000001    }); **
I/Bluetooth Manager(14102): Content JS LOG: --> startup_pair(): 3.performance.now() = 1486.1558850000001 
I/Bluetooth Manager(14102):     at <anonymous> (app://bluetooth.gaiamobile.org/js/startup_pair.js:47:2)


Looks like `require(['config/require'], function() {  // be executed @1486.1558850000001    });`. It means that it spend 800 millisecond while the config/require module is loaded.
(In reply to Ian Liu [:ianliu] from comment #2)
> ** config/require.js is loaded @697.7844789999999 ** (There is no any script

> ** require(['config/require'], function() {  // be executed
> @1486.1558850000001    }); **

In other words, it means that the caller spends 800 millisecond after `require.js` is run completely. I'm not sure why the return time cost 800 millisecond.
I try to hack the BT app to be a homesreen app with icon. It's able to launch BT app from the homescreen. It is quickly to launch BT app with AMD module. Per comment 2, not sure why it costs much time while system message launch BT app with AMD module. Especially, it spend 800 millisecond while the config/require module is loaded. It's not reasonable.

I/Bluetooth Manager(15923): Content JS LOG: --> hello AMD is ready.. :-) 
I/Bluetooth Manager(15923):     at <anonymous> (app://bluetooth.gaiamobile.org/js/startup_pair.js:5:0)
I/Bluetooth Manager(15923): Content JS LOG: --> startup_pair(): 1. performance.now() = 297.602028 
I/Bluetooth Manager(15923):     at <anonymous> (app://bluetooth.gaiamobile.org/js/startup_pair.js:12:0)
I/Bluetooth Manager(15923): Content JS LOG: --> startup_pair(): 4.performance.now() = 318.736455 
I/Bluetooth Manager(15923):     at <anonymous> (app://bluetooth.gaiamobile.org/js/config/require.js:1:0)
I/Bluetooth Manager(15923): Content JS LOG: --> startup_pair(): 3.performance.now() = 352.59671599999996 
I/Bluetooth Manager(15923):     at <anonymous> (app://bluetooth.gaiamobile.org/js/startup_pair.js:47:2)
Another hack to launch BT app via activity request. The cost time is same with launching app from home screen in comment 4.

I/Bluetooth Manager(17612): Content JS LOG: --> hello AMD is ready.. :-) 
I/Bluetooth Manager(17612):     at <anonymous> (app://bluetooth.gaiamobile.org/js/startup_pair.js:5:0)
I/Bluetooth Manager(17612): Content JS LOG: --> startup_pair(): 1. performance.now() = 195.305676 
I/Bluetooth Manager(17612):     at <anonymous> (app://bluetooth.gaiamobile.org/js/startup_pair.js:12:0)
I/Bluetooth Manager(17612): Content JS LOG: --> startup_pair(): 4.performance.now() = 212.746718 
I/Bluetooth Manager(17612):     at <anonymous> (app://bluetooth.gaiamobile.org/js/config/require.js:1:0)
I/Bluetooth Manager(17612): Content JS LOG: --> startup_pair(): 3.performance.now() = 234.194218 
I/Bluetooth Manager(17612):     at <anonymous> (app://bluetooth.gaiamobile.org/js/startup_pair.js:47:2)
Comment on attachment 8535476 [details]
WIP for BT app with AMD

Clear the flag for now as we may drop the use of AMD. Ian, could you summarize the findings in case we may have to continue investigating this in the future? Thanks.
Attachment #8535476 - Flags: feedback?(arthur.chen)
Part A:

Per above comment, I summarize the experiment result for investigation in the future. We measure the time which is running into the required module's callback function. The time difference is from script loaded[1] to required module's callback[2]. It's measuring how long is needed to load the alameda.js only.

[1] https://github.com/ian-liu/gaia/blob/5b3b090e0e6bfc17c9e1d4368316ab17b54aab31/apps/bluetooth/js/startup_pair.js#L12
[2] https://github.com/ian-liu/gaia/blob/5b3b090e0e6bfc17c9e1d4368316ab17b54aab31/apps/bluetooth/js/startup_pair.js#L47

================ measuring log in gaia/apps/bluetooth/js/startup_pair.js ================
require(['config/require'], function() {
  console.log('--> startup_pair(): 3.performance.now() = ' + performance.now());
}); 

[Case 1: BT app is launching via system message('bluetooth-pairing-request').][comment 2]
It took 800 millisecond to run into the callback function.


[Case 2: BT app is launching via home screen icon.][comment 4]
It took < 100 millisecond to run into the callback function.


[Case 3: BT app is launching via activity request.][comment 5]
It took < 50 millisecond to run into the callback function.
Part B:

I put some performance log for measuring the scope of '//data-main support.'(https://github.com/ian-liu/gaia/compare/bluetooth/bug1102796_bt_app_with_AMD#diff-4601edda07a649cd4d92a3d9ddfa1955R1413)

There is nothing abnormal to spend much time here.
Leave assigned state since I will start to implement pairing flow in BT app without AMD.
Status: ASSIGNED → NEW
(Assignee)

Updated

4 years ago
See Also: → bug 1086598
After applied patch AMD 0.2.0-native-promise version(https://github.com/mozilla-b2g/gaia/pull/26832), it's improving the performance time. The loading time(running into the required module's callback function) is reduced to 50 ~ 100 millisecond[1]. I think it's acceptable to show a dialog immediately.


I/Bluetooth Manager( 1496): Content JS LOG: --> hello AMD is ready.. :-) 
I/Bluetooth Manager( 1496):     at <anonymous> (app://bluetooth.gaiamobile.org/js/startup_pair.js:5:0)
I/Bluetooth Manager( 1496): Content JS LOG: --> startup_pair(): 1. performance.now() = 288.56541699999997 
I/Bluetooth Manager( 1496):     at <anonymous> (app://bluetooth.gaiamobile.org/js/startup_pair.js:12:0)
I/Bluetooth Manager( 1496): Content JS LOG: --> startup_pair(): 3.performance.now() = 327.358125 
I/Bluetooth Manager( 1496):     at <anonymous> (app://bluetooth.gaiamobile.org/js/startup_pair.js:47:2)
I/Bluetooth Manager( 1496): Content JS LOG: --> pairingInfo = [object Object] 
I/Bluetooth Manager( 1496):     at <anonymous> (app://bluetooth.gaiamobile.org/js/startup_pair.js:16:2)
I/Bluetooth Manager( 1496): Content JS LOG: --> call window.open.. 
I/Bluetooth Manager( 1496):     at <anonymous> (app://bluetooth.gaiamobile.org/js/startup_pair.js:34:2)
I/Bluetooth Manager( 1496): Content JS LOG: --> startup_pair(): 2.performance.now() = 329.013906 
I/Bluetooth Manager( 1496):     at <anonymous> (app://bluetooth.gaiamobile.org/js/startup_pair.js:35:0)

[1] Measuring time: [3.performance.now() - 1.performance.now()] = 41 millisecond
Comment on attachment 8535476 [details]
WIP for BT app with AMD

Since we fixed performance issue for AMD module, I have updated the WIP for all new Bluetooth app. And I have a manual test for basic functionality(share file, pairing process). It's still working fine.

Arthur, I would like your feedback for the architecture changed. Thanks.
Attachment #8535476 - Flags: feedback?(arthur.chen)
(Assignee)

Updated

3 years ago
Status: NEW → ASSIGNED
Comment on attachment 8535476 [details]
WIP for BT app with AMD

The architecture is good. f=me.
Attachment #8535476 - Flags: feedback?(arthur.chen) → feedback+
Created attachment 8552862 [details] [review]
pull request 27149

Arthur, thanks for your feedback. I updated the patch with your suggestion. And double-check functionality and unit tests are working fine as before. We can go into review state.
Attachment #8552862 - Flags: review?(arthur.chen)
Comment on attachment 8552862 [details] [review]
pull request 27149

Please check my comments in github, thanks.
Attachment #8552862 - Flags: review?(arthur.chen)
Comment on attachment 8535476 [details]
WIP for BT app with AMD

Revised patch which are discussed in Settings::Bluetooth before. Will need Arthur's review again. Thanks.
Attachment #8535476 - Flags: review?(arthur.chen)
Comment on attachment 8535476 [details]
WIP for BT app with AMD

Clean flag since it's a WIP.
Attachment #8535476 - Flags: review?(arthur.chen)
Comment on attachment 8552862 [details] [review]
pull request 27149

We should review in the same pull request here. Sorry for above confused flag.
Attachment #8552862 - Flags: review?(arthur.chen)
Comment on attachment 8552862 [details] [review]
pull request 27149

r=me, thank you!
Attachment #8552862 - Flags: review?(arthur.chen) → review+
(Assignee)

Updated

3 years ago
Keywords: checkin-needed
(Assignee)

Updated

3 years ago
Component: Bluetooth → Gaia::Settings
(Assignee)

Updated

3 years ago
Keywords: checkin-needed
(Assignee)

Updated

3 years ago
Keywords: checkin-needed

Updated

3 years ago
Keywords: checkin-needed
There was an error creating the taskgraph, please try again. If the issue persists please contact someone in #taskcluster.
Since the patch is landed, we can close the issue now.

Gaia/master: d7d22d2e1ae9dd6652c8843f2fb5759d6439f1af
Status: ASSIGNED → RESOLVED
Last Resolved: 3 years ago
status-b2g-master: --- → fixed
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.