Initialization crash because of synchronization issues

Having problems with building or using the JCEF Java binding? Ask your questions here.

Initialization crash because of synchronization issues

Postby Phylanx » Fri May 19, 2017 3:01 am

Hi!

One of our usecases using JCEF is to preview/print/... PDFs stored in our documentation management (we use version 3.2704, 32 bit jdk & jcef/chromium, normal window mode).
Now we got some sporadic JVM Crashes reported by our customers.

I could reproduce the problem inhouse with debugging DLLs/PDBs and with an attached Visual Studio.
The resulting hs_err file is attached (java_error19096.log).
In short the stack is the following:

Code: Select all
Stack: [0x493e0000,0x49430000], sp=0x4942eafc, free space=314k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [jcef.dll+0x371e4] GetHwndOfCanvas+0x44
C [jcef.dll+0x38d7] `anonymous namespace'::create+0x187
C [jcef.dll+0x3fd7] Java_org_cef_browser_CefBrowser_1N_N_1CreateBrowser+0x27
j org.cef.browser.CefBrowser_N.N_CreateBrowser(Lorg/cef/handler/CefClientHandler;JLjava/lang/String;ZLjava/awt/Component;Lorg/cef/browser/CefRequestContext;)Z+0
j org.cef.browser.CefBrowser_N.createBrowser(Lorg/cef/handler/CefClientHandler;JLjava/lang/String;ZLjava/awt/Component;Lorg/cef/browser/CefRequestContext;)V+30
j org.cef.browser.CefBrowserWr.createUIIfRequired()V+101
j org.cef.browser.CefBrowserWr.access$000(Lorg/cef/browser/CefBrowserWr;)V+1
j org.cef.browser.CefBrowserWr$1$1.run()V+7
j java.awt.event.InvocationEvent.dispatch()V+47
j java.awt.EventQueue.dispatchEventImpl(Ljava/awt/AWTEvent;Ljava/lang/Object;)V+21
J 5543 C1 java.awt.EventQueue$3.run()Ljava/lang/Void; (60 bytes) @ 0x034438e8 [0x03443880+0x68]
J 5542 C1 java.awt.EventQueue$3.run()Ljava/lang/Object; (5 bytes) @ 0x03443668 [0x03443640+0x28]
v ~StubRoutines::call_stub
.......
........
.........


In the GetHwndOfCanvas Method the assertion in line jni_util_win.cpp:29 happens:
Code: Select all
  assert((lock & JAWT_LOCK_ERROR) == 0);


As far as I understand it now, following happens:
Our preview is shown in a split pane on the right side of a pure java document explorer.
When clicking on a PDF, on the lower split pane chromium is initialized and the PDF is loaded, which works fine.
If the user clicks fast through the PDFs, mutliple browsers are initialized/deinitialized/initialized/deinitialized/...
deinitialize is always called AFTER initialize, so that can't happen.
What I think now is, that after initializing chromium and adding it to the split pane, the CefBrowserWr.delayedUpdate_ is executed delayed with SwingUtilities.invokeLater.
Before executing that, the termination might be called and Chromium is terminated, the delayedUpdate still in Queue.
Afterwards, the delayedUpdate might want to lock the canvas and therefore crash because of the assertion.

I already know that initializing Chromium is not finished after the CefApp is initialized, CefClient and CefBrowser are created.
In our automatic tests i wrote code checking if our javaScript messaging mechanism works. For that I had to add delays to prevent crashes.
Is there a possibility to check if chromium has finally fully deployed so that I can let the user interaction be blocked until that happened?

Thanks for your help in advance, it is greatly appreciated!
Johann
Attachments
java_error19096.log
(35.01 KiB) Downloaded 566 times
Phylanx
Expert
 
Posts: 201
Joined: Thu Aug 11, 2016 8:17 am

Re: Initialization crash because of synchronization issues

Postby Phylanx » Fri May 19, 2017 8:13 am

Some further research showed me that I'm right with my guess.
This is what happens normally:
1. browser is initialized
2. createUIIfRequired of browser is called
3. browser is closed

This happens in my crashes:
1. browser is initialized
2. browser is closed
3. createUIIfRequired of browser is called

I guess this is a timing problem of our code, so I'll have a look for a solution, but it would be nice if JCEF would throw something like an exception instead of crashing the whole JVM down...
Phylanx
Expert
 
Posts: 201
Joined: Thu Aug 11, 2016 8:17 am


Return to JCEF Forum

Who is online

Users browsing this forum: No registered users and 20 guests