Closed
Bug 1170061
Opened 10 years ago
Closed 9 years ago
Handle shutdown case for HwcComposer2D
Categories
(Core Graveyard :: Widget: Gonk, defect)
Tracking
(firefox41 fixed)
RESOLVED
FIXED
mozilla41
Tracking | Status | |
---|---|---|
firefox41 | --- | fixed |
People
(Reporter: boris, Assigned: boris)
References
Details
Attachments
(1 file, 9 obsolete files)
4.90 KB,
patch
|
boris
:
review+
|
Details | Diff | Splinter Review |
We should call ClearOnShutdown() while creating HwcComposer2D object to make sure we handle the shutdown case properly.
Assignee | ||
Updated•10 years ago
|
Blocks: RefactorHwc
Assignee | ||
Comment 1•10 years ago
|
||
Comment hidden (obsolete) |
Assignee | ||
Updated•10 years ago
|
Assignee: nobody → boris.chiou
Assignee | ||
Updated•10 years ago
|
Assignee: boris.chiou → nobody
Assignee | ||
Updated•10 years ago
|
Summary: Handle shutdown case for HwcComposer2D → Handle shutdown case for HwcComposer2D and HwcHAL
Assignee | ||
Updated•10 years ago
|
OS: Unspecified → Gonk (Firefox OS)
Hardware: Unspecified → ARM
Assignee | ||
Comment 3•10 years ago
|
||
Call ClearOnShutdown when new HwcComposer2D object and clear
HwcHAL in the destructor of HwcComposer2D.
Attachment #8613349 -
Attachment is obsolete: true
Assignee | ||
Updated•10 years ago
|
Assignee: nobody → boris.chiou
Assignee | ||
Comment 4•10 years ago
|
||
Comment on attachment 8613452 [details] [diff] [review]
ClearOnShutdown for hwcomposer (v2)
Review of attachment 8613452 [details] [diff] [review]:
-----------------------------------------------------------------
Hi Sotaro,
This patch is based on Bug 1144012 Comment 146. I added ClearOnShutDown() in HwcComposer2D and a new public API in HwcHALBase to nullify the StaticRefPtr, so now we could manually clear StaticRefPtr<HwcHALBase> in HwcComposer2D destructor. However, GonkDisplayJB still holds this ref-counted pointer (nsRefPtr<HwcHALBase>) and no one would clear GonkDisplayJB object. It's a potential bug we have to fix later.
Attachment #8613452 -
Flags: feedback?(sotaro.ikeda.g)
Updated•10 years ago
|
Attachment #8613452 -
Flags: feedback?(sotaro.ikeda.g) → feedback+
Assignee | ||
Updated•9 years ago
|
Summary: Handle shutdown case for HwcComposer2D and HwcHAL → Handle shutdown case for HwcComposer2D
Comment hidden (typo) |
Assignee | ||
Comment 6•9 years ago
|
||
Call ClearOnShutdown while creaing HwcComposer2D object.
I think we don't need to clear HwcHAL manually in this bug because HwcHAL
will be destructed automatically by UniquePtr, according to Bug 1144012.
Attachment #8613452 -
Attachment is obsolete: true
Attachment #8617083 -
Attachment is obsolete: true
Assignee | ||
Updated•9 years ago
|
Attachment #8617085 -
Flags: review?(sotaro.ikeda.g)
Assignee | ||
Updated•9 years ago
|
Status: NEW → ASSIGNED
Comment 7•9 years ago
|
||
Comment on attachment 8617085 [details] [diff] [review]
ClearOnShutdown for hwcomposer (v3)
Review of attachment 8617085 [details] [diff] [review]:
-----------------------------------------------------------------
::: widget/gonk/HwcComposer2D.cpp
@@ +170,5 @@
> {
> if (!sInstance) {
> LOGI("Creating new instance");
> sInstance = new HwcComposer2D();
> + ClearOnShutdown(&sInstance);
This should be called on main thread. How is it ensured?
Comment 8•9 years ago
|
||
(In reply to Sotaro Ikeda [:sotaro] from comment #7)
>
> ::: widget/gonk/HwcComposer2D.cpp
> @@ +170,5 @@
> > {
> > if (!sInstance) {
> > LOGI("Creating new instance");
> > sInstance = new HwcComposer2D();
> > + ClearOnShutdown(&sInstance);
>
> This should be called on main thread. How is it ensured?
And please add it as a comment, since Composer2D api is normally called on Compositor thread.
Assignee | ||
Comment 9•9 years ago
|
||
(In reply to Sotaro Ikeda [:sotaro] from comment #7)
> Comment on attachment 8617085 [details] [diff] [review]
> ClearOnShutdown for hwcomposer (v3)
>
> Review of attachment 8617085 [details] [diff] [review]:
> -----------------------------------------------------------------
>
> ::: widget/gonk/HwcComposer2D.cpp
> @@ +170,5 @@
> > {
> > if (!sInstance) {
> > LOGI("Creating new instance");
> > sInstance = new HwcComposer2D();
> > + ClearOnShutdown(&sInstance);
>
> This should be called on main thread. How is it ensured?
Thanks for your reminder. I will add a comment and NS_IsMainThread() to make sure it is called on main thread.
BTW: Flame (with vsync) will call this on main thread according to current implementation:
https://dxr.mozilla.org/mozilla-central/source/gfx/thebes/gfxAndroidPlatform.cpp?from=gfxAndroidPlatform.cpp#457
Assignee | ||
Comment 10•9 years ago
|
||
(In reply to Boris Chiou [:boris] from comment #9)
> (In reply to Sotaro Ikeda [:sotaro] from comment #7)
> > Comment on attachment 8617085 [details] [diff] [review]
> > ClearOnShutdown for hwcomposer (v3)
> >
> > Review of attachment 8617085 [details] [diff] [review]:
> > -----------------------------------------------------------------
> >
> > ::: widget/gonk/HwcComposer2D.cpp
> > @@ +170,5 @@
> > > {
> > > if (!sInstance) {
> > > LOGI("Creating new instance");
> > > sInstance = new HwcComposer2D();
> > > + ClearOnShutdown(&sInstance);
> >
> > This should be called on main thread. How is it ensured?
>
> Thanks for your reminder. I will add a comment and NS_IsMainThread() to make
> sure it is called on main thread.
>
> BTW: Flame (with vsync) will call this on main thread according to current
> implementation:
> https://dxr.mozilla.org/mozilla-central/source/gfx/thebes/gfxAndroidPlatform.
> cpp?from=gfxAndroidPlatform.cpp#457
BTW, there is another problem. KillClearOnShutdown() is called in ShutdownXPCOM(),
(https://dxr.mozilla.org/mozilla-central/source/xpcom/build/XPCOMInit.cpp#884), and I'm not sure whether it is a good place to clear HwcComposer2D in ShutdownXPCOM() or not.
Assignee | ||
Comment 11•9 years ago
|
||
Call ClearOnShutdown while creaing HwcComposer2D object.
Attachment #8617085 -
Attachment is obsolete: true
Attachment #8617085 -
Flags: review?(sotaro.ikeda.g)
Attachment #8617790 -
Flags: review?(sotaro.ikeda.g)
Comment 12•9 years ago
|
||
From gfx layer's rendering point of view, it is enough, because gfxPlatform::ShutdownLayersIPC() is already called.
It might better to have a singleton check like MediaManager::Get()
http://mxr.mozilla.org/mozilla-central/source/dom/media/MediaManager.cpp#1601
Assignee | ||
Comment 13•9 years ago
|
||
(In reply to Sotaro Ikeda [:sotaro] from comment #12)
> From gfx layer's rendering point of view, it is enough, because
> gfxPlatform::ShutdownLayersIPC() is already called.
>
> It might better to have a singleton check like MediaManager::Get()
>
> http://mxr.mozilla.org/mozilla-central/source/dom/media/MediaManager.cpp#1601
OK. Do you mean that we can write a help checker function, ex. HwcComposer2D::Get(), to check the object status and creation, and put the main thread check in this checker function? Therefore, HwcComposer2D::GetInstance() could be simpler.
Comment 14•9 years ago
|
||
(In reply to Boris Chiou [:boris] from comment #13)
> (In reply to Sotaro Ikeda [:sotaro] from comment #12)
> > From gfx layer's rendering point of view, it is enough, because
> > gfxPlatform::ShutdownLayersIPC() is already called.
> >
> > It might better to have a singleton check like MediaManager::Get()
> >
> > http://mxr.mozilla.org/mozilla-central/source/dom/media/MediaManager.cpp#1601
>
> OK. Do you mean that we can write a help checker function, ex.
> HwcComposer2D::Get(), to check the object status and creation, and put the
> main thread check in this checker function? Therefore,
> HwcComposer2D::GetInstance() could be simpler.
Sorry, for confusion. I just said to add a code like the following. And
> NS_ASSERTION(NS_IsMainThread(),
> #ifdef DEBUG
> static int timesCreated = 0;
> timesCreated++;
> MOZ_ASSERT(timesCreated == 1);
>#endif
And it seems better to handle nsWindow::~nsWindow() case. To handle it, it seems better that the nsWindow holds a reference to HwcComposer2D.
https://dxr.mozilla.org/mozilla-central/source/widget/gonk/nsWindow.cpp#87
Assignee | ||
Comment 15•9 years ago
|
||
(In reply to Sotaro Ikeda [:sotaro] from comment #14)
> (In reply to Boris Chiou [:boris] from comment #13)
> > (In reply to Sotaro Ikeda [:sotaro] from comment #12)
> > > From gfx layer's rendering point of view, it is enough, because
> > > gfxPlatform::ShutdownLayersIPC() is already called.
> > >
> > > It might better to have a singleton check like MediaManager::Get()
> > >
> > > http://mxr.mozilla.org/mozilla-central/source/dom/media/MediaManager.cpp#1601
> >
> > OK. Do you mean that we can write a help checker function, ex.
> > HwcComposer2D::Get(), to check the object status and creation, and put the
> > main thread check in this checker function? Therefore,
> > HwcComposer2D::GetInstance() could be simpler.
>
> Sorry, for confusion. I just said to add a code like the following. And
>
> > NS_ASSERTION(NS_IsMainThread(),
> > #ifdef DEBUG
> > static int timesCreated = 0;
> > timesCreated++;
> > MOZ_ASSERT(timesCreated == 1);
> >#endif
>
> And it seems better to handle nsWindow::~nsWindow() case. To handle it, it
> seems better that the nsWindow holds a reference to HwcComposer2D.
> https://dxr.mozilla.org/mozilla-central/source/widget/gonk/nsWindow.cpp#87
Good. Thanks for your advice. I will fix it soon.
Updated•9 years ago
|
Attachment #8617790 -
Flags: review?(sotaro.ikeda.g)
Comment hidden (obsolete) |
Assignee | ||
Comment 17•9 years ago
|
||
Call ClearOnShutdown while creaing HwcComposer2D object.
Attachment #8622838 -
Attachment is obsolete: true
Assignee | ||
Comment 18•9 years ago
|
||
Assignee | ||
Updated•9 years ago
|
Attachment #8622842 -
Flags: review?(sotaro.ikeda.g)
Comment 19•9 years ago
|
||
Comment on attachment 8622842 [details] [diff] [review]
ClearOnShutdown for hwcomposer (v6)
Review of attachment 8622842 [details] [diff] [review]:
-----------------------------------------------------------------
Review+ by addressing the comment.
::: widget/gonk/HwcComposer2D.cpp
@@ +169,5 @@
> HwcComposer2D::GetInstance()
> {
> if (!sInstance) {
> + // We should make sure only main thread create HwcComposer2D,
> + // so ClearOnShutdown() can work properly.
Can you add a comment about which code ensures on main thread creation?
Attachment #8622842 -
Flags: review?(sotaro.ikeda.g) → review+
Assignee | ||
Comment 20•9 years ago
|
||
Comment on attachment 8622842 [details] [diff] [review]
ClearOnShutdown for hwcomposer (v6)
Review of attachment 8622842 [details] [diff] [review]:
-----------------------------------------------------------------
::: widget/gonk/HwcComposer2D.cpp
@@ +169,5 @@
> HwcComposer2D::GetInstance()
> {
> if (!sInstance) {
> + // We should make sure only main thread create HwcComposer2D,
> + // so ClearOnShutdown() can work properly.
Actually, I am thinking about this implementation:
if(NS_IsMainThread()) {
// creation
} else {
// post a creation task to main thread
}
By this implementation, we can make sure only main thread can create HwcComposer2D, but I'm not sure the post is necessary here.
Do you have any concern if I use the if-else to check main thread and post creation task? It may be safer than using comments. Thanks.
Comment hidden (typo) |
Assignee | ||
Comment 22•9 years ago
|
||
Call ClearOnShutdown while creaing HwcComposer2D object.
Change the logic. Clear HwcComposer2D only if it is created by the main thread.
Attachment #8625885 -
Attachment is obsolete: true
Assignee | ||
Comment 23•9 years ago
|
||
Comment on attachment 8625886 [details] [diff] [review]
ClearOnShutdown for hwcomposer (v7)
Review of attachment 8625886 [details] [diff] [review]:
-----------------------------------------------------------------
Hi Sotaro,
Sorry, this patch should be reviewed again. In this patch, we call ClearOnShutdown() only if we create HwcComposer2D in the main thread because only main thread can handle this case properly. If anyone changes the logic and use the compositor thread to create HwcComposer2D in the future, we just skip this function. If ClearOnShutdown() can handle objects in other threads in the future, I will remove this check.
Attachment #8625886 -
Flags: review?(sotaro.ikeda.g)
Comment 24•9 years ago
|
||
Comment on attachment 8625886 [details] [diff] [review]
ClearOnShutdown for hwcomposer (v7)
Review of attachment 8625886 [details] [diff] [review]:
-----------------------------------------------------------------
review+ if try server test passes.
Attachment #8625886 -
Flags: review?(sotaro.ikeda.g) → review+
Comment 25•9 years ago
|
||
(In reply to Boris Chiou [:boris] from comment #23)
> Comment on attachment 8625886 [details] [diff] [review]
> ClearOnShutdown for hwcomposer (v7)
>
> Review of attachment 8625886 [details] [diff] [review]:
> -----------------------------------------------------------------
>
> Hi Sotaro,
>
> Sorry, this patch should be reviewed again. In this patch, we call
> ClearOnShutdown() only if we create HwcComposer2D in the main thread because
> only main thread can handle this case properly. If anyone changes the logic
> and use the compositor thread to create HwcComposer2D in the future, we just
> skip this function. If ClearOnShutdown() can handle objects in other threads
> in the future, I will remove this check.
It seems better to be mentioned in the code comment.
Assignee | ||
Comment 26•9 years ago
|
||
(In reply to Sotaro Ikeda [:sotaro] from comment #25)
> (In reply to Boris Chiou [:boris] from comment #23)
> > Comment on attachment 8625886 [details] [diff] [review]
> > ClearOnShutdown for hwcomposer (v7)
> >
> > Review of attachment 8625886 [details] [diff] [review]:
> > -----------------------------------------------------------------
> >
> > Hi Sotaro,
> >
> > Sorry, this patch should be reviewed again. In this patch, we call
> > ClearOnShutdown() only if we create HwcComposer2D in the main thread because
> > only main thread can handle this case properly. If anyone changes the logic
> > and use the compositor thread to create HwcComposer2D in the future, we just
> > skip this function. If ClearOnShutdown() can handle objects in other threads
> > in the future, I will remove this check.
>
> It seems better to be mentioned in the code comment.
OK. I will add this into the patch. Thanks for your review.
Assignee | ||
Comment 27•9 years ago
|
||
Call ClearOnShutdown while creaing HwcComposer2D object.
Attachment #8625886 -
Attachment is obsolete: true
Attachment #8626000 -
Flags: review+
Assignee | ||
Comment 28•9 years ago
|
||
Assignee | ||
Updated•9 years ago
|
Keywords: checkin-needed
Comment 29•9 years ago
|
||
Keywords: checkin-needed
Comment 30•9 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
status-firefox41:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla41
Updated•6 years ago
|
Product: Core → Core Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•