Closed Bug 880943 Opened 11 years ago Closed 11 years ago

[unagi][l10n]Sometimes l10n.js fired 'localized' event earlier than the app executed window.addEventListener('localized'... , causing app being stuck

Categories

(Firefox OS Graveyard :: Gaia::System, defect)

defect
Not set
normal

Tracking

(blocking-b2g:leo+, b2g18 fixed, b2g-v1.1hd fixed)

RESOLVED FIXED
blocking-b2g leo+
Tracking Status
b2g18 --- fixed
b2g-v1.1hd --- fixed

People

(Reporter: ying.xu, Assigned: rudyl)

References

Details

Attachments

(2 files)

User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.56 Safari/537.17

Steps to reproduce:

on both unagi and tara devices,
we lunch the gallery app, long pressed to call card view, close the gallery app,
then lunch the gallery app and repeat the operation we did before. 


Actual results:

sometimes, there show a black screen when lunching the gallery app, about 5% possibilities.
we added some log  and found that the gallery app did not receive the 'localized' event,
but the app did recieve the 'load' event


Expected results:

the app should  be lunched properly.
Summary: [unagi][l10n]Sometimes l10n.js did not fire 'localizted' event when lunching an app, causing app being stucked → [unagi][l10n]Sometimes l10n.js did not fire 'localized' event when lunching an app, causing app being stucked
unagi latest weekly build also has this issue. 
Open and close gallery app repeat, sometimes it will only show black background and can't load pictures.
apuser@JamesZhangubt:~/sp7710ga_sprdroid4.1/B2G/gaia$ adb logcat | grep 'l10n'
I/GeckoDump( 3349): [l10n] library loaded.
I/GeckoDump( 3349): [l10n] #shortTimeFormat is undefined.
I/GeckoDump( 3349): [l10n] #longDateFormat is undefined.
I/GeckoDump( 3349): [l10n] #weekday-1-long is undefined.
I/GeckoDump( 3349): [l10n] #month-0-long is undefined.
I/GeckoDump( 3349): [l10n] #searching is undefined.
I/GeckoDump( 3349): [l10n] loading [en-US] resources, asynchronously.
I/GeckoDump( 3349): [l10n] using the embedded JSON directory, early way out
I/GeckoDump( 3407): [l10n] library loaded.
I/GeckoDump( 3407): [l10n] loading [en-US] resources, asynchronously.
I/GeckoDump( 3407): [l10n] using the embedded JSON directory, early way out
I/GeckoDump( 3461): [l10n] library loaded.
I/GeckoDump( 3461): [l10n] loading [en-US] resources, asynchronously.
I/GeckoDump( 3461): [l10n] using the embedded JSON directory, early way out
I/GeckoDump( 3631): [l10n] library loaded.
I/GeckoDump( 3631): [l10n] loading [en-US] resources, asynchronously.
I/GeckoDump( 3631): [l10n] using the embedded JSON directory, early way out
I/GeckoDump( 3652): [l10n] library loaded.
I/GeckoDump( 3652): [l10n] loading [en-US] resources, asynchronously.
I/GeckoDump( 3652): [l10n] using the embedded JSON directory, early way out
I/GeckoDump( 3670): [l10n] library loaded.
I/GeckoDump( 3670): [l10n] loading [en-US] resources, asynchronously.
I/GeckoDump( 3670): [l10n] using the embedded JSON directory, early way out
I/GeckoDump( 3671): [l10n] library loaded.
I/GeckoDump( 3671): [l10n] loading [en-US] resources, asynchronously.
I/GeckoDump( 3671): [l10n] using the embedded JSON directory, early way out
I/GeckoDump( 3712): [l10n] library loaded.
I/GeckoDump( 3712): [l10n] loading [en-US] resources, asynchronously.
I/GeckoDump( 3712): [l10n] using the embedded JSON directory, early way out
I/GeckoDump( 3736): [l10n] library loaded.
I/GeckoDump( 3736): [l10n] loading [en-US] resources, asynchronously.
I/GeckoDump( 3736): [l10n] using the embedded JSON directory, early way out
I/GeckoDump( 3764): [l10n] library loaded.
I/GeckoDump( 3764): [l10n] loading [en-US] resources, asynchronously.
I/GeckoDump( 3764): [l10n] using the embedded JSON directory, early way out
I/GeckoDump( 3789): [l10n] library loaded.
I/GeckoDump( 3789): [l10n] loading [en-US] resources, asynchronously.
I/GeckoDump( 3789): [l10n] using the embedded JSON directory, early way out
I/GeckoDump( 3816): [l10n] library loaded.
I/GeckoDump( 3816): [l10n] loading [en-US] resources, asynchronously.
I/GeckoDump( 3816): [l10n] using the embedded JSON directory, early way out
I/GeckoDump( 3841): [l10n] library loaded.
I/GeckoDump( 3841): [l10n] loading [en-US] resources, asynchronously.
I/GeckoDump( 3841): [l10n] using the embedded JSON directory, early way out
I/GeckoDump( 3868): [l10n] library loaded.
I/GeckoDump( 3868): [l10n] loading [en-US] resources, asynchronously.
I/GeckoDump( 3868): [l10n] using the embedded JSON directory, early way out
I/GeckoDump( 3897): [l10n] library loaded.
I/GeckoDump( 3897): [l10n] loading [en-US] resources, asynchronously.
I/GeckoDump( 3897): [l10n] using the embedded JSON directory, early way out
I/GeckoDump( 3924): [l10n] library loaded.
I/GeckoDump( 3924): [l10n] loading [en-US] resources, asynchronously.
I/GeckoDump( 3924): [l10n] using the embedded JSON directory, early way out
I/GeckoDump( 3949): [l10n] library loaded.
I/GeckoDump( 3949): [l10n] loading [en-US] resources, asynchronously.
I/GeckoDump( 3949): [l10n] using the embedded JSON directory, early way out
I/GeckoDump( 3977): [l10n] library loaded.
I/GeckoDump( 3977): [l10n] loading [en-US] resources, asynchronously.
I/GeckoDump( 3977): [l10n] using the embedded JSON directory, early way out
I/GeckoDump( 4003): [l10n] library loaded.
I/GeckoDump( 4003): [l10n] loading [en-US] resources, asynchronously.
I/GeckoDump( 4003): [l10n] using the embedded JSON directory, early way out
I/GeckoDump( 4031): [l10n] library loaded.
I/GeckoDump( 4031): [l10n] loading [en-US] resources, asynchronously.
I/GeckoDump( 4031): [l10n] using the embedded JSON directory, early way out
I/GeckoDump( 4057): [l10n] library loaded.
I/GeckoDump( 4057): [l10n] loading [en-US] resources, asynchronously.
I/GeckoDump( 4057): [l10n] using the embedded JSON directory, early way out
I/GeckoDump( 4085): [l10n] library loaded.
I/GeckoDump( 4085): [l10n] loading [en-US] resources, asynchronously.
I/GeckoDump( 4085): [l10n] using the embedded JSON directory, early way out
I/GeckoDump( 4111): [l10n] library loaded.
I/GeckoDump( 4111): [l10n] loading [en-US] resources, asynchronously.
I/GeckoDump( 4111): [l10n] using the embedded JSON directory, early way out
I/GeckoDump( 4140): [l10n] library loaded.
I/GeckoDump( 4140): [l10n] loading [en-US] resources, asynchronously.
I/GeckoDump( 4140): [l10n] using the embedded JSON directory, early way out
I/GeckoDump( 4167): [l10n] library loaded.
I/GeckoDump( 4167): [l10n] loading [en-US] resources, asynchronously.
I/GeckoDump( 4167): [l10n] using the embedded JSON directory, early way out
I/GeckoDump( 4200): [l10n] library loaded.
I/GeckoDump( 4200): [l10n] loading [en-US] resources, asynchronously.
I/GeckoDump( 4200): [l10n] using the embedded JSON directory, early way out
I/GeckoDump( 4231): [l10n] library loaded.
I/GeckoDump( 4231): [l10n] loading [en-US] resources, asynchronously.
I/GeckoDump( 4231): [l10n] using the embedded JSON directory, early way out

When gallery shows black background, there is no 'library loaded' log.
I add some log for debug. I found 'fireL10nReadyEvent' has dispatch 'localized' event,  but gallery can't receive it.

I/GeckoDump( 5005): [l10n] loading [en-US] resources, asynchronously.
I/GeckoDump( 5005): [l10n] using the embedded JSON directory, early way out
I/GeckoDump( 5005): [l10n] function _callback() {
I/GeckoDump( 5005): [l10n] fireL10nReadyEvent
I/GeckoDump( 5026): [l10n] library loaded.
I/GeckoDump( 5026): [l10n] loading [en-US] resources, asynchronously.
I/GeckoDump( 5026): [l10n] using the embedded JSON directory, early way out
I/GeckoDump( 5026): [l10n] function _callback() {
I/GeckoDump( 5026): [l10n] fireL10nReadyEvent
I/GeckoDump( 5046): [l10n] library loaded.
I/GeckoDump( 5046): [l10n] loading [en-US] resources, asynchronously.
I/GeckoDump( 5046): [l10n] using the embedded JSON directory, early way out
I/GeckoDump( 5046): [l10n] function _callback() {
I/GeckoDump( 5046): [l10n] fireL10nReadyEvent
I/GeckoDump( 5051): [l10n] library loaded.
I/GeckoDump( 5051): [l10n] loading [en-US] resources, asynchronously.
I/GeckoDump( 5051): [l10n] using the embedded JSON directory, early way out
I/GeckoDump( 5051): [l10n] function _callback() {
I/GeckoDump( 5051): [l10n] fireL10nReadyEvent
we have confirmed the reason of this bug.

l10n.js was loaded prior to gallery.js when lunching the gallery app,
code in l10n.js was excuted earlier then code in gallery.js.

there is one case that code in l10n.js has been executed completely,
and function fireL10nReadyEvent was called, which fired an event 'localized'.

But code in gallery.js has not be executed yet, especially these code
window.addEventListener('localized', function showBody() {

so gallery.js would miss the 'localized' event and  be stucked.

Right now , we only exchanged the position of l10n.js and gallery.js in index.html of  gallery app.

But we think there should be a better way to fix this.
Summary: [unagi][l10n]Sometimes l10n.js did not fire 'localized' event when lunching an app, causing app being stucked → [unagi][l10n]Sometimes l10n.js fired 'localized' event earlier than the app executed window.addEventListener('localized'... , causing app being stuck
Comment on attachment 760793 [details]
Pointer to Github pull request: https://github.com/mozilla-b2g/gaia/pull/10314

Hi David,

This is a patch to resolve the race condition that localized event might occur before we do "addEventListener" to handle it.

If this case occurs, the app would not be initialized correctly.
Please help take a look.
Also ask for Kaze's feedback to see if this is the best practice.

--
After checking, I think this might be a general issue for each app that depends on "localized" event to do the initialization work.
Will send a mail to dev-gaia to raise the issue.
Attachment #760793 - Flags: review?(dflanagan)
Attachment #760793 - Flags: feedback?(kaze)
Hi David,

BTW, this patch also remove the following line,
https://github.com/mozilla-b2g/gaia/blob/da264667c5aa78f06aa0dda7a84b6c614a14c885/apps/gallery/js/gallery.js#L108 

This was to resolve Bug 826394, though I cannot see why they are related.
I have done some tests and did not see any regression.

Thank you.
Update: just ping :kaze on this. He will see what he could do about this bug.
This issue is probably related to bug 879188, I will set dependency first and needinfo Paul to see if this patch also fixes bug 879188.
Blocks: 879188
(In reply to Rudy Lu [:rudyl] from comment #7)
> Also ask for Kaze's feedback to see if this is the best practice.

I confirm: using mozL10n.ready() is safer than waiting for a `localized' event that might have been sent before the listener starts.

> After checking, I think this might be a general issue for each app that
> depends on "localized" event to do the initialization work.
> Will send a mail to dev-gaia to raise the issue.

Thanks for starting the discussion! I’ve just opened bug 882592 for that, and I agree it should be addressed quickly.
Attachment #760793 - Flags: feedback?(kaze) → feedback+
Rudy,

Sorry that I haven't reviewed this yet.  I'll look at it tomorrow.
Thanks for figuring this out, ying.xu!
Assignee: nobody → rlu
blocking-b2g: --- → leo?
Comment on attachment 760793 [details]
Pointer to Github pull request: https://github.com/mozilla-b2g/gaia/pull/10314

A one-line patch to fix a serious bug!  It looks good to me, and I've nominated the bug as a blocker because I think we should uplift this fix (and something similar for every app that uses the localized event).

r=djf for github commit 5b7f73c
Attachment #760793 - Flags: review?(dflanagan) → review+
Fixed on master: https://github.com/mozilla-b2g/gaia/commit/0e84ea18b9c161a08d39c39740ff2aa0f094d606
Status: UNCONFIRMED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
blocking-b2g: leo? → leo+
Uplifted 0e84ea18b9c161a08d39c39740ff2aa0f094d606 to:
v1-train: e23b58e0f1d8abb829a1092dddbd3057bddf9792
1.1hd: e23b58e0f1d8abb829a1092dddbd3057bddf9792
The issue still reproduce on Leo device.
Steps to repro:
1) Open Gallery app from the home screen
2) Tap the "home" button to return to the home screen 
3) Open any app like "FM Radio" app
4) Go to the "Card View"

Actual Result:
The Gallery app is black in the "Card view"

Expected:
All applications are visible in the "Card View"
 
Environmental  Variables:
Build ID: 20130724070208
Gecko: http://hg.mozilla.org/releases/mozilla-b2g18/rev/91fa9bf5e638
Gaia: a64f37c3327e4cf2105a16eedaf68727bb2adbde
Platform Version: 18.1
I think what you described is another issue about Card View while the original one is about app launch.

Could you please help open another bug if Comment 18 is still reproducible?
Thanks.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: