Opening a new activity is slow

RESOLVED WORKSFORME

Status

Firefox OS
Gaia::System
RESOLVED WORKSFORME
2 years ago
2 years ago

People

(Reporter: Guoqiang.CHEN, Unassigned)

Tracking

(Blocks: 1 bug)

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

2 years ago
Opening a new activity in an app is slow.
From  call new MozActivity(...) to activity display, it is spend 0.5s, some times need > 1s.
Blocks: 1191703
Hi Guoqiang:

Just double confirm, this is reproducible in Flame w/ 2.2, right?
Flags: needinfo?(Chenguoqiang)
Hi Guoqiang:

After discussion w/ team we would like to get some profiling data in your case, in general there are 3 checkpoints for a new activity:

1. caller App send request to Gecko
2. Gecko ask Gaia to open handler app
3. handler App is successfully launched

the assumption is the slowness you observed came from (2) or (3), so it would be good if you can insert  stamps to see the time spent there, say

for (2): https://github.com/mozilla-b2g/gaia/blob/v2.2/apps/system/js/app_window_factory.js#L125
for (3): not sure the activity in your case but you can grep the code w/ keyword "navigator.mozSetMessageHandler". For example in Gallery App it's https://github.com/mozilla-b2g/gaia/blob/v2.2/apps/gallery/js/gallery.js#L194

Thanks.

Comment 3

2 years ago
测试大约20次,平均拉起activity需要约0.5s,主要时间在应用加载初始化这,activitycreated到 activityopened,约0.4s,占总时间80%.
有时由于测下html渲染机制问题,可能应用拉起后会有1s黑屏。

01-02 02:02:50.849 I/GeckoDump(10684): cgq launchActivity dialer     //system 接到按键准备拉起dialer
01-02 02:02:50.879 I/GeckoDump(10684): cgq activity open   // sysem 收到activity open消息
01-02 02:02:50.879 I/GeckoDump(10684): cgq activity activityrequesting
01-02 02:02:50.929 I/GeckoDump(10684): cgq activity activitycreated // sysem 创建activity
01-02 02:02:51.199 I/GeckoDump(11386): cgq dialer load keypad.js     // dialer应用开始加载js
01-02 02:02:51.299 I/GeckoDump(11386): cgq dialer onload         // dialer 收到onload事件
01-02 02:02:51.339 I/GeckoDump(10684): cgq activity activityopened  //dialer
(Reporter)

Comment 4

2 years ago
Dear Wesly,

I think #c3 is provide enough info. 
"01-02 02:02:50.879"  is "2. Gecko ask Gaia to open handler app"
"01-02 02:02:51.199" and "01-02 02:02:51.299" is app load js and received load event.
Flags: needinfo?(Chenguoqiang)
Hi Luke:

As explained, would you help spend some time to look into this one? Thank!
Flags: needinfo?(lchang)

Comment 6

2 years ago
(In reply to Viga from comment #3)
> 测试大约20次,平均拉起activity需要约0.5s,主要时间在应用加载初始化这,activitycreated到
> activityopened,约0.4s,占总时间80%.

About the period between "activitycreated" and "activityopened", it's most likely caused by the "fade in" animation involved in inline-activity. You can turn it off by changing the "openAnimation" from "fade-in" to "immediate" in "activity_window.js" [1].

as my experiment:

----------------------------------------

use "fade-in"

[ActivityWindow][Contacts][ActivityWindow_0][367.903] publishing external event: created 
[ActivityWindow][Contacts][ActivityWindow_0][368.368] publishing external event: opened

created -> opened: 0.465s

----------------------------------------

use "immediate"

[ActivityWindow][Contacts][ActivityWindow_2][269.502] publishing external event: created 
[ActivityWindow][Contacts][ActivityWindow_2][269.548] publishing external event: opened 

created -> opened: 0.046s

----------------------------------------

So, you may adjust the animation method to reduce the delay or just turn it off if you don't really need it.

[1] https://github.com/luke-chang/gaia/blob/master/apps/system/js/activity_window.js#L103
Flags: needinfo?(lchang)
Guoqiang, Viga, would you help check if comment#6 works for you? Per Luke's experiment this should save a lot in your case. Thanks.
Flags: needinfo?(liweijia)
Flags: needinfo?(Chenguoqiang)
(Reporter)

Comment 8

2 years ago
Dear Wesly,

It's within 0.1s.
Viga, please verify it again. thanks.
Flags: needinfo?(Chenguoqiang)

Comment 9

2 years ago
It works in window activity, not inline way. I can still see some defect while in transaction mode.
We do a workaround which is pre-load the app before launch it.
Flags: needinfo?(liweijia)
(Reporter)

Comment 10

2 years ago
Dear Wesly,

Open an App or a new activity, it will display a black screen for 1~2 seconds sometimes,
have any way to decrease it?
Flags: needinfo?(wehuang)
(Reporter)

Comment 11

2 years ago
I submit another bug for comment 10.
https://bugzilla.mozilla.org/show_bug.cgi?id=1202349
Luke's test/suggestion is for inline's case so it's strange to me you got such result. Anyway it's good to hear you have a way to workaround it. 

I will close this one for now (not "won't fix", as it worth further clarification for comment#6 & 9 if we want to dig in more), and for comment#10/11 let's follow it in another bug.

(In reply to Viga from comment #9)
> It works in window activity, not inline way. I can still see some defect
> while in transaction mode.
> We do a workaround which is pre-load the app before launch it.
Status: NEW → RESOLVED
Last Resolved: 2 years ago
Flags: needinfo?(wehuang)
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.