Closed Bug 1074597 Opened 5 years ago Closed 2 years ago

[MTP][KK] Gallery/Video/Music app does not sync changes from PC immediately

Categories

(Firefox OS Graveyard :: Gaia, defect)

ARM
Gonk (Firefox OS)
defect
Not set

Tracking

(blocking-b2g:-)

RESOLVED WONTFIX
blocking-b2g -

People

(Reporter: ashiue, Unassigned, NeedInfo)

Details

Gaia-Rev        13973ab50760d1e8bb773082163f0dff19d35a44
Gecko-Rev       https://hg.mozilla.org/releases/mozilla-aurora/rev/6e317e075d04
Build-ID        20140928160204
Version         34.0a2

STR:
1. Some images at internal storage
2. USB plugged in and enable MTP
3. Launch gallery app (exist some images)
4. PC delete an image at internal storage
5. Check the gallery app 

Expect result:
1. The image which is deleted by PC should not show on gallery list

Actual result:
1. The image which is deleted by PC should still show on gallery list
[Blocking Requested - why for this release]:
Device could not show those deleted files correctly but user still can try to open these files.
blocking-b2g: --- → 2.1?
QA Whiteboard: [COM=Storage]
We can get the same symptom when using "adb shell" to delete some files.
So I think this should be related to the behavior of app.
Maybe app should watch file change event for immediate reaction.


@gaia/shared/js/mediadb.js

function setupHandlers() { 
	// Now that we know the state of all of the storage areas, register
	// an event listener to monitor changes to that state.
	for (var i = 0; i < details.storages.length; i++) {
	  details.storages[i].addEventListener('change', changeHandler);
	}
}

function changeHandler(e) {
	switch (e.reason) {
		case 'modified', 'deleted' :
			fileChangeHandler(e);
			return;
		case 'available', 'unavailable', 'shared' :
			volumeChangeHandler(e);
			return;
	}
}
The media apps(or mediadb) do not handle the MTP cases for now because MTP was recently enabled in 2.1. I assuming MTP should fires the similar/same events as UMS, if so, then we don't have to anything then it should works magically, but I guess it's not so that's why this issue happens.

Dave, would you please describe what should the media apps do for MTP? thanks.
Flags: needinfo?(dhylands)
In my opinion, MTP just do file operation.
So media apps don't need to do any specific behavior just for MTP.
Otherwise, if we would like to react immediately, we need to monitor file change event if possible.
http://dxr.mozilla.org/mozilla-central/source/dom/system/gonk/MozMtpDatabase.cpp#200
Mtp will notify observer ("file-watcher-notify") when there is file operation.
Event : created/modified/deleted

