Closed
Bug 1011606
Opened 10 years ago
Closed 10 years ago
[Camera] [Gecko] I cannot serialize mozCamera.capabilities object
Categories
(Firefox OS Graveyard :: Gaia::Camera, defect)
Tracking
(Not tracked)
RESOLVED
DUPLICATE
of bug 1020368
People
(Reporter: dmarcos, Unassigned, Mentored)
References
Details
(Whiteboard: [mentor=mikeh][lang=C++][LOE:S][good first bug])
Attachments
(2 files)
I get an empty object "{}" when I do:
JSON.stringify(mozCamera.capabilities)
I get proper values if I do:
JSON.stringify(mozCamera.capabilities.previewSizes)
Why is this?
Comment 2•10 years ago
|
||
The CameraCapabilities interface doesn't claim to have a jsonifier. Since JSON.stringify only considers own props by default, and this object (like most DOM objects) doesn't have any, you get the observed behavior.
If you want to be able to JSON.stringify this thing, throw a jsonifier on there.
Flags: needinfo?(bzbarsky)
Reporter | ||
Comment 4•10 years ago
|
||
It's something everybody would expect. If an API returns an object I expect a real object. I found the issue when trying to use it for debugging information.
Flags: needinfo?(dmarcos)
Comment 5•10 years ago
|
||
It's a real object. The properties are just on the prototype, not on the object itself, which is a perfectly normal thing for objects in JS to do.
Reporter | ||
Comment 6•10 years ago
|
||
Don't you think is confusing that an API returns the values in the prototype object? It makes the API more difficult to learn. You're surprising the users. Can you move those values to the object?
Flags: needinfo?(bzbarsky)
Comment 7•10 years ago
|
||
Diego, the _values_ are in the object. But the _getters_ are in the prototype.
This is a very common pattern in JS for cases when you actually use a getter instead of a value property.
Again, if we seriously think people will want to JSON.stringify this, we should add a jsonifier, which adds a toJSON method which returns something useful.
Flags: needinfo?(bzbarsky)
Updated•10 years ago
|
Hello,
I am new to the OSS community and would like to contribute. I saw this as an unassigned mentored bug. Would this be a good place to start?
If so could someone how I could betting understand the bug and start working on it.
I already have the firefox source and build on my machine.
Thank you.
Updated•10 years ago
|
Flags: needinfo?(mhabicher)
Comment 9•10 years ago
|
||
Hi GU, welcome aboard!
Did you pull just the Firefox source, or have you configured a Firefox OS build environment as well? Take a look at:
https://developer.mozilla.org/en-US/Firefox_OS/Building_and_installing_Firefox_OS
If you don't have a phone, you can build for the emulator.
This change is very straightforward: you just need to add a single line to dom/webidl/CameraCapabilities.webidl:
jsonifier;
...and write or extend an existing emulator test (see dom/camera/test/*) to verify that everything works.
The simple value types (sequences, unsigned longs) will JSON-ified by the framework, but some additional work will be needed to handle the 'recorderProfiles' attribute. I recommend getting the simple cases and test working first (which will prove your build environment and tests) and we can take it from there.
Please feel free to ni? me (or find me on IRC) if you need any help.
Flags: needinfo?(mhabicher)
Comment 10•10 years ago
|
||
Also, bug 1020368 is filed to remove some direct JS-engine calls from the class that underlies 'recorderProfiles', so that its 'any' type can be changed to a concrete interface type. If that type also had a jsonifier annotation, then all of this should happen magically.
Comment 11•10 years ago
|
||
Hi,
Thank you for your reply. I built the OS but am having problems running the emulator. To build i ran
./config.sh emulator
./build.sh
./run-emulator.sh
All i see is a black screen which after a while turns grey. I tried disabling the GPU from the run-emulator script but that didnt help.
Any idea what I could be doing wrong. I am running Ubuntu 14.04LTS.
Comment 12•10 years ago
|
||
Hi GU, those are the correct commands. Note that the emulator is not fast. It usually takes my Thinkpad X220 (dual core i7 @ 2.8GHz) several minutes to start the first-time-use wizard. During this time, the logcat output doesn't show much, so it might look like the emulator is doing nothing.
If that still doesn't help, try updating your build tree. Occasionally there are bad changesets that break the emulator.
Comment 13•10 years ago
|
||
My log file for firefox OS booting up.
Comment 14•10 years ago
|
||
I was under the impression that logcat only produced logs once the emulator had booted up. So I looked at logcat and it seems to be looping. Iv attached the output from the log.
If this doesn't help I can look into uploading the build tree.
Comment 15•10 years ago
|
||
Hello Mike,
Could please guide me on how I should proceed with this. I have looked at the code and the fix seems fairly straight forward.
Thanks
Comment 16•10 years ago
|
||
Hello Mike,
Could please guide me on how I should proceed with this. I have looked at the code and the fix seems fairly straight forward.
Thanks
Comment 17•10 years ago
|
||
Hi GU, that logcat looks very short, and I don't see anything obviously wrong in the output. Please try updating your tree and making a fresh build:
git pull -u
./config.sh emulator
rm -rf out
rm -rf objdir-gecko
./build.sh
Sometimes you get unlucky and pull a bad changeset. If the above steps don't fix your problem, please capture a log by running |adb logcat -v threadtime| -- the extra parameters add timestamps to the log, to make it more obvious what is going on.
Comment 18•10 years ago
|
||
So i cleaned and got the latest version and ran again and it seems to be stuck again. attached in the log with
adb logcat -v threadtime
Comment 19•10 years ago
|
||
GU, the following means mediaserver is crashing:
10-25 19:36:06.892 33 33 I ServiceManager: service 'media.resource_manager' died
10-25 19:36:06.892 33 33 I ServiceManager: service 'permission' died
10-25 19:36:06.902 33 33 I ServiceManager: service 'media.audio_policy' died
10-25 19:36:06.902 33 33 I ServiceManager: service 'media.audio_flinger' died
10-25 19:36:06.902 33 33 I ServiceManager: service 'media.player' died
10-25 19:36:06.902 33 33 I ServiceManager: service 'media.camera' died
If you are comfortable with gdb, then you can try debugging the crash. 'adb shell ps | grep mediaserver' should tell you the $PID of mediaserver, and you can try attaching to it by running './run-gdb.sh attach $PID'. gdb should trap the crash, and then 'bt' or 'bt full' will dump the backtrace.
It might take some careful timing, depending on how quickly the crash happens.
Comment 20•10 years ago
|
||
That sounds cool. I'l fire up gdb as soon as I get some time. I also kept reading this:
Failed to load native module at path '/system/b2g/components/libxpcomsample.so': (80004005) Cannot load library: load_library[1091]: Library '/system/b2g/components/libxpcomsample.so' not found
I was wondering if this has any significance?
Comment 21•10 years ago
|
||
(In reply to GU from comment #20)
> Failed to load native module at path
> '/system/b2g/components/libxpcomsample.so': (80004005) Cannot load library:
> load_library[1091]: Library '/system/b2g/components/libxpcomsample.so' not
> found
I've seen that error too when things are working properly. I don't think it's related.
Comment 22•10 years ago
|
||
GU, I've been working on cleaning up the camera capabilities reporting, and adding serialization to it was simple enough, so this bug has been absorbed into the patch in bug 1020368 -- my apologies.
We should try to get your emulator problems sorted out, though. Feel free to email me directly (or find me on IRC) if you're still having trouble.
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•