New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 723699 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: May 2017
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Bug

Blocking:
issue 592556



Sign in to add a comment

[JNI crashes] Properly throw Java Exceptions from android_webview::AwContentsClientBridge::RunBeforeUnloadDialog

Project Member Reported by gsennton@chromium.org, May 17 2017

Issue description

This callback is very similar to the RunJavaScriptDialog one (but with a slightly different call stack).
If we can solve the RunJavaScriptDialog bug by posting the Java-callback back to the current thread (https://codereview.chromium.org/2886963003/) we can probably do so with this callback as well.


debugger_posix.cc:221 )	base::debug::BreakDebugger()
jni_android.cc:243 )	base::android::CheckException(_JNIEnv*)
jni_generator_helper.h:42 )	android_webview::AwContentsClientBridge::RunBeforeUnloadDialog(...)
aw_javascript_dialog_manager.cc:48 )	android_webview::AwJavaScriptDialogManager::RunBeforeUnloadDialog(...)
web_contents_impl.cc:4228 )	content::WebContentsImpl::RunBeforeUnloadConfirm(content::RenderFrameHost*, bool, IPC::Message*)
render_frame_host_impl.cc:1704 )	content::RenderFrameHostImpl::OnRunBeforeUnloadConfirm(GURL const&, bool, IPC::Message*)
tuple.h:131 )	content::RenderFrameHostImpl::OnMessageReceived(IPC::Message const&)
render_process_host_impl.cc:2081 )	content::RenderProcessHostImpl::OnMessageReceived(IPC::Message const&)
ipc_channel_proxy.cc:329 )	IPC::ChannelProxy::Context::OnDispatchMessage(IPC::Message const&)
ipc_sync_channel.cc:184 )	IPC::SyncChannel::ReceivedSyncMsgQueue::DispatchMessages(IPC::SyncChannel::SyncContext*)
bind_internal.h:214 )	Run
callback.h:85 )	mojo::Watcher::OnHandleReady(unsigned int)
bind_internal.h:214 )	Run
callback.h:68 )	base::debug::TaskAnnotator::RunTask(char const*, base::PendingTask*)
message_loop.cc:423 )	base::MessageLoop::RunTask(base::PendingTask*)
message_loop.cc:434 )	base::MessageLoop::DeferOrRunPendingTask(base::PendingTask)
message_loop.cc:527 )	base::MessageLoop::DoWork()
message_pump_android.cc:44 )	Java_org_chromium_base_SystemMessageHandler_nativeDoRunLoopOnce


This crash accounts for less than 1.5% of JNI crashes on 58.
 
Project Member

Comment 1 by bugdroid1@chromium.org, May 18 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/e49ac49943ad77f452e6a586612b2cfcae8d63ff

commit e49ac49943ad77f452e6a586612b2cfcae8d63ff
Author: gsennton <gsennton@chromium.org>
Date: Thu May 18 20:15:18 2017

[Android WebView] Propagate Java exceptions from handleJsBeforeUnload.

WebView applications can throw run-time exceptions within
WebView-callbacks. When such an exception is thrown from either
onJsBeforeUnload, it is not correctly propagated to Android's feedback
mechanism. This is because that callbacks is called through JNI, and the
default way (in Chromium) of handling Java exceptions thrown on the
Java-side of JNI calls is to print the stack trace for the current
exception to the logcat when the JNI call returns to native, and then
intentionally crash in native.

With this CL we avoid the problem of propagating a Java exception back
through JNI and the native stack by posting the WebView-callback (which
can cause the Java exception) as a new task to the current Java Handler.
In that way any Java exception thrown inside the WebView-callback can be
propagated directly up to the Android framework's
UncaughtExceptionHandler which then properly reports the Exception
through the framework's crash reporting mechanism.

BUG= 723699 

Review-Url: https://codereview.chromium.org/2887173004
Cr-Commit-Position: refs/heads/master@{#472911}

[modify] https://crrev.com/e49ac49943ad77f452e6a586612b2cfcae8d63ff/android_webview/java/src/org/chromium/android_webview/AwContentsClientBridge.java

Status: Fixed (was: Assigned)

Sign in to add a comment