[B2G][Helix][camera][dingyu]Start the video recording failed

RESOLVED WORKSFORME

Status

Firefox OS
Gaia::Camera
P3
normal
RESOLVED WORKSFORME
5 years ago
4 years ago

People

(Reporter: lecky, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

5 years ago
User Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.112 Safari/535.1

Steps to reproduce:

1. open the camera and toggle to video mode
2. press the caputre button to start a video recording 
3. press the home key to make the camera work in background 
4. press the camera button and go back to the camera 
5. repeat 2 ~ 4 quickly



Actual results:

a dialog box show that "Video not recorded, An error prevented Camera from recording the video"


Expected results:

start recording successfully
(Reporter)

Comment 1

5 years ago
According to the log:
nsresult mozilla::nsGonkCameraControl::SetupRecording(int, int, int64_t, int64_t):1320 : mCameraHw is null
It means the mCameraHw is null, so the api startRecording return false and the dialog box appeared.

Compare the normal log and abnormal log I find that:
mCameraHw is define in GonkCameraControl.cpp L239: mCameraHw = GonkCameraHardware::Connect(this, mCameraId);(I am not sure of that)
According to the log, when the issue happens, the time of define "mCameraHw" is after than the judgment RETURN_IF_NO_CAMERA_HW in function "nsGonkCameraControl::SetupRecording"(in GonkCameraControl.cpp).

I try to find the original location to call "mCameraHw = GonkCameraHardware::Connect" and "nsGonkCameraControl::SetupRecording". But I am sorry I only find that:
"mCameraHw = GonkCameraHardware::Connect" is from "nsDOMCameraManager::GetCamera()" (in DomCameraManger.cpp)
"nsGonkCameraControl::SetupRecording" is from "nsDOMCameraControl::StartRecording"(in DomCameraControl.cpp)

So in my opinion, the reason is as follow: when I open the camera, nsDOMCameraManager::GetCamera will go and the mCameraHw  will be defined. Because of my pressing the capture button so quickly that at the time "RETURN_IF_NO_CAMERA_HW " to check the mCameraHw, actually the "mCameaHw" have not be defined.
(Reporter)

Updated

5 years ago
blocking-b2g: --- → hd?
Flags: needinfo?(wchang)
Priority: -- → P2
(Reporter)

Comment 2

5 years ago
I think in camera.js we set some time delay befor we call the api "startRecording". it maybe helpful.
Not blocking HD.

Vincent, can you check this and nominate for koi if you think the fix is worth it?
blocking-b2g: hd? → ---
Flags: needinfo?(wchang) → needinfo?(vliu)
(In reply to lecky from comment #1)
> 
> Compare the normal log and abnormal log I find that:
> mCameraHw is define in GonkCameraControl.cpp L239: mCameraHw =
> GonkCameraHardware::Connect(this, mCameraId);(I am not sure of that)

This function get camera hw ownership from CameraService in android mediaserver. If this function failed, the problem happens in CameraService side.
(In reply to lecky from comment #2)
> I think in camera.js we set some time delay befor we call the api
> "startRecording". it maybe helpful.

I do not think it is a good idea without analyzing the actual cause of the problem.
I think the solution is that the 'visibilitychange' event handler[1] needs to call disableButtons() to make sure we can't tap on the start-recording button until the preview has restarted.

1. https://github.com/mozilla-b2g/gaia/blob/master/apps/camera/js/camera.js#L1540
Created attachment 825356 [details] [diff] [review]
WIP - disable camera buttons when it goes into the background, v1

lecky, can you try out this patch?
Attachment #825356 - Flags: feedback?(lecky.wanglei)
Flags: needinfo?(lecky.wanglei)
Duplicate of this bug: 928856

Updated

5 years ago
Flags: needinfo?(vliu)
(Reporter)

Comment 9

5 years ago
(In reply to Sotaro Ikeda [:sotaro] from comment #4)

> This function get camera hw ownership from CameraService in android
> mediaserver. If this function failed, the problem happens in CameraService
> side.
In my opinion, the function get camera hw ownership doesn't failed. Because I use continuous auto focus in preview, so If i open the camera then press the capture button quickly, the api "startRecording" is running quickly. In my thought, the reason of the problem is that when I open the camera the function "navigator.mozCameras.getCamera" will call to define mCameraHw, before the mCameraHw is defined, "RETURN_IF_NO_CAMERA_HW " is called. 
  I think Camera.disableButtons(); add after https://github.com/mozilla-b2g/gaia/blob/master/apps/camera/js/camera.js#L1540 will more better? do you think so?
Flags: needinfo?(lecky.wanglei)
lecky, have you tried the above patch (or your suggestion in comment 9)?
Flags: needinfo?(lecky.wanglei)
(Reporter)

Comment 11

5 years ago
(In reply to Mike Habicher [:mikeh] from comment #10)
> lecky, have you tried the above patch (or your suggestion in comment 9)?

Mike I have try the patch, the probability become small, but the problem is still exist.But if I merge the patch, when it failed, the log is not the same as previous.
Flags: needinfo?(lecky.wanglei)
(Reporter)

Updated

5 years ago
Priority: P2 → P3
This does not reproduce anymore:

Gaia      6a1373340b40fcfe901336bc9e80676e5f2ba979
Gecko     https://hg.mozilla.org/releases/mozilla-aurora/rev/82ef9bf64d87
BuildID   20140626000202
Version   32.0a2

Please reopen if you're able to reproduce.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.