Last Comment Bug 777259 - Device Storage returning null object
: Device Storage returning null object
Status: VERIFIED FIXED
:
Product: Core
Classification: Components
Component: DOM: Device Interfaces (show other bugs)
: unspecified
: x86 Mac OS X
: -- normal (vote)
: mozilla17
Assigned To: Dave Hylands [:dhylands]
:
Mentors:
: 777921 781004 (view as bug list)
Depends on: 751951
Blocks: 761936
  Show dependency treegraph
 
Reported: 2012-07-25 00:54 PDT by dclarke@mozilla.com [:onecyrenus]
Modified: 2012-08-29 14:42 PDT (History)
9 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---
+


Attachments
Bug 777259 - Launch VolumeService earlier to prevent races on retrieving Volume information (7.83 KB, patch)
2012-08-08 15:48 PDT, Dave Hylands [:dhylands]
dougt: review+
Details | Diff | Review

Description dclarke@mozilla.com [:onecyrenus] 2012-07-25 00:54:36 PDT
Environment: 

otoro- 7/24/2012 build 
gaia app - Music

Device Storage is returning null.  

The repro case is to load audio in /sdcard/Music, and then start the Music app


E/GeckoConsole(  106): Content JS ERROR at app://music.thisdomaindoesnotexist.org/js/MediaDB.js:197 in MediaDB: MediaDB(): can't get DeviceStorage object TypeError: navigator.getDeviceStorage(mediaType) is null

This might also not be a device storage error as much as a permsissions error, unsure, but i verified the permissions to device storage are correct in permissions.sqlite


173|music.thisdomaindoesnotexist.org|indexedDB-unlimited|1|0|0
174|music.thisdomaindoesnotexist.org|webapps-manage|1|0|0
175|music.thisdomaindoesnotexist.org|offline-app|1|0|0
176|music.thisdomaindoesnotexist.org|pin-app|1|0|0
177|music.thisdomaindoesnotexist.org|websettings-read|1|0|0
178|music.thisdomaindoesnotexist.org|websettings-readwrite|1|0|0
179|music.thisdomaindoesnotexist.org|content-camera|1|0|0
180|music.thisdomaindoesnotexist.org|webcontacts-manage|1|0|0
181|music.thisdomaindoesnotexist.org|wifi-manage|1|0|0
182|music.thisdomaindoesnotexist.org|desktop-notification|1|0|0
183|music.thisdomaindoesnotexist.org|geolocation|1|0|0
184|music.thisdomaindoesnotexist.org|device-storage|1|0|0
185|music.thisdomaindoesnotexist.org|alarms|1|0|0
Comment 1 dclarke@mozilla.com [:onecyrenus] 2012-07-25 01:00:55 PDT
Verified this is happening with Video App as well, and a similar error is being returned.
Comment 2 dclarke@mozilla.com [:onecyrenus] 2012-07-25 05:51:56 PDT
logcat output: 

I/Vold    (  100): /dev/block/vold/179:1 being considered for volume sdcard
D/Vold    (  100): Volume sdcard state changing 1 (Idle-Unmounted) -> 3 (Checking)
W/SocketClient(  100): write error (Broken pipe)
W/SocketClient(  100): Unable to send msg '605 Volume sdcard /mnt/sdcard state changed from 1 (Idle-Unmounted) to 3 (Checking)'
W/SocketListener(  100): Error sending broadcast (Broken pipe)
Comment 3 Doug Turner (:dougt) 2012-07-25 09:54:30 PDT
dclarke, does your device have a sdcard installed?  If not, then everything is working as expected.
Comment 4 dclarke@mozilla.com [:onecyrenus] 2012-07-26 15:26:30 PDT
Yes it does.  I can adb shell cd /sdcard/Music 
ls -al shows many files
Comment 5 dclarke@mozilla.com [:onecyrenus] 2012-07-26 17:35:45 PDT
Doug are you running the latest otoro build from releases.mozilla ? 


Taht would be a good place to start.
Comment 6 dclarke@mozilla.com [:onecyrenus] 2012-07-26 17:36:04 PDT
Doug are you running the latest otoro build from releases.mozilla ? 


that would be a good place to start.
Comment 7 dclarke@mozilla.com [:onecyrenus] 2012-07-27 15:26:05 PDT
*** Bug 777921 has been marked as a duplicate of this bug. ***
Comment 8 Doug Turner (:dougt) 2012-08-08 11:19:44 PDT
if the volume manager says that the sdcard isn't present, we return a null storage object for all types (video, pictures, music)
Comment 9 Dave Hylands [:dhylands] 2012-08-08 11:43:54 PDT
I figured out the problem.

The nsVolumeService class doesn't get instantiated until the very first time that:

do_GetService(NS_VOLUMESERVICE_CONTRACTID)

is called. The nsVolumeService constructor then fires off some IOTHread initialization. If the call to GetVolumeByPath comes in before the iothread has had a chance to finish, then it see no volume.

So I see a few potential solutions:

1 - Have the VolumeManager do a call to do_GetService to have the nsVolumeService instantiated earlier.
2 - Have the nsVolumeService do some type of synchronization so that GetVolumeByPath blocks until the iothread is finished
3 - Move the main thread data out of nsVolumeService and have the main thread data initialized earlier, so that nsVolumeService can access it immediately.

I'm inclined to do #3. Comments?
Comment 10 Doug Turner (:dougt) 2012-08-08 11:46:27 PDT
4 - You could just add the volume service to app-startup.  This would create your service on startup and you don't have to do anything else.

Not sure about the impact on startup perf though.
Comment 11 Dave Hylands [:dhylands] 2012-08-08 15:48:10 PDT
Created attachment 650347 [details] [diff] [review]
Bug 777259 - Launch VolumeService earlier to prevent races on retrieving Volume information
Comment 12 Doug Turner (:dougt) 2012-08-09 12:52:24 PDT
Comment on attachment 650347 [details] [diff] [review]
Bug 777259 - Launch VolumeService earlier to prevent races on retrieving Volume information

works great.
Comment 13 dclarke@mozilla.com [:onecyrenus] 2012-08-09 17:36:21 PDT
Let us know when this makes it into the tree
Comment 14 Dave Hylands [:dhylands] 2012-08-09 20:48:52 PDT
I pushed it to mozilla-inbound: 
https://hg.mozilla.org/integration/mozilla-inbound/rev/4a08177931d2

As long as no build failures occur, it should be on mozilla-central tomorrow morning.
Comment 15 Ed Morley [:emorley] 2012-08-10 01:57:04 PDT
https://hg.mozilla.org/mozilla-central/rev/4a08177931d2
Comment 16 dclarke@mozilla.com [:onecyrenus] 2012-08-13 16:44:42 PDT
*** Bug 781004 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.