[OSX] libcef trying to load cefclient.pak

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

[OSX] libcef trying to load cefclient.pak

Postby hal9000 » Mon May 02, 2011 2:26 am

Hi, there

First thank you for your great work on cef :-)
I am doing an experiment using cef (r218) within a Java application through JNI. I am not getting very far -- on my first call of CefInitialize() I got a SIGABRT with:
Code: Select all
 
terminate called after throwing an instance of 'std::logic_error'
  what():  basic_string::_S_construct NULL not valid


I fired up GDB found the error is thrown from browser_webkit_glue_mac.mm line no.32
Code: Select all
26 void InitializeDataPak() {
     ...
30   NSString *resource_path =
31         [base::mac::MainAppBundle() pathForResource:@"cefclient" ofType:@"pak"];
32    FilePath resources_pak_path([resource_path fileSystemRepresentation]);
     ...


Because my Java app are not even having a bundle directory, so there are no cefclient.pak to load, thus resource_path is NULL.

If I am not wrong, "cefclient" is the demo application, isn't it? Why the libcef are trying to load a pak file from cefclient's resource directory? Is it safe to remove webkit_glue::InitializeDataPak() call from CefProcessUIThread::PlatformInit ?

Thanks.


-- hal9000
hal9000
Newbie
 
Posts: 1
Joined: Mon May 02, 2011 1:52 am

Re: [OSX] libcef trying to load cefclient.pak

Postby magreenblatt » Mon May 02, 2011 8:25 am

Why the libcef are trying to load a pak file from cefclient's resource directory? Is it safe to remove webkit_glue::InitializeDataPak() call from CefProcessUIThread::PlatformInit ?

On Mac, resources used by Chromium and WebKit must be loaded from somewhere on the file system. This code should probably be changed to allow specification of the resource directory via a CefSettings parameter.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: [OSX] libcef trying to load cefclient.pak

Postby bosko » Tue May 01, 2012 11:05 am

I had the same problem...
when i run java application trough JNI, the cef looks for chrome.pak in "System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin" location and when he dont find it there, he sets resource_path to ""!!!
I did HARCODE on address to look for:
Code: Select all
FilePath GetResourcesPakFilePath(NSString* name, NSString* mac_locale) {
  NSString *resource_path;
  // Some of the helper processes need to be able to fetch resources
  // (chrome_main.cc: SubprocessNeedsResourceBundle()). Fetch the same locale
  // as the already-running browser instead of using what NSBundle might pick
  // based on values at helper launch time.
 
  printf("\n mac_locale is: %s\n", [mac_locale cStringUsingEncoding:NSUTF8StringEncoding]);

//NSBundle* mainBundle = base::mac::MainAppBundle();
// NSString bundlePath = [mainBundle bundlePath];
// bundlePath ="";
  printf ("\n mainAppBundle.bundlePath() is: %s\n", [[base::mac::MainAppBundle() bundlePath] cStringUsingEncoding:NSUTF8StringEncoding]);
  printf ("\n mainAppBundle.resourcePath() is: %s\n", [[base::mac::MainAppBundle() resourcePath] cStringUsingEncoding:NSUTF8StringEncoding]);
  if ([mac_locale length]) {
    resource_path = [base::mac::MainAppBundle() pathForResource:name
                                                        ofType:@"pak"
                                                   inDirectory:@""
                                               forLocalization:mac_locale];
  } else {
    resource_path = [base::mac::MainAppBundle() pathForResource:name
                                                        ofType:@"pak"];
  }
  if (!resource_path)
  {
 resource_path=@"/Users/tralala/Desktop/eclipseProjects/Cef_JNI/Resources/";
 
  if ([mac_locale length]) {
  resource_path=[resource_path stringByAppendingString: mac_locale ];
  resource_path=[resource_path stringByAppendingString: @".lproj/" ];
 
  }
 
  resource_path=[resource_path stringByAppendingString: name ];
  resource_path=[resource_path stringByAppendingString: @".pak" ];
 
  printf ("\n resource_path is: %s\n", [ resource_path cStringUsingEncoding:NSUTF8StringEncoding]);
 
 
  return FilePath([resource_path fileSystemRepresentation]);
  //return FilePath();
  }
printf("\n Resource path is: %s\n", [resource_path cStringUsingEncoding:NSUTF8StringEncoding]);

  return FilePath([resource_path fileSystemRepresentation]);
}

}  // namespace



Hope it will help someone...
bosko
Techie
 
Posts: 28
Joined: Tue May 01, 2012 10:47 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 210 guests

cron