If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

AsyncPanZoomController needs to run on a thread with a MessageLoop

RESOLVED FIXED in mozilla22

Status

()

Core
Graphics: Layers
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: kats, Assigned: kats)

Tracking

unspecified
mozilla22
All
Android
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

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
Created attachment 713987 [details] [diff] [review]
Patch

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)
https://tbpl.mozilla.org/?tree=Try&rev=09086abc7c7a
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/integration/mozilla-inbound/rev/aa7ee3a0eede
https://hg.mozilla.org/mozilla-central/rev/aa7ee3a0eede
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla22
You need to log in before you can comment on or make changes to this bug.