Page 1 of 1

JCEF crash on re-parent in SampleApplication detailed

PostPosted: Wed May 27, 2020 11:24 pm
by chandan
Hi,

We are trying to replace JXBrowser in our application with JCEF. We want to design JCEF in such a way that a single CefBrowser instance will be created and loadUrl API will be used to load different URLs. While trying to do so, the application is crashing after CefApp.getInstance().dispose() during System.exit(0). I am able to replicate the same issue in the Sample application detailed example. Following are my environment details and reproduction steps:

1. Offscreen rendering disabled
Using:
JCEF Version = 81.2.24.251
CEF Version = 81.2.24
Chromium Version = 81.0.4044.113
2. Java version used is 1.8.0_201-b09 and OS is Windows 7 x64 bit
3. Open the Detailed example and go to Tests--> Reparent. Clieck on reparent several times then close the reparent window followed by the main window.
4. The JVM crashes at the time of exit. We are facing the same issue when used in our application also.
5. Surprisingly, there's no issue when I use Java 1.8.0_101 or older versions, but our requirement is Java 1.8.0_201-b09
6. I have observed that the issue occurs whenever there's a call to BrowserFrame.onAfterParentChanged

We are stuck at this point. Any help will be much appreciated. Thanks in advance.

When I debugged with debug symbols I have found the following stacktrace.

[Inline Frame] jcef.dll!JNIEnv_::EnsureLocalCapacity(long capacity) Line 862 C++
jcef.dll!ScopedJNIEnv::ScopedJNIEnv(JNIEnv_ * env, long local_capacity) Line 188 C++
[Inline Frame] jcef.dll!ScopedJNIEnv::{ctor}(long) Line 177 C++
jcef.dll!ScopedJNIObjectGlobal::~ScopedJNIObjectGlobal() Line 222 C++
[External Code]
jcef.dll!ClientHandler::Release() Line 79 C++
[Inline Frame] jcef.dll!CefCppToCRefCounted<CefClientCppToC,CefClient,_cef_client_t>::UnderlyingRelease() Line 134 C++
jcef.dll!CefCppToCRefCounted<CefClientCppToC,CefClient,_cef_client_t>::Release() Line 84 C++
jcef.dll!CefCppToCRefCounted<CefClientCppToC,CefClient,_cef_client_t>::struct_release(_cef_base_ref_counted_t * base) Line 165 C++
[External Code]
[Inline Frame] libcef.dll!scoped_refptr<CefClient>::Release(CefClient * ptr) Line 322 C++
[Inline Frame] libcef.dll!scoped_refptr<CefClient>::~scoped_refptr() Line 224 C++
libcef.dll!CefBrowserHostImpl::~CefBrowserHostImpl() Line 570 C++
[External Code]
[Inline Frame] libcef.dll!CefCppToCRefCounted<CefBrowserCppToC,CefBrowser,_cef_browser_t>::UnderlyingRelease() Line 134 C++
libcef.dll!CefCppToCRefCounted<CefBrowserCppToC,CefBrowser,_cef_browser_t>::Release() Line 84 C++
libcef.dll!CefCppToCRefCounted<CefAuthCallbackCppToC,CefAuthCallback,_cef_auth_callback_t>::struct_release(_cef_base_ref_counted_t * base) Line 165 C++
[Inline Frame] jcef.dll!CefCToCppRefCounted<CefBrowserCToCpp,CefBrowser,_cef_browser_t>::UnderlyingRelease() Line 76 C++
jcef.dll!CefCToCppRefCounted<CefBrowserCToCpp,CefBrowser,_cef_browser_t>::Release() Line 154 C++
[External Code]
[Inline Frame] jcef.dll!_execute_onexit_table::__l22::<lambda>() Line 196 C++
jcef.dll!__crt_seh_guarded_call<int>::operator()<void <lambda>(void),int <lambda>(void) & __ptr64,void <lambda>(void) >(__acrt_lock_and_call::__l3::void <lambda>(void) && setup, _execute_onexit_table::__l22::int <lambda>(void) & action, __acrt_lock_and_call::__l4::void <lambda>(void) && cleanup) Line 199 C++
[Inline Frame] jcef.dll!__acrt_lock_and_call(const __acrt_lock_id) Line 881 C++
jcef.dll!_execute_onexit_table(_onexit_table_t * table) Line 222 C++
jcef.dll!common_exit(const int return_code, const _crt_exit_cleanup_mode cleanup_mode, const _crt_exit_return_mode return_mode) Line 215 C++
[External Code]

this->jenv_->**functions** was nullptr.

#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000007fec50fa52c, pid=19404, tid=0x000000000000372c
#
# JRE version: Java(TM) SE Runtime Environment (8.0_201-b09) (build 1.8.0_201-b09)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.201-b09 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C [jcef.dll+0x4a52c] ScopedJNIEnv::ScopedJNIEnv+0x5c
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# F:\temp\Java-CEF\25052020\src\hs_err_pid19404.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp

Re: JCEF crash on re-parent in SampleApplication detailed

PostPosted: Thu May 28, 2020 10:52 am
by magreenblatt
Please add a bug. Perhaps the new JVM version has changed the timing of Java object dispose() calls.

Re: JCEF crash on re-parent in SampleApplication detailed

PostPosted: Thu May 28, 2020 10:56 am
by magreenblatt
Are you waiting for the CefAppHandler.stateHasChanged call with state TERMINATED before calling System.exit(0)?

Re: JCEF crash on re-parent in SampleApplication detailed

PostPosted: Thu May 28, 2020 11:36 am
by chandan
Thank you for the quick response.

Yes - I am waiting in CefAppHandler.stateHasChanged(). If cef state is TERMINATED, then only I am calling System.exit(). The same has also been done in Detailed Sample Application Example.

Would you please let me know how to raise a bug for the same?

Re: JCEF crash on re-parent in SampleApplication detailed

PostPosted: Thu May 28, 2020 12:16 pm
by magreenblatt
You can report a bug here.

Re: JCEF crash on re-parent in SampleApplication detailed

PostPosted: Fri May 29, 2020 7:43 am
by chandan
Thank you.

A bug (Issue #369) has been raised for the same:

https://bitbucket.org/chromiumembedded/ ... -parent-in