There is same behavior in bluetooth.
http://dxr.mozilla.org/mozilla-central/source/dom/bluetooth/bluedroid/BluetoothOppManager.cpp#1332
(In reply to Dominic Kuo [:dkuo] from comment #3)
> The media apps(or mediadb) do not handle the MTP cases for now because MTP
> was recently enabled in 2.1. I assuming MTP should fires the similar/same
> events as UMS, if so, then we don't have to anything then it should works
> magically, but I guess it's not so that's why this issue happens.
> 
> Dave, would you please describe what should the media apps do for MTP?
> thanks.

The media apps shouldn't have to do anything for MTP.

MTP connects into the same reporting mechanism that Device Storage uses, and MTP gets notified of changes made to device storage and device storage gets notified of changes made via MTP.

I ran ds-test and issued the "Add Listener" for the pictures type.

Then I took a couple photos using the camera app, and saw created & modified events for each picture.
From the command line, under linux, I then did:

rm /var/run/user/35029/gvfs/mtp\:host\=%5Busb%3A003%2C076%5D/sdcard/DCIM/100MZLLA/IMG_0001.jpg

and instantly saw the deleted file notification in ds-test.

It's possible that MTP is doing things differently from different hosts, so it would be useful to perform the same experiment (using ds-test to report notifications) and see if its receiving the notification when you remove the file using the host.
Flags: needinfo?(dhylands)
Note that device storage does NOT detect files added/modified/deleted through adb shell.
Adding qawanted for branch checks.
Keywords: qawanted
QA Whiteboard: [COM=Storage] → [COM=MTP/UMS]
Component: General → MTP/UMS
It's a new feature for media app. We need UX to define the behavior of media apps(Gallery, Music, Video), e.g. when music is playing and the file is deleted from PC side, what would happen on the music app? A warning message, pause or jump to the next song...etc. We need to file separate bugs for each app.

Hi Rob, can you help to find the right person for this? Thanks.
blocking-b2g: 2.1? → -
feature-b2g: --- → 2.2?
Flags: needinfo?(rmacdonald)
Keywords: qawanted
Thanks to Alphan and Dave, and I also used the way how Dave tested in comment 6, with Ubuntu 14.04 and my flame while it connected in MTP mode, I tried to add/remove some mp3 files but I didn't get created & modified events, I don't know the result on windows but if different hosts could have different results, then it would be better to define some ux flows to prevent these cases, let's also flag Katie and Jacqueline to help on it since they are the media ux people.

Katie and Jacqueline, would you please give some inputs on this? thanks.
Flags: needinfo?(kcaldwell)
Flags: needinfo?(jsavory)
Katie should be able to look at this next week. Thanks!
Flags: needinfo?(rmacdonald)
Flags: needinfo?(jsavory)
I think that this bug is a duplicate of bug 1072535 (which landed yesterday).

With a build containing the fix for bug 1072535, I mounted my phone via MTP, and brought up gallery. Then on the PC I browsed to one of the photos and deleted it on the PC. Within a couple of seconds, the thumbnail disappeared from the gallery.
(In reply to howie [:howie] from comment #9)
> It's a new feature for media app. We need UX to define the behavior of media
> apps(Gallery, Music, Video), e.g. when music is playing and the file is
> deleted from PC side, what would happen on the music app? A warning message,
> pause or jump to the next song...etc. We need to file separate bugs for each
> app.

Hi all - thanks for your patience on this.

MTP Mode 
If I understand correctly how this mode works - as a user, I can enable USB Storage using MTP, and continue to have access (via my phone and unlike UMS mode) to media apps : Gallery, Camera, Video and Music. 

If that is correct, the expected behaviour is to have the apps immediately sync updates (add/delete actions) from the PC to reflect the users actions (as the bug title says). 

UX Recommendation: 
As a general rule: Since MTP mode allows continued access to the device apps while connected to a user's PC via USB, in all cases, the apps are expected to behave as they currently do. If there is a confirmation banner, a loading banner/notification, etc based on a user action (add/delete media), the same experience should continue, the phone should not behave differently. 

If the Music app is open on the phone, and... 
• music is playing and the user chooses to delete the song (or album) via MTP on their PC, the user would complete the delete activity (confirm deletion), the song would be removed from storage / stop playing, and the user would be redirected to the next song in the playlist, or back to the previous screen. If the user is in an Artist view and the deleted song happens the last song, they should be returned to the artist page 
• the user adds music via MTP to their device from their PC, songs are immediately added to app (Currently in the Music app, a banner with a loading icon appears at the top of the screen and it runs through the files it's adding, this same behaviour would be expected here) 
• the user deletes 1 or more songs via MTP on their PC, immediately delete songs from storage (update song list and/or artist and album list) 

If the Camera app is open on the phone, and... 
• the user takes pictures (or video), the new images should immediately appear to the user on their PC. 
• and in Preview Image, the user chooses to delete the image via MTP on their PC, image(s) would be removed immediately from storage, and the user is redirected to the next image in the camera roll. If no images remain, redirects to active Camera. 

If the Gallery app is open on the phone, and... 
• the user deletes a photo (or group of photos) via MTP mode, photos would be removed immediately from Gallery (and preview roll in Camera). If this takes time (not instant), show progress bar to show action is being taken. Redirect user to next image in the roll, if no images remain, show message to user (should behave as spec'd for empty Gallery / FTE) 
• it's in Main view, and the user adds images via MTP on their PC, immediately add images to Gallery view (appropriately based on timestamp/meta-data of image files). If there are numerous images, this may take time, show progress/loading bar. 

If the Video app is open on the phone, and... 
• the user has a video playing and chooses to delete the video via MTP on their PC, user completes delete activity (confirm deletion), video is removed from storage / stops playing, user is redirected to Main Video view/list. 
• the user takes video, the new video files should immediately appear to the user on their PC. 
• it's in List view, and the user adds video files via MTP on their PC, immediately update list to reflect new additions. If this isn't instant, show progress/loading bar to show action is being taken. 
• it's in List view, and the user deletes video files via MTP on their PC, immediately update list to reflect removal of files. If this isn't instant, show progress/loading bar to show action is being taken. 

Please let us know if we've missed any scenarios... hope this helps!
Flags: needinfo?(kcaldwell)
feature-b2g: 2.2? → ---
Since this bug can be resolved by adding a listener for file modified event in media apps, I modified the component to gaia.
Component: MTP/UMS → Gaia
Hi David and Dominic,
This bug is talking about media app cannot refresh the file list immediately when MTP in use.
From comment 13, Katie have pointed out the scenarios those app may meet when MTP in use.
Could you take a look and give some feedback?
Flags: needinfo?(dkuo)
Flags: needinfo?(dflanagan)
(In reply to Alphan Chen[:Alphan] from comment #15)
> Hi David and Dominic,
> This bug is talking about media app cannot refresh the file list immediately
> when MTP in use.
> From comment 13, Katie have pointed out the scenarios those app may meet
> when MTP in use.
> Could you take a look and give some feedback?

Hey Alphan, thanks for recapping this MTP issue and I think base on Katie's description in comment 13, the media apps should interact with those MTP operations if users do some file actions from the pc, I am sure currently most of the media apps do not handle these scenarios, which means these will be new features for the media apps if we want to complete the MTP user stories.

I am not sure if those MTP user stories are still the 2.2 targets so should we ask the product manager to clarify? maybe Bruce?
Flags: needinfo?(dkuo)
Flags: needinfo?(dflanagan)
Flags: needinfo?(bhuang)
Firefox OS is not being worked on
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.