Page 1 of 1

using JCEF on WIN32

PostPosted: Mon Jul 17, 2017 11:16 pm
by Leifstart
Hi,
I have building a win32 JCEF project and tring to test the 'tests.detailed.MainFrame.java' in eclipse.
There was a problems occurred.
when I click the abort before the current website has been loaded,an exception will be occurred.
In function onLoadError,the "errorCode" is null,and the "errorText" gets the value of errorCode,
the "failedUrl" gets the value of "errorText".
Code: Select all
             public void onLoadError(CefBrowser browser, int frameIdentifer,
                    ErrorCode errorCode,
                    String errorText, String failedUrl)
             {
                if (errorCode != ErrorCode.ERR_NONE && errorCode != ErrorCode.ERR_ABORTED)
                {
                    errorMsg_ = "<html><head>";
                    errorMsg_ += "<title>Error while loading</title>";
                    errorMsg_ += "</head><body>";
                    errorMsg_ += "<h1>" + errorCode + "</h1>";
                    errorMsg_ += "<h3>Failed to load " + failedUrl + "</h3>";
                    String string = (errorText == null ? "" : errorText);
                    errorMsg_ += "<p>" + string + "</p>";
                    errorMsg_ += "</body></html>";
                    browser.stopLoad();
                }
            }

The console is:
Code: Select all
java.lang.NullPointerException
   at java.lang.String.length(Unknown Source)
   at java.lang.AbstractStringBuilder.append(Unknown Source)
   at java.lang.StringBuilder.append(Unknown Source)
   at tests.detailed.MainFrame32Detailed$3.onLoadError(MainFrame32Detailed.java:193)
   at org.cef.CefClient.onLoadError(CefClient.java:638)


It didn't occurred in win64 project.How to deal with it?

Thanks in advance,
Leif

Re: using JCEF on WIN32

PostPosted: Mon Jul 24, 2017 3:36 am
by Phylanx
Hi!

We had exactly the same problem, see https://bitbucket.org/chromiumembedded/ ... t-types-in
An issue is planned with lowest prio in our input Queue to have a look on the JCEF binaries to find the problem, but it is not sure that we get the time to do that.

Our fix was to make a dirty dirty type check with instanceof and if the problem is seen, then switch the two parameters.
See this code:
Code: Select all
            // This is a hack, it seems P_errorCode and Ps_errorText are reversed!
            // https://bitbucket.org/chromiumembedded/java-cef/issues/235/wrong-object-types-in
            if (ErrorCode.class.isAssignableFrom(Ps_errorText.getClass()))
            {
                Object F_o = Ps_errorText;
                F_errorCode = (ErrorCode)F_o;
                Fs_errorText = "";
            }
            else
            {
                F_errorCode = P_errorCode;
                Fs_errorText = Ps_errorText;
            }


Hope that helps.

By the way, which version are you using?
Is this still a problem in the newest JCEF versions?