Closed Bug 879756 Opened 11 years ago Closed 11 years ago

Possible memory leak when repeatedly opening and closing applications

Categories

(Firefox OS Graveyard :: Gaia::System, defect, P2)

ARM
Gonk (Firefox OS)
defect

Tracking

(b2g18+)

RESOLVED WORKSFORME
Tracking Status
b2g18 + ---

People

(Reporter: rwood, Assigned: hub)

References

Details

(Keywords: perf, Whiteboard: [c= ][MemShrink])

Attachments

(2 files)

Attached file About_memory logs
It looks like there might be a memory leak in the Camera viewfinder on Firefox OS.

Found by running a gaia-ui endurance test (camera_viewfinder) on inari, on b2g 18 v1.0.1. The test starts up the camera app, just leaves the viewfinder open for 30 seconds (doesn't actually take a photo), closes down the app, then repeats. The test is ran 100 iterations, and every 10 iterations there is a device-side checkpoint that records the b2g memory use value.

To demonstrate, click on any of these datapoints on DataZilla on the graph at the following link.  This is from the camera_viewfinder test running on inari with b2g v1.0.1:

https://datazilla.mozilla.org/b2g/?branch=master&device=inari&range=7&test=endurance_camera_viewfinder&app_list=browser,camera&app=camera&gaia_rev=bf10abc41a015169&gecko_rev=08a0e76ee93117be

You will notice on the detailed data in the chart at the bottom, that for each b2g memory checkpoint (every 10 iterations), the memory use increases. I did not expect the memory use to increase, because no photo is actually being taken.

The source code for the camera_viewfinder test can be found here:

https://github.com/rwood-moz/gaia-ui-tests/blob/gaiastress/gaiatest/tests/endurance/test_endurance_camera_viewfinder.py

I also did a v1-train build of inari with DMD enabled (June 3). Attached are about_memory logs before, and then after running the same camera_viewfinder test at 100 iterations. Attached is also the corresponding b2g memory process data output from the endurance test.
Does the call to 'self.close_app()' actually terminate the Camera application, or just send it to the background? If the former, I don't see how it's possible for the Camera app to leak member, since it's killed and cleaned up by the OS. In that case, the leak would need to be in the parent process somewhere.
s/member/memory
blocking-b2g: --- → leo?
Ahhh.. yes the call to 'self.close_app()' actually kills the app by pressing the home button then clicking on the 'x' on the app's card view, to close it.

I found a similar issue with a browser test (Bug 879031), which also closes the app, so yes perhaps it is a leak with cards_view or closing an app or something and not the particular app itself...
Changing the summary and component to better reflect the issue... thanks :mikeh
Component: Gaia::Camera → Gaia::System
Summary: [camera] Possible memory leak in camera viewfinder → Possible memory leak when repeatedly opening and closing applications
Based on comment 1, b2g memory is increasing slowly:

b2g_vsize: 181588, 186644, 192788, 202068, 202068, 208212, 211220, 208156, 212252, 215392
------------------------------------------------------------------
Twice-reported stack trace records
------------------------------------------------------------------

Twice-reported: 206 blocks in stack trace record 1 of 5
 4,218,880 bytes (3,864,972 requested / 353,908 slop)
 7.74% of the heap (7.74% cumulative);  91.72% of twice-reported (91.72% cumulative)
 Allocated at
   malloc /home/rwood-gaia/B2G/gecko/memory/build/replace_malloc.c:152 (0x4017a2ae libmozglue.so+0x42ae)
   js_malloc /home/rwood-gaia/B2G/objdir-gecko/dist/include/js/Utility.h:153 (0x41614642 libxul.so+0xcb6642)
   JSStructuredCloneReader::startRead(JS::Value*) /home/rwood-gaia/B2G/gecko/js/src/jsclone.cpp:956 (0x41615bae libxul.so+0xcb7bae)
   js::ReadStructuredClone(JSContext*, unsigned long long*, unsigned int, JS::Value*, JSStructuredCloneCallbacks const*, void*) /home/rwood-gaia/B2G/gecko/js/src/jsclone.cpp:145 (0x416163ce libxul.so+0xcb83ce)
   JS_ReadStructuredClone /home/rwood-gaia/B2G/gecko/js/src/jsapi.cpp:6461 (0x415fc918 libxul.so+0xc9e918)
   mozilla::dom::ReadStructuredClone(JSContext*, unsigned long long*, unsigned int, mozilla::dom::StructuredCloneClosure const&, JS::Value*) /home/rwood-gaia/B2G/gecko/dom/ipc/StructuredCloneUtils.cpp:176 (0x412d02a0 libxul.so+0x9722a0)
   nsFrameMessageManager::ReceiveMessage(nsISupports*, nsAString_internal const&, bool, mozilla::dom::StructuredCloneData const*, JSObject*, InfallibleTArray<nsString>*, JSContext*) /home/rwood-gaia/B2G/gecko/content/base/src/nsFrameMessageManager.cpp:572 (0x40e5f374 libxul.so+0x501374)
   nsAsyncMessageToSameProcessChild::Run() /home/rwood-gaia/B2G/gecko/content/base/src/nsFrameMessageManager.cpp:1094 (0x40e5f820 libxul.so+0x501820)
   nsThread::ProcessNextEvent(bool, bool*) /home/rwood-gaia/B2G/gecko/xpcom/threads/nsThread.cpp:620 (0x413f3d6e libxul.so+0xa95d6e)
   NS_ProcessNextEvent_P(nsIThread*, bool) /home/rwood-gaia/B2G/objdir-gecko/dist/include/nsError.h:1069 (0x413d412e libxul.so+0xa7612e)
   mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) /home/rwood-gaia/B2G/gecko/ipc/glue/MessagePump.cpp:83 (0x412e6a84 libxul.so+0x988a84)
   MessageLoop::RunInternal() /home/rwood-gaia/B2G/gecko/ipc/chromium/src/base/message_loop.cc:220 (0x41416488 libxul.so+0xab8488)
   ~AutoRunState /home/rwood-gaia/B2G/gecko/ipc/chromium/src/base/message_loop.cc:506 (0x41416532 libxul.so+0xab8532)
   nsBaseAppShell::Run() /home/rwood-gaia/B2G/gecko/widget/xpwidgets/nsBaseAppShell.cpp:165 (0x4126b904 libxul.so+0x90d904)
   nsAppStartup::Run() /home/rwood-gaia/B2G/objdir-gecko/dist/include/nsError.h:1065 (0x411cfae8 libxul.so+0x871ae8)
   XREMain::XRE_mainRun() /home/rwood-gaia/B2G/objdir-gecko/dist/include/nsError.h:1065 (0x40bfa0ba libxul.so+0x29c0ba)
   XREMain::XRE_main(int, char**, nsXREAppData const*) /home/rwood-gaia/B2G/gecko/toolkit/xre/nsAppRunner.cpp:3881 (0x40bfc724 libxul.so+0x29e724)
   XRE_main /home/rwood-gaia/B2G/gecko/toolkit/xre/nsAppRunner.cpp:3935 (0x40bfc870 libxul.so+0x29e870)
   (0x9a0e /system/b2g/b2g+0x9a0e) (can't find lib)
   __libc_init /home/rwood-gaia/B2G/bionic/libc/bionic/libc_init_dynamic.c:114 (0x4007477a libc.so+0x1677a)
   __cxa_atexit /home/rwood-gaia/B2G/bionic/libc/stdlib/atexit.c:101 (0x4007cd86 libc.so+0x1ed86)
bjacob, this looks a lot like what we were seeing in bug 860483, which we closed wontfix because it seemed to be unagi-specific. Except in this case it's on inari. :(

------------------------------------------------------------------
Unreported stack trace records
------------------------------------------------------------------

Unreported: ~640 blocks in stack trace record 1 of 637
 ~2,619,520 bytes (~2,619,520 requested / ~0 slop)
 4.80% of the heap (4.80% cumulative);  11.50% of unreported (11.50% cumulative)
 Allocated at
   calloc /home/rwood-gaia/B2G/gecko/memory/build/replace_malloc.c:182 (0x4017a208 libmozglue.so+0x4208)
   os_calloc_ext (0x42c380e4 libgsl.so+0x40e4) (no addr2line)
   eglSetYUVAttributes (0x4285dac4 libEGL_adreno200.so+0x19ac4) (no addr2line)
   qeglDrvAPI_eglCreateImageKHR (0x428501f0 libEGL_adreno200.so+0xc1f0) (no addr2line)
   eglCreateImageKHR (0x42d586f4 libEGL_adreno200.so+0x56f4) (no addr2line)
   eglCreateImageKHR /home/rwood-gaia/B2G/frameworks/base/opengl/libs/EGL/eglApi.cpp:1276 (0x402cdfc8 libEGL.so+0xcfc8)
   mozilla::gl::GLContext::fBindTexture(unsigned int, unsigned int) /home/rwood-gaia/B2G/gecko/gfx/gl/GLContext.h:2231 (0x4149bb6e libxul.so+0xb1fb6e)
   mozilla::layers::ShadowImageLayerOGL::RenderLayer(int, nsIntPoint const&) /home/rwood-gaia/B2G/gecko/gfx/layers/opengl/ImageLayerOGL.cpp:970 (0x41481e90 libxul.so+0xb05e90)
   nsRefPtr<mozilla::gl::GLContext>::get() const /home/rwood-gaia/B2G/objdir-gecko/dist/include/nsAutoPtr.h:1003 (0x414622f6 libxul.so+0xb042f6)
   nsRefPtr<mozilla::gl::GLContext>::get() const /home/rwood-gaia/B2G/objdir-gecko/dist/include/nsAutoPtr.h:1003 (0x414622f6 libxul.so+0xb042f6)
   nsRefPtr<mozilla::gl::GLContext>::get() const /home/rwood-gaia/B2G/objdir-gecko/dist/include/nsAutoPtr.h:1003 (0x4146266a libxul.so+0xb0466a)
   nsRefPtr<mozilla::gl::GLContext>::get() const /home/rwood-gaia/B2G/objdir-gecko/dist/include/nsAutoPtr.h:1003 (0x414622f6 libxul.so+0xb042f6)
   nsRefPtr<mozilla::gl::GLContext>::get() const /home/rwood-gaia/B2G/objdir-gecko/dist/include/nsAutoPtr.h:1003 (0x414622f6 libxul.so+0xb042f6)
   nsRefPtr<mozilla::gl::GLContext>::get() const /home/rwood-gaia/B2G/objdir-gecko/dist/include/nsAutoPtr.h:1003 (0x414622f6 libxul.so+0xb042f6)
   nsRefPtr<mozilla::gl::GLContext>::get() const /home/rwood-gaia/B2G/objdir-gecko/dist/include/nsAutoPtr.h:1003 (0x414622f6 libxul.so+0xb042f6)
   mozilla::layers::LayerManagerOGL::Render() /home/rwood-gaia/B2G/gecko/gfx/layers/opengl/LayerManagerOGL.cpp:1031 (0x41466ae4 libxul.so+0xb08ae4)
   mozilla::layers::LayerManagerOGL::EndTransaction(void (*)(mozilla::layers::ThebesLayer*, gfxContext*, nsIntRegion const&, nsIntRegion const&, void*), void*, mozilla::layers::LayerManager::EndTransactionFlags) /home/rwood-gaia/B2G/gecko/gfx/layers/opengl/LayerManagerOGL.cpp:700 (0x41466f2e libxul.so+0xb08f2e)
   mozilla::layers::LayerManagerOGL::EndEmptyTransaction(mozilla::layers::LayerManager::EndTransactionFlags) /home/rwood-gaia/B2G/gecko/gfx/layers/opengl/LayerManagerOGL.cpp:642 (0x41464aa2 libxul.so+0xb06aa2)
   ~AutoResolveRefLayers /home/rwood-gaia/B2G/gecko/gfx/layers/ipc/CompositorParent.cpp:458 (0x414724be libxul.so+0xb144be)
   RunnableMethod<mozilla::layers::ImageContainerChild, void (mozilla::layers::ImageContainerChild::*)(), Tuple0>::Run() /home/rwood-gaia/B2G/gecko/ipc/chromium/src/base/task.h:308 (0x412c8f36 libxul.so+0x96af36)
   MessageLoop::RunTask(Task*) /home/rwood-gaia/B2G/gecko/ipc/chromium/src/base/message_loop.cc:338 (0x414164cc libxul.so+0xab84cc)
   MessageLoop::DeferOrRunPendingTask(MessageLoop::PendingTask const&) /home/rwood-gaia/B2G/gecko/ipc/chromium/src/base/message_loop.cc:348 (0x414172fe libxul.so+0xab92fe)
   MessageLoop::DoWork() /home/rwood-gaia/B2G/gecko/ipc/chromium/src/base/message_loop.cc:445 (0x41417edc libxul.so+0xab9edc)
   base::MessagePumpDefault::Run(base::MessagePump::Delegate*) /home/rwood-gaia/B2G/gecko/ipc/chromium/src/base/message_pump_default.cc:24 (0x4141816c libxul.so+0xaba16c)
Flags: needinfo?(bjacob)
Yes, this definitely looks like the same as in bug 860483. We established that it was a driver bug, asked Qualcomm about it, and the answer was that that was specific to Unagi's driver. I would suggest getting fresh input from Qualcomm on this new bug.
Flags: needinfo?(bjacob)
Michael, we need your expertise here.
Flags: needinfo?(mvines)
Keywords: perf
Whiteboard: c=
Can you please try on Buri or Leo?  For v1.1 we don't be able to support ics_chocolate (baseline that Inari, Unagi are using.)
Flags: needinfo?(mvines)
Yes, if you can get me one of those devices then no problem :)
I have borrowed a Leo from Sotaro
Update: Unable to run the test on the Leo as the microSD card is not working. Tried the latest b2g18 Leo nightly as well as an older one. Will try a v1-train engineering build from Sotaro tomorrow and see if the microSD is also broken there. Need the microSD for the test (i.e. start the camera viewfinder).
Putting qawanted on this to keep this on our radar. 

Severity of the bug depends largely on how many devices are being hit by the problem--if Rob's exploration isn't fruitful, we should see if we can help.
Keywords: qawanted
(In reply to Geo Mealer [:geo] from comment #16)
> Putting qawanted on this to keep this on our radar. 
> 
> Severity of the bug depends largely on how many devices are being hit by the
> problem--if Rob's exploration isn't fruitful, we should see if we can help.

If doing this via automation is running into trouble, we could do manual investigation here if need be on the target devices.
Triage- Tracking as this is found during endurance QA testing. Should have low impact on regular daily usage.

Please renom if not the case.
blocking-b2g: leo? → ---
tracking-b2g18: --- → +
This may be related to the issue in bug 851626.
See Also: → 851626
Priority: -- → P2
I can take a look at this one
Assignee: nobody → hub
I'm gonna wait that bug 887326 is resolved (regression). It might be related to me not seeing this extensive memory leakage.
blocking-b2g: --- → leo?
Priority: P2 → --
blocking-b2g: leo? → ---
Priority: -- → P2
Status: NEW → ASSIGNED
Whiteboard: c= → [c= ]
As of today I still get a black viewfinder on Keon. Bug 880780
Depends on: 880780
Depends on: 894557
Depends on: 892708
No longer depends on: 894557
Whiteboard: [c= ] → [c= ][MemShrink]
I get the leak with the camera viewfinder, but as I am on Unagi, we have established it is bug 860483 (WONTFIX as of now).

This happen by just leaving the camera app open and the b2g VSIZE and RSS increase. It stops increasing when I close it or put it in the background.
Status: ASSIGNED → NEW
Status: NEW → ASSIGNED
I haven't found any evidence of the leak with camera / gallery on Inari.

Closing as WFM. If you have a better scenario, please open a new bug.
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → WORKSFORME
Keywords: qawanted
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: