Closed Bug 909124 Opened 11 years ago Closed 11 years ago

[b2g desktop] shell.js did not get correct mozbrowserloadstart event to send Gaia the pending chromeEvents

Categories

(Firefox OS Graveyard :: General, defect)

x86_64
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: rudyl, Assigned: rudyl)

References

Details

Attachments

(1 file, 3 obsolete files)

STR
====

After 3rd-party IME framework has landed to Gaia master, bc8c1c962addd419b48ba12c6d8ddabdf9805391, we found that it would fail to run Gaia with b2g desktop.

It would be stuck at the init logo.
When this issue can be reproduced, I noticed that Gaia system app would not received "webapps-registry-ready" chromeEvent from Gecko to start loading the FTU app.

We do mozApps.mgmt.getAll() in shared/js/keyboard_helper.js, which is invoked from keyboard_manager.js, I suspect this might be the root cause.

I am trying to open debug log of Gecko's mozApps API to see what happened.
My comment in the email: I would suggest modifying and building b2g desktop in a way where it includes our desktop shims.

Telephony shim: https://github.com/mozilla-b2g/gaia/blob/master/tools/extensions/desktop-helper/content/data/lib/telephony.js
:rudyl++ I can confirm this is not the lockscreen error mentioned in the mailing list... That has been present for the last month without any obvious breakage.
I am tracing to b2g/chrome/content/shell.js, when this issue occurs, `shell.isHomeLoaded` won't be set as true, so Gaia would not receive the chromeEvents for "webapps-registry-ready".

Still trying to figure out why `shell.isHomeLoaded` won't be set as true.
(Due to the 'load' event was not emitted from content?)
Hi James,

We need logs to identify the problem.

Could you provide the js log when error occurs by running b2g-desktop with `-jsconsole` parameter. For example on ubuntu 12.x, I run b2g-destop with the following command:

 b2g -profile $GAIA_PROFILE -jsconsole
I'm building custom desktop b2g to diagnose this.
BTW,
1. Don't go through mgmt.getAll before applicationready.
2. I see load event is correctly fired.
3. It seems sometimes cannot be reproduced...timing issue? Race condition?
[Investigation Result]
I found that the root cause might be in mozbrowser API event.

In shell.js
http://mxr.mozilla.org/mozilla-central/source/b2g/chrome/content/shell.js#465

We will wait for mozbrowserloadstart event and in that event handler, trying to listen for content's load event.
However, when this issue occurs, somehow it would receive 2 times of mozbrowserloadstart event with document.location == "about:blank".
So it never add event listener for content load event.


[Potential workaround]
We might be able to listen to mozbrowserlocationchange and then add event listener to content load.

Still need more time to test if this workaround can work on device and ff nightly.
[Root Cause]
When running Gaia with b2g desktop, most of the time, shell.js would get mozbrowserloadstart event with document.location == "about:blank", so it did not add event listener for Gaia's onload, so Gais would be stuck at waiting for Gecko's chromeEvent.

Before 3rd-party IME has landed, bc8c1c962addd419b48ba12c6d8ddabdf9805391, this would still work because we would load keyboard iframe immediately after loading Gaia system app, and this will generate additional mozbrowserloadstart for shell.js to do the follow-up init process.

After 3rd-party IME landed, we would delay keyboard iframe loading until we got the chromeEvent of 'webapps-registry-ready' from Gecko, so the above "magic" from loading keyboard iframe won't happen again.

I have a patch to workaround this.
Assignee: nobody → rlu
Summary: 3rd-party IME framework broke Gaia running in b2g desktop → [b2g desktop] shell.js did not get correct mozbrowserloadstart event to send Gaia the pending chromeEvents
Attached patch Bug909124.patch (obsolete) — Splinter Review
Hi Fabrice, Tim,

This patch is to workaround the srange event sequences of mozbrowserloadstart by listening to mozbrowserlocationchange.

If we get 'mozbrowserloadstart' and found its document.location is still "about:blank", then we could expect there will be a mozbrowserlocationchange event to come.

Please help review this.
Thank you.
Attachment #795440 - Flags: review?(timdream)
Attachment #795440 - Flags: review?(fabrice)
Component: Gaia::Keyboard → General
Attached patch Bug909124.patch - V1.1 (obsolete) — Splinter Review
Slightly modify the patch.
Will remove the debug logs after review.

Thanks.
Attachment #795440 - Attachment is obsolete: true
Attachment #795440 - Flags: review?(timdream)
Attachment #795440 - Flags: review?(fabrice)
Attachment #795444 - Flags: review?(timdream)
Attachment #795444 - Flags: review?(fabrice)
Comment on attachment 795444 [details] [diff] [review]
Bug909124.patch - V1.1

I am not qualified of reviewing B2G runtime.
Attachment #795444 - Flags: review?(timdream) → feedback+
Comment on attachment 795444 [details] [diff] [review]
Bug909124.patch - V1.1

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

r=me but I'd like to see the final version with all the debug logs removed.

::: b2g/chrome/content/shell.js
@@ +327,5 @@
>      window.removeEventListener('MozApplicationManifest', this);
>      window.removeEventListener('mozfullscreenchange', this);
>      window.removeEventListener('sizemodechange', this);
>      this.contentBrowser.removeEventListener('mozbrowserloadstart', this, true);
> +    this.contentBrowser.removeEventListener('mozbrowserlocationchange', this, true);

You already remove these event listeners in onContentStart.

@@ +584,5 @@
>          let sender = message.target.QueryInterface(Ci.nsIMessageSender);
>          sender.sendAsyncMessage(activity.response, { success: false });
>        }
>      }
> +  },

nit: add blank line.
Attachment #795444 - Flags: review?(fabrice) → review+
Attached patch Bug909124.patch - V1.2 (obsolete) — Splinter Review
Carry forward the r+.

Fabrice, Tim,

Thanks for the review.
Attachment #796438 - Flags: review+
Attachment #795444 - Attachment is obsolete: true
Add r=fabrice to the commit message.
Attachment #796438 - Attachment is obsolete: true
Attachment #796480 - Flags: review+
https://hg.mozilla.org/mozilla-central/rev/82d22aca8337
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: