Closed Bug 840721 Opened 11 years ago Closed 11 years ago

AsyncPanZoomController needs to run on a thread with a MessageLoop

Categories

(Core :: Graphics: Layers, defect)

All
Android
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla22

People

(Reporter: kats, Assigned: kats)

References

Details

Attachments

(1 file)

I'm not sure if this is the right component but it looks like the APZC bugs are filed here.

I have some WIP patches at https://github.com/staktrace/mozilla-central/commits/pzc that try to use the APZC in Fennec. Once I got events flowing from Java to APZC (on the Java UI thread), I got this crash:

(gdb) bt
#0  0x400c1598 in ?? () from /Users/kats/android/jdb/moz-gdb/lib/01466E640801401C/system/lib/libc.so
#1  0x68e1c6d4 in LockImpl::Lock (this=0xc4) at /Users/kats/zspace/mozilla-git/ipc/chromium/src/base/lock_impl_posix.cc:41
#2  0x689b0714 in Lock::Acquire (this=0xc4) at /Users/kats/zspace/mozilla-git/ipc/chromium/src/base/lock.h:16
#3  0x689b074e in AutoLock::AutoLock (this=0xbe9e1f30, lock=...) at /Users/kats/zspace/mozilla-git/ipc/chromium/src/base/lock.h:43
#4  0x68de424c in MessageLoop::PostTask_Helper (this=0x0, from_here=..., task=0x6652cb60, delay_ms=500, nestable=true) at /Users/kats/zspace/mozilla-git/ipc/chromium/src/base/message_loop.cc:295
#5  0x68de40a8 in MessageLoop::PostDelayedTask (this=0x0, from_here=..., task=0x6652cb60, delay_ms=500) at /Users/kats/zspace/mozilla-git/ipc/chromium/src/base/message_loop.cc:253
#6  0x68ecfb64 in mozilla::layers::GestureEventListener::HandleInputEvent (this=0x664fb880, aEvent=...) at /Users/kats/zspace/mozilla-git/gfx/layers/ipc/GestureEventListener.cpp:94
#7  0x68ec263e in mozilla::layers::AsyncPanZoomController::HandleInputEvent (this=0x664d5800, aEvent=...) at /Users/kats/zspace/mozilla-git/gfx/layers/ipc/AsyncPanZoomController.cpp:326
#8  0x68ec25ca in mozilla::layers::AsyncPanZoomController::ReceiveInputEvent (this=0x664d5800, aEvent=...) at /Users/kats/zspace/mozilla-git/gfx/layers/ipc/AsyncPanZoomController.cpp:319
#9  0x68874708 in Java_org_mozilla_gecko_gfx_NativePanZoomController_handleTouchEvent (env=0x41fb0828, instance=0x8b600021, event=0x93f00025)
    at /Users/kats/zspace/mozilla-git/widget/android/AndroidJNI.cpp:936
#10 0x593e7812 in Java_org_mozilla_gecko_gfx_NativePanZoomController_handleTouchEvent (arg0=0x41fb0828, arg1=0x8b600021, arg2=0x93f00025)
    at /Users/kats/zspace/mozilla-git/mozglue/android/jni-stubs.inc:412
#11 0x407e1294 in dvmPlatformInvoke () from /Users/kats/android/jdb/moz-gdb/lib/01466E640801401C/system/lib/libdvm.so
#12 0x40810414 in dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*) () from /Users/kats/android/jdb/moz-gdb/lib/01466E640801401C/system/lib/libdvm.so
#13 0x40812570 in dvmResolveNativeMethod(unsigned int const*, JValue*, Method const*, Thread*) () from /Users/kats/android/jdb/moz-gdb/lib/01466E640801401C/system/lib/libdvm.so
#14 0x407ea6a4 in dvmJitToInterpNoChain () from /Users/kats/android/jdb/moz-gdb/lib/01466E640801401C/system/lib/libdvm.so
#15 0x407ea6a4 in dvmJitToInterpNoChain () from /Users/kats/android/jdb/moz-gdb/lib/01466E640801401C/system/lib/libdvm.so
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

The problem seems to be in frame 6, where GestureEventListener::HandleInputEvent calls MessageLoop::current()->PostDelayedTask. MessageLoop::current() returns null because this is the java UI thread, and there is no message loop instance.

Also one of the parameters to the PostDelayedTask is a call to Preferences::GetInt which probably also shouldn't be there as it can only be called on the Gecko main thread.
Component: General → Graphics: Layers
Product: Boot2Gecko → Core
Summary: AsyncPanZoomController assumes the "UI/controller" thread is the gecko main thread → AsyncPanZoomController needs to run on a thread with a MessageLoop
Working on a patch that routes the PostDelayedTask out through GeckoContentController.
Assignee: nobody → bugmail.mozilla
Attached patch PatchSplinter Review
I'll push to try for testing since I don't have a B2G build set up locally any more. This compiles and works for Fennec (with my local implementation of PostDelayedTask).
Attachment #713987 - Flags: review?(jones.chris.g)
Here is a better try push: https://tbpl.mozilla.org/?tree=Try&rev=d44e13e5155a
The one above didn't run any tests because I didn't pick the right platform.
Comment on attachment 713987 [details] [diff] [review]
Patch

Sorry for review lag.

>diff --git a/gfx/layers/ipc/AsyncPanZoomController.cpp b/gfx/layers/ipc/AsyncPanZoomController.cpp

>+void AsyncPanZoomController::PostDelayedTask(Task* task, int delay_ms) {

Nit: |aTask, aDelayMs|

>diff --git a/gfx/layers/ipc/AsyncPanZoomController.h b/gfx/layers/ipc/AsyncPanZoomController.h

>+  void PostDelayedTask(Task* task, int delay_ms);

(Same nit here.)

Looks reasonable to me.  r=me with nits picked.
Attachment #713987 - Flags: review?(jones.chris.g) → review+
https://hg.mozilla.org/mozilla-central/rev/aa7ee3a0eede
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla22
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: