Closed Bug 1161175 Opened 5 years ago Closed 2 years ago

[B2G] Camera flash-enabled apps do not work

Categories

(Firefox OS Graveyard :: General, defect)

ARM
Gonk (Firefox OS)
defect
Not set

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: ychung, Assigned: adora)

References

()

Details

(Keywords: regression, Whiteboard: [3.0-Daily-Testing])

Attachments

(2 files)

Description:
Flashlight apps that use the hardware camera flash do not work properly. The flash does not turn on. This is not app-specific issue as at least 2 apps (MultiFlash, LED Flashlight) do not work properly.

Repro Steps:
1) Update a Flame to 20150504010202.
2) Open Marketplace.
3) Search and download "MultiFlash" app.
4) Open the downloaded app.
5) Select "Allow" on the App Permission screen.
6) Tap the on/off switch within the app.

Actual:
The hardware camera flash does not turn on.

Expected:
The hardware camera flash turns on.

Environmental Variables:
Device: Flame 3.0 (KK, 319mb, full flash)
Build ID: 20150504010202
Gaia: e18cce173840d6ff07fb6f1f0e0ffb58b99aab3e
Gecko: dc5f85980a82
Gonk: a9f3f8fb8b0844724de32426b7bcc4e6dc4fa2ed
Version: 40.0a1 (3.0)
Firmware Version: v18D-1
User Agent: Mozilla/5.0 (Mobile; rv:40.0) Gecko/40.0 Firefox/40.0

Repro frequency: 7/7
See attached: video clip, logcat
https://youtu.be/ASKJHWU5yrA
This issue also reproduces on Flame 2.2.

Result: Flashlight apps do not work.

Environmental Variables:
Device: Flame 2.2 (KK, 319mb, full flash)
Build ID: 20150504002502
Gaia: 8d14361337e608c8cdf165ea5034db5eda23b618
Gecko: cb7cb6597c91
Gonk: a9f3f8fb8b0844724de32426b7bcc4e6dc4fa2ed
Version: 37.0 (2.2)
Firmware Version: v18D-1
User Agent: Mozilla/5.0 (Mobile; rv:37.0) Gecko/37.0 Firefox/37.0

====================
This issue does not reproduce on Flame 2.1.

Result: Flashlight apps function properly.

Environmental Variables:
Device: Flame 2.1 (KK, 319mb, full flash)
Build ID: 20150504001200
Gaia: b4a03b7ee61de5a479b3cf0916f47e91a43b0f50
Gecko: 03bfe12e50d0
Gonk: a9f3f8fb8b0844724de32426b7bcc4e6dc4fa2ed
Version: 34.0 (2.1)
Firmware Version: v18D-1
User Agent: Mozilla/5.0 (Mobile; rv:34.0) Gecko/34.0 Firefox/34.0
QA Whiteboard: [QAnalyst-Triage?]
Flags: needinfo?(ktucker)
No-Jun, can you take a look at this please?
QA Whiteboard: [QAnalyst-Triage?] → [QAnalyst-Triage+]
Flags: needinfo?(ktucker) → needinfo?(npark)
Hmm, not sure how to treat 3rd party app breakage. Hema, what do we normally do with these issues?
Flags: needinfo?(npark) → needinfo?(hkoka)
Pinging Adora in App Review.

@Adora -  Would you mind taking a look at these claims?
Assignee: mellis → adora
Flags: needinfo?(adora)
Results of my testing:

2.2
Multiflash - Does not work 
LED Flashlight - Does not work

2.1
Multiflash- Does not work
LED Flashlight - Works well

