Greetings,

I started work on application which is supposed to synchronize data stored on 
OS X Computers and Firefox OS Device. It's based on simple architecture, user 
will install client on his mac and then he access the data from device using 
http api. 

So far application can be used to download contacts from AddressBook to Firefox 
OS Contacts and I implemented functionality to download music albums from 
iTunes, but there are several issues.

My download process works in following way:

1. Download list of tracks from server
2. Sort them to Albums (later I would like to add view by interprets or by 
genre etc.)
3. Download the album covers into Object
4. Draw download screen

--- When user choose albums to download and clicks to import button

5. Create the list of tracks to download
6 One after one download the media files, saving them to blob and then adding 
to storage
7. When all files are downloaded, show msg to user

Unfortunately, I encountered two big problems:

First, it  seems that downloading file with mime audio/mp4 is breaking, mime is 
not assigned correctly and file is not saved (I fixed that by using audio/mpeg, 
but...)

Second, and much more important...  first and maybe second downloaded tracks 
are ok, but then the save process fails. I am fetch the data from server,I 
construct the blob, but I can't save it to storage. It seems to me that when 
onsuccess callback of navigator.getDeviceStorage('music').add is called, the 
storage is not ready for another file.

Solution for this problem is to add timeout before downloading next track, this 
way I was able to download and store like 50 music files in a row without 
error. But this works only in Simulator. On device I download first files, 
maybe few more, but then application quits without any message.

Or course, I was suspicious about memory issues and I worked on optimization. 
The memory consumption of B2G simulator improved a lot, but still have same 
problem on device.

Please check the code at: 
https://raw.github.com/DarkenBLN/fxos-osx-sync-tool/master/fxos-client/js/media.js

Download is implemented by loop calling of new App.MusicTrackDownload until 
there are tracks to download.

Device: Open ZTE with updated Gecko and Gaia to 1.1.0 (I also tried on official 
1.0.1. build)

Thank you for any help

Michael

Device log:


I/IdleService(  113): SetTimerExpiryIfBefore: next timeout 1000 msec from now
I/IdleService(  113): reset timer expiry to 1010 msec from now
I/IdleService(  113): Reset idle timeout: tell observer 490f97c0 user is back
D/memalloc(  113): /dev/pmem: Allocated buffer base:0x4d200000 size:614400 
offset:4628480 fd:115
I/Adreno200-EGLSUB(  113): <CreateImage:991>: Android Image
I/Adreno200-EGLSUB(  113): <GetImageAttributes:1200>: RGBA_8888
I/GeckoDump(  113): XXX FIXME : Got a mozContentEvent: permission-allow
D/memalloc(  113): /dev/pmem: Freeing buffer base:0x4d570000 size:614400 
offset:3604480 fd:97
D/memalloc(  113): /dev/pmem: Freeing buffer base:0x4d66a000 size:614400 
offset:4628480 fd:115
E/GeckoConsole( 4033): Content JS LOG at 
app://d547d135-e3bc-074b-b147-8f4d1ebeaf01/js/media.js:131 in anonymous: 
download music tracks called
E/GeckoConsole( 4033): Content JS LOG at 
app://d547d135-e3bc-074b-b147-8f4d1ebeaf01/js/media.js:154 in anonymous: track 
: CAFF9C0873B948F7
D/memalloc(  113): /dev/pmem: Allocated buffer base:0x4d200000 size:614400 
offset:3604480 fd:115
D/memalloc( 4033): /dev/pmem: Mapped buffer base:0x45529000 size:4218880 
offset:3604480 fd:62
D/memalloc(  113): /dev/pmem: Allocated buffer base:0x4d200000 size:8192 
offset:1228800 fd:127
D/memalloc( 4033): /dev/pmem: Mapped buffer base:0x45ca6000 size:1236992 
offset:1228800 fd:71
I/Adreno200-EGLSUB(  113): <CreateImage:991>: Android Image
I/Adreno200-EGLSUB(  113): <GetImageAttributes:1200>: RGBA_8888
I/Adreno200-EGLSUB(  113): <CreateImage:991>: Android Image
I/Adreno200-EGLSUB(  113): <GetImageAttributes:1200>: RGBA_8888
D/memalloc( 4033): /dev/pmem: Unmapping buffer base:0x45936000 size:3604480 
offset:3522560
D/memalloc(  113): /dev/pmem: Freeing buffer base:0x4d55c000 size:81920 
offset:3522560 fd:152
D/memalloc(  113): /dev/pmem: Freeing buffer base:0x4d462000 size:81920 
offset:2498560 fd:140
D/memalloc(  113): /dev/pmem: Allocated buffer base:0x4d200000 size:614400 
offset:4628480 fd:140
D/memalloc( 4033): /dev/pmem: Mapped buffer base:0x46b6a000 size:5242880 
offset:4628480 fd:65
D/memalloc(  113): /dev/pmem: Allocated buffer base:0x4d200000 size:8192 
offset:2498560 fd:151
D/memalloc( 4033): /dev/pmem: Mapped buffer base:0x4592f000 size:2506752 
offset:2498560 fd:74
I/Adreno200-EGLSUB(  113): <CreateImage:991>: Android Image
I/Adreno200-EGLSUB(  113): <GetImageAttributes:1200>: RGBA_8888
D/memalloc( 4033): /dev/pmem: Unmapping buffer base:0x44fac000 size:2580480 
offset:2498560
I/IdleService(  113): Get idle time: time since reset 824 msec
I/IdleService(  113): Idle timer callback: current idle time 824 msec
I/IdleService(  113): next timeout 174 msec from now
I/IdleService(  113): SetTimerExpiryIfBefore: next timeout 174 msec from now
I/IdleService(  113): reset timer expiry to 184 msec from now
I/IdleService(  113): Get idle time: time since reset 1008 msec
I/IdleService(  113): Idle timer callback: current idle time 1008 msec
I/IdleService(  113): next timeout 4294967293991 msec from now
I/IdleService(  113): SetTimerExpiryIfBefore: next timeout 4294967293991 msec 
from now
I/IdleService(  113): reset timer expiry to 4294967294001 msec from now
I/IdleService(  113): Idle timer callback: tell observer 490f97c0 user is idle
I/IdleService(  113): Get idle time: time since reset 1009 msec
E/WifiHW  (  113): 'SIGNAL_POLL'
I/Adreno200-EGLSUB(  113): <CreateImage:991>: Android Image
I/Adreno200-EGLSUB(  113): <GetImageAttributes:1256>: RGBX_8888
I/Gecko   (  113):
I/Gecko   (  113): ###!!! [Parent][AsyncChannel] Error: Channel error: cannot 
send/recv
I/Gecko   (  113):
I/Gecko   (  113):
I/Gecko   (  113): ###!!! [Parent][AsyncChannel] Error: Channel error: cannot 
send/recv
I/Gecko   (  113):
E/GeckoConsole( 4033): Content JS LOG at 
app://d547d135-e3bc-074b-b147-8f4d1ebeaf01/js/media.js:165 in anonymous: Music 
track download process finished audio/mpeg
I/Gecko   (  113):
I/Gecko   (  113): ###!!! [Parent][AsyncChannel] Error: Channel error: cannot 
send/recv
I/Gecko   (  113):
I/Gecko   (  113):
I/Gecko   (  113): ###!!! [Parent][AsyncChannel] Error: Channel error: cannot 
send/recv
I/Gecko   (  113):
I/Gonk    (  113): Setting nice for pid 3604 to 1
I/Gonk    (  113): Changed nice for pid 3604 from 18 to 1.
D/memalloc(  113): /dev/pmem: Freeing buffer base:0x4d570000 size:614400 
offset:3604480 fd:115
D/memalloc(  113): /dev/pmem: Freeing buffer base:0x4d462000 size:8192 
offset:2498560 fd:151
D/memalloc(  113): /dev/pmem: Freeing buffer base:0x4d3fe000 size:409600 
offset:2088960 fd:122
D/memalloc(  113): /dev/pmem: Freeing buffer base:0x4d476000 size:532480 
offset:2580480 fd:144
D/memalloc(  113): /dev/pmem: Freeing buffer base:0x4d37c000 size:532480 
offset:1556480 fd:128
D/memalloc(  113): /dev/pmem: Freeing buffer base:0x4d606000 size:409600 
offset:4218880 fd:138
D/memalloc(  113): /dev/pmem: Freeing buffer base:0x4d66a000 size:614400 
offset:4628480 fd:140
D/memalloc(  113): /dev/pmem: Freeing buffer base:0x4d32c000 size:8192 
offset:1228800 fd:127
I/Gecko   (  113):
I/Gecko   (  113): ###!!! [Parent][AsyncChannel] Error: Channel error: cannot 
send/recv
I/Gecko   (  113):
D/memalloc(  113): /dev/pmem: Allocated buffer base:0x4d200000 size:614400 
offset:1228800 fd:74
D/memalloc( 3604): /dev/pmem: Mapped buffer base:0x44800000 size:1843200 
offset:1228800 fd:33
D/memalloc(  113): /dev/pmem: Allocated buffer base:0x4d200000 size:8192 
offset:1843200 fd:97
D/memalloc( 3604): /dev/pmem: Mapped buffer base:0x44a09000 size:1851392 
offset:1843200 fd:36
D/memalloc(  113): /dev/pmem: Allocated buffer base:0x4d200000 size:532480 
offset:1851392 fd:114
D/memalloc( 3604): /dev/pmem: Mapped buffer base:0x44be5000 size:2383872 
offset:1851392 fd:39
D/memalloc(  113): /dev/pmem: Allocated buffer base:0x4d200000 size:16384 
offset:2383872 fd:119
D/memalloc( 3604): /dev/pmem: Mapped buffer base:0x44ed3000 size:2400256 
offset:2383872 fd:42
D/memalloc(  113): /dev/pmem: Allocated buffer base:0x4d200000 size:614400 
offset:2400256 fd:122
D/memalloc(  113): /dev/pmem: Allocated buffer base:0x4d200000 size:122880 
offset:3014656 fd:129
D/memalloc( 3604): /dev/pmem: Mapped buffer base:0x4519a000 size:3137536 
offset:3014656 fd:45
I/Adreno200-EGLSUB(  113): <CreateImage:991>: Android Image
I/Adreno200-EGLSUB(  113): <GetImageAttributes:1256>: RGBX_8888
I/Adreno200-EGLSUB(  113): <CreateImage:991>: Android Image
I/Adreno200-EGLSUB(  113): <GetImageAttributes:1256>: RGBX_8888
_______________________________________________
dev-b2g mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-b2g

Reply via email to