Can't create client

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

Can't create client

Postby edominic » Mon May 04, 2015 2:19 am

Another problem here :/
In my test project, it works fine. But now I am trying to integrate JCEF in our main application.
I don't get any errors.

Here is an example code:
Code: Select all
CefApp xyzApp = CefApp.getInstance(); // works fine
CefClient xyzClient = xyzApp.createClient(); // hangs in this function


The same way it works in my test application (its exact same code).
If I debug through this code I see, that the application "hangs" at:
Code: Select all
            public void start() {
                if(!this.isAlive() && super.getState() == State.NEW) {
                    CefApp.this.lock.lock();

                    try {
                        if(SwingUtilities.isEventDispatchThread()) {
                            CefApp.this.initialize();
                        }

                        super.start();
                        CefApp.this.cefInitialized.awaitUninterruptibly(); // <-- Here it hangs/waits
                    } finally {
                        CefApp.this.lock.unlock();
                    }
                }

            }
in CefApp in JCEF.jar

I copied the content of jcef_example_app to ourprojectpath/Contents and passed java.library.path to it:
Code: Select all
-Djava.library.path="/workspace/xyz-client/Contents/Java/:/workspace/xyz-client/Contents/Frameworks/Chromium Embedded Framework.framework/Libraries"
(IntelliJ VM-Options)
and tried to add resources-argument like mentioned http://www.magpcss.org/ceforum/viewtopic.php?f=17&t=11884.

CefSettings:
Code: Select all
      CefSettings cefSettings = new CefSettings();
      cefSettings.locales_dir_path = "/workspace/xyz-client/Contents/Frameworks/Chromium Embedded Framework.framework/Resources/";
      cefSettings.resources_dir_path = "/workspace/xyz-client/Contents/Frameworks/Chromium Embedded Framework.framework/Resources/";
      cefSettings.log_severity = CefSettings.LogSeverity.LOGSEVERITY_VERBOSE;
      cefSettings.log_file = "/workspace/xyz-client/jcef.log";

      CefApp = CefApp.getInstance(cefSettings);


Some hints for me? Is there a way to get some logs of CEF?

Here some output of console while runtime (last few lines):
Code: Select all
[Dynamic-linking native method sun.nio.fs.UnixNativeDispatcher.init ... JNI]
[Dynamic-linking native method sun.nio.fs.UnixNativeDispatcher.getcwd ... JNI]
Checked JNI functions are being used to validate JNI usage
Checked JNI functions are being used to validate JNI usage
Checked JNI functions are being used to validate JNI usage
initialize on Thread[AWT-EventQueue-0,6,main] with library path /workspace/xyz-client/Contents/Java/
[Dynamic-linking native method org.cef.CefApp.N_Initialize ... JNI]


Edit:
Some information...
MacOsX10.10 with IntelliJ 14 and Java8
(I read about, to set working directory to example jcef app bundle, but its no possibility for me (and I can't test it)

After playing around with it, I got following error:
Code: Select all
FATAL ERROR in native method: JNI string operation received a non-string
   at org.cef.CefApp.N_Initialize(Native Method)
   at org.cef.CefApp.access$1100(CefApp.java:25)
   at org.cef.CefApp$5.run(CefApp.java:509)
   at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:301)
   at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:749)
   at java.awt.EventQueue.access$500(EventQueue.java:97)
   at java.awt.EventQueue$3.run(EventQueue.java:702)
   at java.awt.EventQueue$3.run(EventQueue.java:696)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
   at java.awt.EventQueue.dispatchEvent(EventQueue.java:719)
   at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
   at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
   at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
   at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)


It crashes in
Code: Select all
CefApp.this.cefInitialized.awaitUninterruptibly();
edominic
Mentor
 
Posts: 82
Joined: Fri Mar 13, 2015 6:46 am

Re: Can't create client

Postby edominic » Tue May 05, 2015 2:08 am

I created another little test project.
My steps:
- I build latest jcef sources
- In project set working directory to /pathtojcef/src/xcodebuild/Debug/jcef_app.app/
- Added external Library/Libraries (/pathtojcef/src/xcodebuild/Debug/jcef_app.app/Contents/Java/)

If I build and run my project it works fine, without any problems.
Then, next steps:
- In project set working directory to /workspace/xyz-client/
- Changed external Library/Libraries to /workspace/xyz-client/Contents/Java/
- Added client settings:
Code: Select all
        CefSettings cefSettings = new CefSettings();
        cefSettings.locales_dir_path = "/workspace/xyz-client/Contents/Frameworks/Chromium Embedded Framework.framework/Resources";
        cefSettings.resources_dir_path = "/workspace/xyz-client/Contents/Frameworks/Chromium Embedded Framework.framework/Resources";
        cefSettings.log_severity = CefSettings.LogSeverity.LOGSEVERITY_VERBOSE;
cefApp_ = CefApp.getInstance(cefSettings);


