I've found that XWalkView.stopLoading() doesn't prevent InterceptedRequestData.getData().read() from being executed at a bad time. Use case:1) user navigates to a webpage with a lot of image URLs2) each image triggers a callback to XWalkResourceClient.shouldInterceptLoadRequest()3) my app immediately returns a WebResourceResponse object containing my derived InputStream object4) my overridden InputStream.read() function shows in logcat when read() is called5) my logcat shows that after calling XWalkView.stopLoading() and getNavigationHistory().navigate(XWalkNavigationHistory.Direction.BACKWARD, 1) some InterceptedRequestData.getData().read() are still being called and the result is a JNI exception. How is it possible to ensure that old InterceptedRequestData are discarded when the user clicks "Back" from a webpage that is currently being loaded ?
From: [email protected] To: [email protected]; [email protected] Subject: RE: [Crosswalk-help] JNI exception in XWalkView Date: Tue, 12 May 2015 02:22:05 +0000 How about remove “mWebView.stopLoading();” ? If this still happens, could you please help to provide a whole test case(including layout/activity/) for this? From: Alexander Biemann [mailto:[email protected]] Sent: Tuesday, May 12, 2015 9:51 AM To: Xu, Xing; [email protected] Subject: RE: [Crosswalk-help] JNI exception in XWalkView Hi, There is no use of WebView, however, some names of objects contain "webview" because I've migrated the code from WebView. I have a hunch where how this problem manifests... it seems that when the back button (in our app, not the Android back button) is pressed quickly after loading a page, it contributes toward the exception. The exception shows up about 3 page loads later. Below is the relevant code... My worry is that calling .navigate() so soon after stopLoading() is a problem. Can you confirm ? onClick handler for the button : @Override public void onClick(View view) { if (view == mBackButton) { // only allow back button 1 second after an article click event long lElapsedTime = System.currentTimeMillis() - mContentHubWebViewClient.getClickEventTimestamp(); if (lElapsedTime > 1000 ) { if (mWebView.canGoBack()) { mWebView.post(new Runnable() { @Override public void run() { mWebView.stopLoading(); mWebView.getNavigationHistory().navigate(XWalkNavigationHistory.Direction.BACKWARD, 1);//TODO is this a problem ?? } }); } else { mParentActivity.finish(); } } } if (view == mCloseButton) { mParentActivity.finish(); } } Page loading, done using optimized asynchronous approach : @Override public WebResourceResponse shouldInterceptLoadRequest(XWalkView view, String url) { //data is fetched from database where the url is a custom scheme and loads the necessary JSON data Map <String, String> map = ZBi.Gson_Parser.fromJson(s, type); String externalUrl = map.get(EXTERNAL_ASSET_URL); WebResourceResponse wrr = new WebResourceResponse(contentItem.getMimeType(), "UTF-8", new AsyncByteArrayInputStream(externalUrl)); responseToReturn = wrr; return responseToReturn; } This class does the asynchronous magic that we require so that images are loaded in parallel, not in sequence static public class AsyncByteArrayInputStream extends ByteArrayInputStream { // member variables ByteArrayInputStream internalByteArrayInputStream = null; OkHttpClient client; String mURL; public AsyncByteArrayInputStream(String url) { super(new byte[1]); mURL = url; client = new OkHttpClient(); } @Override public synchronized int read(byte[] buffer, int byteOffset, int byteCount) { if (internalByteArrayInputStream == null) { Request request = new Request.Builder() .url(mURL) .build(); try { Response response = client.newCall(request).execute();// async internalByteArrayInputStream = new ByteArrayInputStream(response.body().bytes()); } catch (Exception ex) { } } return internalByteArrayInputStream.read(buffer, byteOffset, byteCount); } } From: [email protected] To: [email protected]; [email protected] Subject: RE: [Crosswalk-help] JNI exception in XWalkView Date: Fri, 8 May 2015 06:35:09 +0000 Hi, Could you please share the XWalkView related java code? I am afraid you are using android webview instead of XWalkView. From: Crosswalk-help [mailto:[email protected]] On Behalf Of Alexander Biemann Sent: Friday, May 8, 2015 3:04 AM To: [email protected] Subject: [Crosswalk-help] JNI exception in XWalkView How it happened : Navigating a lot through a website - maybe 3 mins of clicking on links and letting the page load before clicking the next link Crosswalk version used : org.xwalk:xwalk_core_library:12.41.296.9 Device : LG G3 running Android 5.0 Logcat : 05-07 11:48:33.278 20751-22317/com.zumobi.android.zbimsampleapp A/art﹕ art/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: can't call java.io.InputStream org.xwalk.core.internal.InterceptedRequestData.getData() on null object 05-07 11:48:33.278 20751-22317/com.zumobi.android.zbimsampleapp A/art﹕ art/runtime/check_jni.cc:65] in call to CallObjectMethodV 05-07 11:48:33.278 20751-22317/com.zumobi.android.zbimsampleapp A/art﹕ art/runtime/check_jni.cc:65] "Thread-18890" prio=5 tid=47 Runnable 05-07 11:48:33.278 20751-22317/com.zumobi.android.zbimsampleapp A/art﹕ art/runtime/check_jni.cc:65] | group="main" sCount=0 dsCount=0 obj=0x13c4e0e0 self=0x99c96000 05-07 11:48:33.278 20751-22317/com.zumobi.android.zbimsampleapp A/art﹕ art/runtime/check_jni.cc:65] | sysTid=22317 nice=0 cgrp=apps sched=0/0 handle=0x99ca3f80 05-07 11:48:33.278 20751-22317/com.zumobi.android.zbimsampleapp A/art﹕ art/runtime/check_jni.cc:65] | state=R schedstat=( 0 0 0 ) utm=8 stm=6 core=3 HZ=100 05-07 11:48:33.278 20751-22317/com.zumobi.android.zbimsampleapp A/art﹕ art/runtime/check_jni.cc:65] | stack=0x98e9e000-0x98ea0000 stackSize=1012KB 05-07 11:48:33.278 20751-22317/com.zumobi.android.zbimsampleapp A/art﹕ art/runtime/check_jni.cc:65] | held mutexes= "mutator lock"(shared held) 05-07 11:48:33.278 20751-22317/com.zumobi.android.zbimsampleapp A/art﹕ art/runtime/check_jni.cc:65] native: #00 pc 000045b4 /system/lib/libbacktrace_libc++.so (UnwindCurrent::Unwind(unsigned int, ucontext*)+23) 05-07 11:48:33.278 20751-22317/com.zumobi.android.zbimsampleapp A/art﹕ art/runtime/check_jni.cc:65] native: #01 pc 00002e1d /system/lib/libbacktrace_libc++.so (Backtrace::Unwind(unsigned int, ucontext*)+8) 05-07 11:48:33.278 20751-22317/com.zumobi.android.zbimsampleapp A/art﹕ art/runtime/check_jni.cc:65] native: #02 pc 002524d5 /system/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, char const*, art::mirror::ArtMethod*)+84) 05-07 11:48:33.278 20751-22317/com.zumobi.android.zbimsampleapp A/art﹕ art/runtime/check_jni.cc:65] native: #03 pc 00235fb3 /system/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const+162) 05-07 11:48:33.278 20751-22317/com.zumobi.android.zbimsampleapp A/art﹕ art/runtime/check_jni.cc:65] native: #04 pc 000b0865 /system/lib/libart.so (art::JniAbort(char const*, char const*)+620) 05-07 11:48:33.278 20751-22317/com.zumobi.android.zbimsampleapp A/art﹕ art/runtime/check_jni.cc:65] native: #05 pc 000b0f95 /system/lib/libart.so (art::JniAbortF(char const*, char const*, ...)+68) 05-07 11:48:33.278 20751-22317/com.zumobi.android.zbimsampleapp A/art﹕ art/runtime/check_jni.cc:65] native: #06 pc 000b12af /system/lib/libart.so (art::ScopedCheck::CheckVirtualMethod(_jobject*, _jmethodID*)+438) 05-07 11:48:33.278 20751-22317/com.zumobi.android.zbimsampleapp A/art﹕ art/runtime/check_jni.cc:65] native: #07 pc 000b906b /system/lib/libart.so (art::CheckJNI::CallObjectMethodV(_JNIEnv*, _jobject*, _jmethodID*, std::__va_list)+82) 05-07 11:48:33.278 20751-22317/com.zumobi.android.zbimsampleapp A/art﹕ art/runtime/check_jni.cc:65] native: #08 pc 001d33a1 /data/app/com.zumobi.android.zbimsampleapp-2/lib/arm/libxwalkcore.so (???) 05-07 11:48:33.278 20751-22317/com.zumobi.android.zbimsampleapp A/art﹕ art/runtime/check_jni.cc:65] (no managed stack frames) 05-07 11:48:33.278 20751-22317/com.zumobi.android.zbimsampleapp A/art﹕ art/runtime/check_jni.cc:65] 05-07 11:48:35.362 20751-22317/com.zumobi.android.zbimsampleapp A/art﹕ art/runtime/runtime.cc:284] Runtime aborting... 05-07 11:48:35.362 20751-22317/com.zumobi.android.zbimsampleapp A/art﹕ art/runtime/runtime.cc:284] Aborting thread: 05-07 11:48:35.362 20751-22317/com.zumobi.android.zbimsampleapp A/art﹕ art/runtime/runtime.cc:284] "Thread-18890" prio=5 tid=47 Native 05-07 11:48:35.362 20751-22317/com.zumobi.android.zbimsampleapp A/art﹕ art/runtime/runtime.cc:284] | group="" sCount=0 dsCount=0 obj=0x13c4e0e0 self=0x99c96000
_______________________________________________ Crosswalk-help mailing list [email protected] https://lists.crosswalk-project.org/mailman/listinfo/crosswalk-help