2.0 
Multiflash - Works well 
LED Flashlight - Works well
Status: NEW → ASSIGNED
(In reply to No-Jun Park [:njpark] from comment #3)
> Hmm, not sure how to treat 3rd party app breakage. Hema, what do we normally
> do with these issues?

No-jun, Marketplace team usually takes a first look at 3rd party app related issues.
Flags: needinfo?(hkoka)
@ Harald, could this be an issue with b2g we may need to take a look at before devices hit market?
Flags: needinfo?(hkirschner)
This might be a regression in platform; at least an API change on our side.

ni? hema to ni? somebody that worked on the Camera API.
Flags: needinfo?(hkoka)
Flags: needinfo?(hkirschner)
Flags: needinfo?(adora)
Andrew: Can you check on this and comment?

Thanks
Hema
Flags: needinfo?(hkoka) → needinfo?(aosmond)
Hey guys

I really need a solution for this. There are devices coming out with Flashlight app preloaded and I need a solution whether the problem is the API or not

Please, I urge you to provide me some information asap

Thanks in advance
The API for mozCamera changed in 2.2 from callbacks to promises. While initially we supported both during the transition, bug 1107683 stripped out support for callbacks. This is what is breaking the apps.

I created a pull request for one app a while ago to support both the callback and promise variants (if you need to support < 2.2):

https://github.com/texthtml/torch/commit/9ed896eae4436fb3295eadfc1a23ac2d439e52d8
Flags: needinfo?(aosmond)
See Also: → 1107683
andrew, does this mean that the developer has to modify their app with the code you've submitted??
Flags: needinfo?(aosmond)
Yes, but I would not recommend the code that :aosmond provided as it uses feature detection to differ between old and new API.

Also can we update the docs when we break privileged APIs that are used widely? https://developer.mozilla.org/en-US/docs/Web/API/CameraManager/getCamera
aosmond when 2.2 broke because of the API breaking changes, why would 2.1 cause breakage?
This issue is blocking the certification of the first device to be launched with v2.1, please provide a way to unlock the situation.
My reference code works on 2.0 and 2.2 but for TEF fails on their 2.1 device: https://github.com/digitarald/firefox-os-flashlight . We need to make sure nothing changed on our side that would break this.
Flags: needinfo?(hkoka)
(In reply to Harald Kirschner :digitarald from comment #16)
> My reference code works on 2.0 and 2.2 but for TEF fails on their 2.1
> device: https://github.com/digitarald/firefox-os-flashlight . We need to
> make sure nothing changed on our side that would break this.

Andrew is doing a build now and investigating this. Will leave the NI on him to report his findings.
Flags: needinfo?(hkoka)
2.1 flash apps work for me on Flame. Could I get some build information from you?

Build ID               20150714001203
Gaia Revision          d13826b20b4a45e3f5cd4b25a30a737d8be7f1b9
Gaia Date              2015-07-02 23:36:46
Gecko Revision         https://hg.mozilla.org/releases/mozilla-b2g34_v2_1/rev/92049b3c4bb5
Gecko Version          34.0
Device Name            flame
Firmware(Release)      4.4.2
Firmware(Incremental)  eng.cltbld.20150714.034039
Firmware Date          Tue Jul 14 03:40:51 EDT 2015
Bootloader             L1TC000118D0

I tried the above build, in addition to building it myself to see with some extra logging. I installed LED flashlight and Multiflash via Marketplace, no problems. I also synced https://github.com/digitarald/firefox-os-flashlight and https://github.com/mdq3/multiflash and installed them via the WebIDE -- they also worked for me without any problems.

In terms of WebIDL API changes (for the mozCamera object) from 2.0 to 2.1, the only modification (besides additions) was changing exposure compensation from a getter/setter to an attribute. The applications don't appear to use this attribute (nor would I expect them to).
Flags: needinfo?(mellis)
Flags: needinfo?(hkirschner)
Flags: needinfo?(aosmond)
José to provide his device info.
Flags: needinfo?(mellis)
Flags: needinfo?(joseenrique.alvarezfernandez)
Flags: needinfo?(hkirschner)
Ok.

I've downloaded the LED flashlight app from the marketplace and tested on ZTE OPEN C2 with 2.1 and it works.
BUT the problem is that the app that we are preloading in the device is NOT WORKING and it was working on 2.0
We can't preload any other app so we need the flashlight that was developed by TechTree to work. I've attached it to this bug so you can guys review it if you need it
Flags: needinfo?(joseenrique.alvarezfernandez)
This is the last version of the Flashlight developed by TechTree and the one that we are preloading. It was working fine on FFOS 2.0 but it not longer does.

It is not on the Marketplace so you have to sideload it.
(In reply to joseenrique.alvarezfernandez from comment #21)
> Created attachment 8633988 [details]
> Flashlight_V2.1-for-gaia-2.0.zip
> 
> This is the last version of the Flashlight developed by TechTree and the one
> that we are preloading. It was working fine on FFOS 2.0 but it not longer
> does.
> 
> It is not on the Marketplace so you have to sideload it.

Thanks, I've sideloaded it onto the same 2.1 builds but it still works for me. I noticed it does not release the camera when you background the application so it prevents all of the other camera using applications from working; this will be fixed in 3.0 by bug 1073017. The only way to work around it in the app is to release the camera handle when the window is hidden. If you force close the app, everything else can use the camera again.

If I install a second copy of the app (just copied the folder, renamed that and in the manifest), I can see that the second instance silently fails if the first instance is backgrounded and still holding the camera. I suspect this might be your problem.

Can you:
1) Open the default FFOS camera app to see if it reports "Camera Unavailable" when the flash won't start for your app, and
2) Force close all backgrounded applications and then retry your app.
Flags: needinfo?(joseenrique.alvarezfernandez)
Tested with latest ZTE build in v2.1
> Can you:
> 1) Open the default FFOS camera app to see if it reports "Camera
> Unavailable" when the flash won't start for your app, and
yes, I can reproduce the "camera unavailable" message
> 2) Force close all backgrounded applications and then retry your app.
No, it still doesn't work.

So I guess we had two issues now with this application: Flash is not working and camera is not released after moving the flashlight app to background.
(In reply to Beatriz Rodríguez [:brg] from comment #23)
> Tested with latest ZTE build in v2.1
> > Can you:
> > 1) Open the default FFOS camera app to see if it reports "Camera
> > Unavailable" when the flash won't start for your app, and
> yes, I can reproduce the "camera unavailable" message
> > 2) Force close all backgrounded applications and then retry your app.
> No, it still doesn't work.
> 
> So I guess we had two issues now with this application: Flash is not working
> and camera is not released after moving the flashlight app to background.

Okay so based on 1), flash probably does work and the problem is the camera resource is already taken. 2) very much confuses me however -- even if the applications crash in the worst case, the Android media service will detect the loss of the client/child process and release the camera resource on its behalf... To be clear, after closing all of the backgrounded apps (hold home button and press "x" for all apps that come up?), the FFOS camera app also still reports camera unavailable?
Had mid air collision

I have the same results than Beatriz
Flags: needinfo?(joseenrique.alvarezfernandez)
(In reply to Andrew Osmond [:aosmond] from comment #24)
> 
> Okay so based on 1), flash probably does work and the problem is the camera
> resource is already taken. 2) very much confuses me however -- even if the
> applications crash in the worst case, the Android media service will detect
> the loss of the client/child process and release the camera resource on its
> behalf... To be clear, after closing all of the backgrounded apps (hold home
> button and press "x" for all apps that come up?), the FFOS camera app also
> still reports camera unavailable?

No, after closing all backgrounded apps, camera app can be used again normally. You can take a picture even using the flash.
(In reply to Beatriz Rodríguez [:brg] from comment #26)
> (In reply to Andrew Osmond [:aosmond] from comment #24)
> > 
> > Okay so based on 1), flash probably does work and the problem is the camera
> > resource is already taken. 2) very much confuses me however -- even if the
> > applications crash in the worst case, the Android media service will detect
> > the loss of the client/child process and release the camera resource on its
> > behalf... To be clear, after closing all of the backgrounded apps (hold home
> > button and press "x" for all apps that come up?), the FFOS camera app also
> > still reports camera unavailable?
> 
> No, after closing all backgrounded apps, camera app can be used again
> normally. You can take a picture even using the flash.

Yes, I've got the same results. 

Also, If you open the flashlight app but you don't touch the button to light up the LED, put it in background and then open the camera the message that the app is unavailable appears
Component: 3rd Party Applications → General
Product: Marketplace → Firefox OS
Version: Avenir → unspecified
Firefox OS is not being worked on
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.