pwnall / chromeview

Proof of concept Android WebView implementation based on Chromium code
1.69k stars 434 forks source link

ChromeView very very slow, and I can't even scroll. #39

Closed ghost closed 10 years ago

ghost commented 10 years ago

V8 Engine works properly (WebSocket works)

ChromeView#onTouchEvent is called but I can't scroll.

@Override
public boolean onTouchEvent(final MotionEvent event) {
    final boolean h = super.onTouchEvent(event);
    Util.log(h + "");
    return h;
}

This print true on down and move, but false on up.

cbsol commented 10 years ago

For scrolling simple override the onDraw Methode org.chromium.android_webview.AwContents.java

to:

public void onDraw(Canvas canvas) { if (mNativeAwContents == 0) return; canvas.getClipBounds(mClipBoundsTemporary);

  if (!nativeOnDraw(mNativeAwContents, canvas, canvas.isHardwareAccelerated(),
              mContainerView.getScrollX(), mContainerView.getScrollY(),
              mClipBoundsTemporary.left, mClipBoundsTemporary.top,
              mClipBoundsTemporary.right, mClipBoundsTemporary.bottom )) {
      Log.w(TAG, "nativeOnDraw failed; clearing to background color.");
      int c = mContentViewCore.getBackgroundColor();
      canvas.drawRGB(Color.red(c), Color.green(c), Color.blue(c));
  }

}

ghost commented 10 years ago

Thank yout very much! How did you know that??

The problem was

mScrollOffsetManager.syncScrollOffsetFromOnDraw();

This syncs offset to top.

cbsol commented 10 years ago

The Problem was that the ChromeView Scrolls indeed but it does not update the UI so you cant see the scroll effect.

I was just looking for the onDraw and saw the mistake ;)