If I build and run my project, I get following errors:
Code: Select all
[0505/085242:VERBOSE1:pref_proxy_config_tracker_impl.cc(148)] 0x7ff5f2e60840: set chrome proxy config service to 0x7ff5f2c67150
[0505/085242:VERBOSE1:pref_proxy_config_tracker_impl.cc(277)] 0x7ff5f2e60840: Done pushing proxy to UpdateProxyConfig
[0505/085242:ERROR:icu_util.cc(144)] icudtl.dat not found in bundle
[0505/085242:FATAL:content_main_runner.cc(721)] Check failed: base::i18n::InitializeICU().
[0505/085243:ERROR:icu_util.cc(144)] icudtl.dat not found in bundle
[0505/085243:FATAL:content_main_runner.cc(721)] Check failed: base::i18n::InitializeICU().
[0505/085243:VERBOSE1:webrtc_internals.cc(56)] Could not get the download directory.
[0505/085244:WARNING:message_in_transit_queue.cc(18)] Destroying nonempty message queue


The "Contents" directory of xyz-client is exact the same as the "Contents" directory of jcef_app.app

Is this a bug of jcef? I get the same error messages, if I leave CefSettings.

I hope you can help me, because I need this :/ It's important

Edit:
After playing around with settings, here maybe some important information.
Settings1: <-- Works fine
- Working directory in jcef_app.app
- external library (jcef.jar) in jcef_app.app/Contents/Java/
- no additional CefSettings

Settings2: <-- Works fine, too
- Working directory in /workspace/xyz-client/
- external library (jcef.jar) in jcef_app.app/Contents/Java/
- no additional CefSettings

Settings3: <-- Doesn't work
- Working directory in jcef_app.app
- external library (jcef.jar) in /workspace/xyz-client/Contents/Java/
- no additional CefSettings

Settings 4: <-- Doesn't work
- Working directory in /workspace/xyz-client/
- external library (jcef.jar) in /workspace/xyz-client/Contents/Java/
- CefSettings for resource and locale path

Result: Once I don't use Java path in jcef_app.app, Application doesn't work any more.
Again, Contents directories are both exact the same
edominic
Mentor
 
Posts: 82
Joined: Fri Mar 13, 2015 6:46 am

Re: Can't create client

Postby edominic » Tue May 05, 2015 10:07 am

I debugged the native code to the point, where it hangs/waits.

In Java, it is this point:
Code: Select all
CefApp.this.cefInitialized.awaitUninterruptibly();


In native, its this point:
Code: Select all
bool CefInitializeOnMainThread(const CefMainArgs& args,
                               const CefSettings& settings,
                               CefRefPtr<ClientApp> application) {
  SystemStub* stub = [[SystemStub alloc] initWithValues:args
                                               settings:settings
                                            application:application];
  // we're not using waitUntilDone here because we want to return true
  // or false to the caller of this method.
  g_lock_initialize = [[NSCondition alloc] init];
  [g_lock_initialize lock];
  [[CefHandler class] performSelectorOnMainThread:@selector(initialize:)
                                       withObject:stub
                                    waitUntilDone:NO];
  [g_lock_initialize wait];
  [g_lock_initialize unlock];
  [g_lock_initialize release];
  [stub release];
  return g_init_result;
}

It hangs/waits at
Code: Select all
  [g_lock_initialize wait];
and does nothing.
It is in util_mac.mm at line 430.

Any idea?
edominic
Mentor
 
Posts: 82
Joined: Fri Mar 13, 2015 6:46 am

Re: Can't create client

Postby edominic » Wed May 06, 2015 1:02 am

This error:
Code: Select all
FATAL ERROR in native method: JNI string operation received a non-string
   at org.cef.CefApp.N_Initialize(Native Method)
   at org.cef.CefApp.access$1100(CefApp.java:25)
   at org.cef.CefApp$5.run(CefApp.java:509)
   at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:301)
   at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:749)
   at java.awt.EventQueue.access$500(EventQueue.java:97)
   at java.awt.EventQueue$3.run(EventQueue.java:702)
   at java.awt.EventQueue$3.run(EventQueue.java:696)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
   at java.awt.EventQueue.dispatchEvent(EventQueue.java:719)
   at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
   at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
   at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
   at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)


only appears, if flags "-Xcheck:jni" and "-verbose:jni" are set
edominic
Mentor
 
Posts: 82
Joined: Fri Mar 13, 2015 6:46 am

Re: Can't create client

Postby edominic » Wed May 06, 2015 1:36 am

Some additional information about hang/wait problem.

In our application, we're working with multiple processes.
- Main process
- Browser process
- ... some other not namable processes

Browser process is handling jcef.

Main process starts Browser process, browser process ist called with vm option "-XstartOnFirstThread"
The problem is this vm option, if it's set, the application hangs/waits, if this option is not set, it starts (but I have to test our application, if this option is still necessary)
edominic
Mentor
 
Posts: 82
Joined: Fri Mar 13, 2015 6:46 am


Return to JCEF Forum

Who is online

Users browsing this forum: No registered users and 135 guests