Git Product home page Git Product logo

equodev / chromium Goto Github PK

View Code? Open in Web Editor NEW
161.0 161.0 32.0 11.2 MB

Create and render web UIs in Java, SWT, Swing, JavaFX(coming soon), and Eclipse RCP applications.

Home Page: https://www.equo.dev/chromium

License: GNU General Public License v3.0

Java 100.00%
browser cef chromium chromium-embedded-framework chromium-swt chromium-widget desktop-app eclipse eclipse-plugin eclipse-rcp java swing swt swt-browser

chromium's People

Contributors

lonelion avatar mauropuravida avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chromium's Issues

Add a license when installing the P2s

When installing the P2 repositories the license screen contains no license. Have you all considered a license yet and if so when will it be available?

No win32 support?

Hi,

I try to install it in Eclipse win32 but it failed. There;s no problem for Mac OS X.

Thanks

How to stop Chromium process after Eclipse shutdown?

When closing the eclipse, the chromium process (chromium_subp-0700.exe) keeps running.
This prevents the eclipse from being terminated.

I already tried to use the Chromium.shutdown(); method, but it seems to be protected and can't be used.

What's the proper procedure to terminate chromium?

Chromium for SWT is a great thing that I'm sure many people have been waiting for.
I hope you can help me.

thx

A second window is shown on Linux

When the chromium browser is started on Linux, the browser is opened and another grey window as well.
Resizing this window resizes the browser window as well.

See the sample program in issue #34

Running the same code with the swt browser (webkit) only shows the browser window.

Environment
Ubuntu 18.04.1 LTS
com.make.chromium.cef.gtk.linux.x86_64_0.3.0.201807050001
org.eclipse.swt_3.107.0.v20180611-0422
org.eclipse.swt.gtk.linux.x86_64_3.107.0.v20180611-0422
org.eclipse.swt.chromium_0.7.0.201811300653
org.eclipse.swt.chromium.gtk.linux.x86_64_0.7.0.201811300653

Browser function issue

I updated to 0.9 and ran some tests - I am now seeing an issue with a browser function that I've not seen before. I modified an existing unit test to show the problem. I have an existing page that we use for donations withing BiglyBT - it has a callback to a function called 'sendDonationEvent'. Normally two calls are made to it, one to indicate the preferred size of the browser, the second to inform that the page loaded.

If you run the test below the first callback occurs but then second doesn't and the web page subsequently fails to load.

If you remove the new JavascriptCallback(browser, "sendDonationEvent"); then the page loads fine. Something to do with that adding that callback is breaking the browser :(

Place a breakpoint at the final assertTrue(...) call so that you can observe the browser before it gets disposed.

public void test_BrowserFunction_callback () {
	// On webkit1, this test works if ran on it's own. But sometimes in test-suite with other tests it causes jvm crash.
	// culprit seems to be the main_context_iteration() call in shell.setVisible().
	// See Bug 509587.  Solution: Webkit2.
	assumeFalse(webkit1SkipMsg(), isWebkit1);

	AtomicBoolean javaCallbackExecuted = new AtomicBoolean(false);

	class JavascriptCallback extends BrowserFunction { // Note: Local class defined inside method.
		JavascriptCallback(Browser browser, String name) {
			super(browser, name);
		}

		@Override
		public Object function(Object[] arguments) {
			javaCallbackExecuted.set(true);
			return null;
		}
	}	
	new JavascriptCallback(browser, "sendDonationEvent");	

	browser.setUrl( "https://www.biglybt.com/donation/donate.php" );
	
	browser.addProgressListener(callCustomFunctionUponLoad);

	shell.open();
	boolean passed = waitForPassCondition(javaCallbackExecuted::get);
	String message = "Java failed to get a callback from javascript. Test timed out";
	assertTrue(message, passed);
}

New encoding problem with 0.8.1

There is a new problem with the encoding of web pages since 0.8.1, that worked fine with 0.7.
Tested on macOS and Windows, same problem

The html has the correct encoding, but still it gets wrong chars

<?xml version='1.0' encoding='utf-8'?>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <base href="http://bundle/icons/" />
        <meta http-equiv="Content-Style-Type" content="text/css" />
        <meta name='viewport' content='initial-scale=1.0, maximum-scale=1.0' />
        <meta content="http://www.w3.org/1999/xhtml; charset=utf-8" http-equiv="Content-Type" />

image

Unable to draw above the chromium.swt browser

Problem description

We need to draw lines and rectangles above of the browser. It is working for the common swt browser. But the chromium browser always cover the canvas.

The below screenshot is the result of the common browser which is expected. The red dotted rectangle is painted in the above canvas. The browser is setting with an offset of 50,50 to the top left.
image

The below screenshot is the result of the chromium.swt browser. The red dotted rectangle which is painted by the above canvas is not shown at all. But the browser which is under the canvas area cannot get focus(e.g. the link for main page cannot be clicked) so that it is likely the browser is still under the canvas.
image

Steps to recreate

  1. Import the eclipse swt sample as instructed in https://github.com/maketechnology/chromium.swt
  2. Replace the BrowserExample.java with the attached one.
package org.eclipse.swt.examples.browserexample;

import org.eclipse.swt.*;
import org.eclipse.swt.browser.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.chromium.Browser;

import java.util.*;

public class BrowserExample {
	static ResourceBundle resourceBundle = ResourceBundle.getBundle("examples_browser");
	int index;
	boolean busy;
	Image images[];
	Image icon = null;
	boolean title = false;
	Composite parent;
	Browser browser;
	Canvas canvas;
	SWTError error = null;
	Composite _compositeDesignArea;

	
		
	public BrowserExample(Composite parent, boolean top) {
		this.parent = parent;
		try {
			_compositeDesignArea = new Composite( parent, SWT.NULL );
			
			canvas = new Canvas(_compositeDesignArea, SWT.TRANSPARENT);
			canvas.setBounds(0, 0, 400, 400);
			canvas.addListener(SWT.Paint, new Listener() {
				public void handleEvent(Event e) {
					GC gc = e.gc;
					Rectangle rectBounds = new Rectangle( 10, 10, 200, 200 );
					rectBounds.width--;
					rectBounds.height--;

					gc.setForeground( e.widget.getDisplay().getSystemColor(SWT.COLOR_RED) );
					gc.setLineWidth( 2 );
					gc.setLineStyle( SWT.LINE_DOT );
					gc.drawRectangle( rectBounds );
					gc.setLineStyle( SWT.LINE_SOLID );		
				}
			});
			
			Composite _compositeBrowser = new Composite( _compositeDesignArea, SWT.BORDER );
			_compositeBrowser.setLayout( new FillLayout() );
			_compositeBrowser.setBounds( new Rectangle( 50, 50, 2000, 2000 ) );
			browser = new Browser(_compositeBrowser, SWT.TRANSPARENT);
			browser.setBounds(0, 0, 1000, 1000);
		} catch (SWTError e) {
			error = e;
			/* Browser widget could not be instantiated */
			parent.setLayout(new FillLayout());
			Label label = new Label(parent, SWT.CENTER | SWT.WRAP);
			label.setText("BrowserNotCreated");
			parent.layout(true);
			return;
		}
		browser.setData("org.eclipse.swt.examples.browserexample.BrowserApplication", this);		
		browser.setUrl("http://en.wikipedia.org/wiki/Main_Page");
		show(true, null, null, true, true, true, true);		
	}

	/**
	 * Disposes of all resources associated with a particular
	 * instance of the BrowserApplication.
	 */	
	public void dispose() {
		freeResources();
	}
	
	
	public SWTError getError() { return error; }
	
	public Browser getBrowser() { return browser; }
	
	public void setShellDecoration(Image icon, boolean title) {
		this.icon = icon;
		this.title = title;
	}
	
	void show(boolean owned, Point location, Point size, boolean addressBar, boolean menuBar, boolean statusBar, boolean toolBar) {
		final Shell shell = browser.getShell();		
		parent.layout(true);
		shell.open();
	}


	/**
	 * Frees the resources
	 */
	void freeResources() {
		if (images != null) {
			for (int i = 0; i < images.length; ++i) {
				final Image image = images[i];
				if (image != null) image.dispose();
			}
			images = null;
		}
	}
	
	public void focus() {
		if (browser != null) browser.setFocus();
		else parent.setFocus();
	}
	
	public static void main(String [] args) {
		Display display = new Display();
		Shell shell = new Shell(display);
		shell.setLayout(new FillLayout());
		shell.setText("window.title");
		
		BrowserExample app = new BrowserExample(shell, true);
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		app.dispose();
		display.dispose();
	}
}
  1. To switch between chromium and normal swt browser, comment/uncomment
    import org.eclipse.swt.chromium.Browser;

HDPI screens with zoom level will not size the internal browser correctly

we call: chromium.getSize()

which is of an eclipse Control class:

public Point getSize (){
checkWidget ();
return DPIUtil.autoScaleDown(getSizeInPixels ());
}

that scopes the actual size in pixels down to the "rendered" size on screen.

so for me 2144x1580 in real pixels are reported back as: 1072x790

but it seems that the internal browser component really wants the actual size in pixels
so we have to do the reverse, i added a method:

private Point getChromiumSize() {
	Point size = chromium.getSize();
	return DPIUtil.autoScaleUp(size);
}

and everywhere we do chromium.getSize() i replaced it with the above method call.

Browser not loading/rendering in my installed plugin.

HI! I’m going to describe a scenario where the Chromium browser seems to load in my view, but doesn’t seem to render. My scenario/sample is pretty simple, I’m actually attaching a P2 installable site with my sample. I create a simple view plugin that instantiates the new Chromium browser and sets and URL. I then select my plugin and do ‘Run As -> Eclipse Application’. In the resultant Eclipse I open my view and the Chromium browser is loaded and displays the URL perfectly. Very awesome! Note that in the console I see a lot of debug output from your Chromium feature, all looks good.
The problem is what comes next, that is, I recently exported my plugin as a P2 site, install it, and then opened my view. In this case, Chromium browser seems to not render and seems hung. Let me explain those steps a little more. Basically, I create a feature for my plugin and then export it as a ‘Deployable Features’ (p2 site). I then install your two Chromium P2 sites, and my P2 site, into a pristine Eclipse Photon JEE. After install I restart and then open my view. The view opens but the browser seems to be hung. In the console I see all the debug output from the Chromium feature as usual which looks normal to me (i.e. no errors). The browser never seems to render, that is, it doesn’t display the web page and seems to be hung. So my question is, why does my view and the Chromium browser load/work perfectly when I do a ‘Run As -> eclipse application’, but not when I install the plugin. My guess is that either my plugin is missing a dependency, or the Chromium feature is missing a dependency.

If you would like to try this out for yourself, I’ve attached my P2 site (MyCEFView.zip attached, source code is there as well). To use it, please do the following:

  1. I got the latest Eclipse Photon JEE and extracted it.

  2. I then installed the following two P2 sites (restarting after each install):

http://dl.maketechnology.io/chromium-swt/rls/repository

http://dl.maketechnology.io/chromium-cef/rls/repository

  1. I then installed my P2 site (download and extract the attached MyCEFView.zip). During install uncheck the ‘group items by category’.

  2. Restart eclipse (start it from the console so you can see the Chromium debug output).

  3. Go to Window -> Show View -> Other… -> Sample Category -> Sample View. The view will be opened, Chromium debug printed to the console (all looks well), but the view/browser seems to be hung.

If you import my feature instead, then select it, and do ‘Run As – Eclipse Application’, then open the view in the resultant Eclipse, the view and browser works great.

Could you look at the source of my plugin and see if I’m missing something or if you Chromium plugin is missing something?

Sincerely,

Heath Thomann

Merge 3029 to master?

At the moment, master is broken on mac, but 3029 works great. Can we merge 3029 to master?

I'd like to refer people to this repository, and the fewer hiccups there are for them to build the example app the better.

Support for load handlers?

It would be awesome if it would be possible to set a handler to implement custom resource loading (even if it's not possible via the standard SWT Browser API).

Eclipse crashes on exit

When using cefswt in an RCP application, e.g. like this:

public class ExampleChromeView extends ViewPart {
	
	public static final String ID = "ExampleChromeView";

	Chromium chromium;
	
	@Override
	public void createPartControl(Composite parent) {
		parent.setLayout(new FillLayout());
		chromium = new Chromium(parent, SWT.NONE);
		chromium.setUrl("https://www.whatismybrowser.com/");
	}

	@Override
	public void setFocus() {
		chromium.setFocus();
	}
}

Eclipse crashes on exit (at least on OSX). This is the stdout/stderr:

Hello CEF, ARGS: 29
Calling cef_execute_process
[0809/135511.895190:WARNING:mediasession.cc(355)] Duplicate id found. Reassigning from 103 to 127
[0809/135511.895295:WARNING:mediasession.cc(355)] Duplicate id found. Reassigning from 104 to 125
J:disposing chromium
J:call close_browser
J:STOPPING MSG LOOP
J:shutting down CEF on exit from thread main
r: Calling cef_shutdown
J:LifeSpanHandler Remove myself
J:OnBeforeClose
J:SIZEOF:Browser:200
call rls
freed
objc[28918]: autorelease pool page 0x7f844242c000 corrupted
  magic     0x29a89000 0x00000001 0x4570e178 0x00007f84
  should be 0xa1a1a1a1 0x4f545541 0x454c4552 0x21455341
  pthread   0x129a89030
  should be 0x7fff945853c0

Issues with special characters as return values for BrowserFunction

The Browser fails to render the web page if the return value of a BrowserFunction contains special characters like ä,ö,ü
In that case, the javascript execution seems to be interrupted and the browser just displays a blank page (even if it should have some content to display)

An example project that demonstrates the issue can be found here: https://github.com/MichaelFroeschen/chromium-swt-spc-poc/

The Application should display a page that has the contents:

English
Success: Reset
German
Success: Zurücksetzen

Instead a blank page will be shown

The javascript code contains several console.log calls to demonstrate when the execution stops:

[1107/072424.804:INFO:CONSOLE(11)] "callFunc(en)",  (11)
[1107/072424.812:INFO:CONSOLE(13)] "en json received",  (13)
[1107/072424.812:INFO:CONSOLE(15)] "en json parsed",  (15)
[1107/072424.812:INFO:CONSOLE(17)] "html updated",  (17)
[1107/072424.813:INFO:CONSOLE(19)] "callFunc(de)",  (19)

You can see that it fails with the call to callFunc('de') at line 20.

Windows, Hi-DPI, Scale > 100% -> Blank page

We discovered a problem with Windows computers that have a high DPI screen. When the display scaling in Windows is set to something other than 100%, all chromium browser windows remain white. You may inspect the HTML with View source, but nothing is shown.

Setting to 100% and relogin fixes the problem, but this is not suitable as high DPI machines have really a tiny font size when not scaled up.

Tested with 0.8.1, Microsoft Surface Pro 6 & Huawei Matebook X Pro 13.9''

black rectangle is shown when closing the browser (shown in an editor)

The nicest solution would be if we don't paint (stop painting) at all when closing
So you still just see the browser as is and it disappears in one go

Else i guess setting the background correctly to the system background color would be a solution
But that is not just light gray, i guess when in a black theme it should be black?

cef binaries not found even if using repo

I think I have included all relevant bundles from the CEF binaries repo, but still getting this exception:

java.lang.UnsatisfiedLinkError: Could not find resourcecef.pak (in subdirectory: chromium-3071 )
at org.eclipse.swt.internal.chromium.ResourceExpander.findResource(ResourceExpander.java:116)
at org.eclipse.swt.chromium.Chromium.loadLib(Chromium.java:479)
at org.eclipse.swt.chromium.Chromium.(Chromium.java:50)
at org.eclipse.swt.chromium.Browser.(Browser.java:32)

I am on win10 x86_64.

extract of resources doesn't work on windows because of FILE_SEPARATOR

In ResourceExpander on line 133 we have this:

is = Library.class.getResourceAsStream ("/" + mappedName); //$NON-NLS-1$

but that should become

is = Library.class.getResourceAsStream ('/' + mappedName.replace('\', '/'));

because getRessourceAsStream really expects to have a url syntax, so if using a \ in the name it will not find anything

Various crashes in com.kenai.jffi.Foreign.memchr(JIJ)J+0

Same setup as in #41

I was testing in BiglyBT with an embedded browser showing https://biglybt.tumblr.com/ and after a few refreshes (triggered by clicking on the large, bold "BiglyBT" top left) it crashes the application. I went ahead and created a standalone test

		Browser browser = new Browser( shell, SWT.NULL );
		browser.setUrl( "https://biglybt.tumblr.com/" );
		shell.open();

and the same thing happens. I also created a refresh loop calling browser.refresh() every 10 seconds and this also produces the crash.

Here are a few stack traces - please ask if I can help further!


Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) C [msvcrt.dll+0x15001]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j com.kenai.jffi.Foreign.memchr(JIJ)J+0
j com.kenai.jffi.MemoryIO$UnsafeImpl.memchr(JIJ)J+4
j com.kenai.jffi.MemoryIO.indexOf(JBI)J+6
j jnr.ffi.provider.jffi.DirectMemoryIO.indexOf(JBI)I+12
j jnr.ffi.provider.AbstractMemoryIO.indexOf(JB)I+5
j jnr.ffi.provider.converters.StringResultConverter.fromNative(Ljnr/ffi/Pointer;Ljnr/ffi/mapper/FromNativeContext;)Ljava/lang/String;+13
j org.eclipse.swt.chromium.Chromium$Lib$jnr$ffi$0.cefswt_get_text(Ljnr/ffi/Pointer;Lorg/eclipse/swt/internal/chromium/CEF$cef_string_visitor_t;)Ljava/lang/String;+78
j org.eclipse.swt.chromium.Chromium.updateText()V+36
j org.eclipse.swt.chromium.Chromium.lambda$13(Lorg/eclipse/swt/internal/chromium/CEF$cef_load_handler_t;Ljnr/ffi/Pointer;Ljnr/ffi/Pointer;I)V+19
j org.eclipse.swt.chromium.Chromium$$Lambda$360.invoke(Lorg/eclipse/swt/internal/chromium/CEF$cef_load_handler_t;Ljnr/ffi/Pointer;Ljnr/ffi/Pointer;I)V+9
j jnr.ffi.provider.jffi.NativeClosureProxy$$impl$$28.invoke(JJJI)V+49
v ~StubRoutines::call_stub
J 9375 com.kenai.jffi.Foreign.invokeArrayReturnInt(JJ[B)I (0 bytes) @ 0x0000000004260cdd [0x0000000004260c80+0x5d]
J 11181 C2 com.kenai.jffi.Invoker.invokeInt(Lcom/kenai/jffi/CallContext;JLcom/kenai/jffi/HeapInvocationBuffer;)I (42 bytes) @ 0x0000000002f67808 [0x0000000002f677a0+0x68]
J 9954 C1 org.eclipse.swt.chromium.Chromium$$Lambda$335.run()V (8 bytes) @ 0x0000000004471084 [0x0000000004470a60+0x624]
J 10266 C2 org.eclipse.swt.widgets.Display.readAndDispatch()Z (96 bytes) @ 0x0000000002b82c3c [0x0000000002b81fa0+0xc9c]
J 14129% C2 com.biglybt.ui.swt.mainwindow.SWTThread.(Lcom/biglybt/ui/IUIIntializer;)V (883 bytes) @ 0x00000000057687b4 [0x0000000005768320+0x494]
j com.biglybt.ui.swt.mainwindow.SWTThread.createInstance(Lcom/biglybt/ui/IUIIntializer;)V+18
j com.biglybt.ui.swt.Initializer.(Lcom/biglybt/core/Core;Lcom/biglybt/ui/common/StartServer;)V+121
j com.biglybt.ui.swt.UI.takeMainThread()V+8
j com.biglybt.ui.Main.main([Ljava/lang/String;)V+690


C [msvcrt.dll+0x15001]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j com.kenai.jffi.Foreign.memchr(JIJ)J+0
J 11779 C1 jnr.ffi.provider.jffi.DirectMemoryIO.indexOf(JBI)I (17 bytes) @ 0x0000000004ce386c [0x0000000004ce3560+0x30c]
J 11778 C1 jnr.ffi.provider.AbstractMemoryIO.indexOf(JB)I (9 bytes) @ 0x0000000002891fe4 [0x0000000002891ec0+0x124]
J 11051 C1 jnr.ffi.provider.converters.StringResultConverter.fromNative(Ljnr/ffi/Pointer;Ljnr/ffi/mapper/FromNativeContext;)Ljava/lang/String; (110 bytes) @ 0x00000000048019cc [0x0000000004801640+0x38c]
j org.eclipse.swt.chromium.Chromium$Lib$jnr$ffi$0.cefswt_get_text(Ljnr/ffi/Pointer;Lorg/eclipse/swt/internal/chromium/CEF$cef_string_visitor_t;)Ljava/lang/String;+78
j org.eclipse.swt.chromium.Chromium.updateText()V+36
j org.eclipse.swt.chromium.Chromium.lambda$13(Lorg/eclipse/swt/internal/chromium/CEF$cef_load_handler_t;Ljnr/ffi/Pointer;Ljnr/ffi/Pointer;I)V+19
j org.eclipse.swt.chromium.Chromium$$Lambda$338.invoke(Lorg/eclipse/swt/internal/chromium/CEF$cef_load_handler_t;Ljnr/ffi/Pointer;Ljnr/ffi/Pointer;I)V+9
j jnr.ffi.provider.jffi.NativeClosureProxy$$impl$$28.invoke(JJJI)V+49
v ~StubRoutines::call_stub
J 6831 com.kenai.jffi.Foreign.invokeArrayReturnInt(JJ[B)I (0 bytes) @ 0x0000000002877a9d [0x0000000002877a40+0x5d]
J 11405 C2 org.eclipse.swt.chromium.Chromium$$Lambda$313.run()V (8 bytes) @ 0x0000000004b00894 [0x0000000004b00620+0x274]
J 7184 C2 org.eclipse.swt.widgets.Display.readAndDispatch()Z (96 bytes) @ 0x0000000002b75cf0 [0x0000000002b75180+0xb70]
j com.biglybt.ui.swt.mainwindow.SWTThread.(Lcom/biglybt/ui/IUIIntializer;)V+601
j com.biglybt.ui.swt.mainwindow.SWTThread.createInstance(Lcom/biglybt/ui/IUIIntializer;)V+18
j com.biglybt.ui.swt.Initializer.(Lcom/biglybt/core/Core;Lcom/biglybt/ui/common/StartServer;)V+121
j com.biglybt.ui.swt.UI.takeMainThread()V+8
j com.biglybt.ui.Main.main([Ljava/lang/String;)V+690


C [msvcrt.dll+0x15001]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j com.kenai.jffi.Foreign.memchr(JIJ)J+0
j com.kenai.jffi.MemoryIO$UnsafeImpl.memchr(JIJ)J+4
j com.kenai.jffi.MemoryIO.indexOf(JBI)J+6
j jnr.ffi.provider.jffi.DirectMemoryIO.indexOf(JBI)I+12
j jnr.ffi.provider.AbstractMemoryIO.indexOf(JB)I+5
J 11883 C1 jnr.ffi.provider.converters.StringResultConverter.fromNative(Ljnr/ffi/Pointer;Ljnr/ffi/mapper/FromNativeContext;)Ljava/lang/String; (110 bytes) @ 0x0000000004dca30c [0x0000000004dc9f80+0x38c]
j org.eclipse.swt.chromium.Chromium$Lib$jnr$ffi$0.cefswt_get_text(Ljnr/ffi/Pointer;Lorg/eclipse/swt/internal/chromium/CEF$cef_string_visitor_t;)Ljava/lang/String;+78
j org.eclipse.swt.chromium.Chromium.updateText()V+36
j org.eclipse.swt.chromium.Chromium.lambda$13(Lorg/eclipse/swt/internal/chromium/CEF$cef_load_handler_t;Ljnr/ffi/Pointer;Ljnr/ffi/Pointer;I)V+19
j org.eclipse.swt.chromium.Chromium$$Lambda$370.invoke(Lorg/eclipse/swt/internal/chromium/CEF$cef_load_handler_t;Ljnr/ffi/Pointer;Ljnr/ffi/Pointer;I)V+9
j jnr.ffi.provider.jffi.NativeClosureProxy$$impl$$28.invoke(JJJI)V+49
v ~StubRoutines::call_stub
J 10647 com.kenai.jffi.Foreign.invokeArrayReturnInt(JJ[B)I (0 bytes) @ 0x000000000484bb5d [0x000000000484bb00+0x5d]
J 11998 C2 com.kenai.jffi.Invoker.invokeInt(Lcom/kenai/jffi/CallContext;JLcom/kenai/jffi/HeapInvocationBuffer;)I (42 bytes) @ 0x0000000004dd240c [0x0000000004dd23a0+0x6c]
J 10666 C1 org.eclipse.swt.chromium.Chromium$$Lambda$345.run()V (8 bytes) @ 0x00000000048a8884 [0x00000000048a8260+0x624]
J 10672 C2 org.eclipse.swt.widgets.Display.readAndDispatch()Z (96 bytes) @ 0x00000000048c6198 [0x00000000048c58e0+0x8b8]
j com.biglybt.ui.swt.mainwindow.SWTThread.(Lcom/biglybt/ui/IUIIntializer;)V+601
j com.biglybt.ui.swt.mainwindow.SWTThread.createInstance(Lcom/biglybt/ui/IUIIntializer;)V+18
j com.biglybt.ui.swt.Initializer.(Lcom/biglybt/core/Core;Lcom/biglybt/ui/common/StartServer;)V+121
j com.biglybt.ui.swt.UI.takeMainThread()V+8
j com.biglybt.ui.Main.main([Ljava/lang/String;)V+690


C [msvcrt.dll+0x15001]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
J 1210 com.kenai.jffi.Foreign.memchr(JIJ)J (0 bytes) @ 0x000000000282cb49 [0x000000000282cb00+0x49]
J 1181 C1 jnr.ffi.provider.jffi.DirectMemoryIO.indexOf(JBI)I (17 bytes) @ 0x000000000271824c [0x0000000002717f60+0x2ec]
J 1180 C1 jnr.ffi.provider.AbstractMemoryIO.indexOf(JB)I (9 bytes) @ 0x000000000277dec4 [0x000000000277ddc0+0x104]
J 1157 C1 jnr.ffi.provider.converters.StringResultConverter.fromNative(Ljnr/ffi/Pointer;Ljnr/ffi/mapper/FromNativeContext;)Ljava/lang/String; (110 bytes) @ 0x0000000002626554 [0x00000000026261e0+0x374]
j org.eclipse.swt.chromium.Chromium$Lib$jnr$ffi$0.cefswt_get_text(Ljnr/ffi/Pointer;Lorg/eclipse/swt/internal/chromium/CEF$cef_string_visitor_t;)Ljava/lang/String;+78
j org.eclipse.swt.chromium.Chromium.updateText()V+36
j org.eclipse.swt.chromium.Chromium.lambda$13(Lorg/eclipse/swt/internal/chromium/CEF$cef_load_handler_t;Ljnr/ffi/Pointer;Ljnr/ffi/Pointer;I)V+19
j org.eclipse.swt.chromium.Chromium$$Lambda$34.invoke(Lorg/eclipse/swt/internal/chromium/CEF$cef_load_handler_t;Ljnr/ffi/Pointer;Ljnr/ffi/Pointer;I)V+9
j jnr.ffi.provider.jffi.NativeClosureProxy$$impl$$28.invoke(JJJI)V+49
v ~StubRoutines::call_stub
J 1039 com.kenai.jffi.Foreign.invokeArrayReturnInt(JJ[B)I (0 bytes) @ 0x0000000002806a1d [0x00000000028069c0+0x5d]
J 1205 C2 org.eclipse.swt.chromium.Chromium$$Lambda$9.run()V (8 bytes) @ 0x0000000002830bb0 [0x0000000002830a00+0x1b0]
J 1118 C2 org.eclipse.swt.widgets.Display.readAndDispatch()Z (96 bytes) @ 0x0000000002868e04 [0x00000000028688e0+0x524]
j a.b.c.Test.main([Ljava/lang/String;)V+77


C [msvcrt.dll+0x15001]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
J 1181 com.kenai.jffi.Foreign.memchr(JIJ)J (0 bytes) @ 0x00000000028105c9 [0x0000000002810580+0x49]
J 1153 C1 jnr.ffi.provider.jffi.DirectMemoryIO.indexOf(JBI)I (17 bytes) @ 0x00000000026de54c [0x00000000026de260+0x2ec]
J 1152 C1 jnr.ffi.provider.AbstractMemoryIO.indexOf(JB)I (9 bytes) @ 0x00000000026deb44 [0x00000000026dea40+0x104]
J 1124 C1 jnr.ffi.provider.converters.StringResultConverter.fromNative(Ljnr/ffi/Pointer;Ljnr/ffi/mapper/FromNativeContext;)Ljava/lang/String; (110 bytes) @ 0x0000000002618dd4 [0x0000000002618a60+0x374]
j org.eclipse.swt.chromium.Chromium$Lib$jnr$ffi$0.cefswt_get_text(Ljnr/ffi/Pointer;Lorg/eclipse/swt/internal/chromium/CEF$cef_string_visitor_t;)Ljava/lang/String;+78
j org.eclipse.swt.chromium.Chromium.updateText()V+36
j org.eclipse.swt.chromium.Chromium.lambda$13(Lorg/eclipse/swt/internal/chromium/CEF$cef_load_handler_t;Ljnr/ffi/Pointer;Ljnr/ffi/Pointer;I)V+19
j org.eclipse.swt.chromium.Chromium$$Lambda$34.invoke(Lorg/eclipse/swt/internal/chromium/CEF$cef_load_handler_t;Ljnr/ffi/Pointer;Ljnr/ffi/Pointer;I)V+9
j jnr.ffi.provider.jffi.NativeClosureProxy$$impl$$28.invoke(JJJI)V+49
v ~StubRoutines::call_stub
J 1008 com.kenai.jffi.Foreign.invokeArrayReturnInt(JJ[B)I (0 bytes) @ 0x00000000027e77dd [0x00000000027e7780+0x5d]
J 1189 C2 org.eclipse.swt.chromium.Chromium$$Lambda$9.run()V (8 bytes) @ 0x00000000027bd6b0 [0x00000000027bd500+0x1b0]
J 1096 C2 org.eclipse.swt.widgets.Display.readAndDispatch()Z (96 bytes) @ 0x000000000284adc4 [0x000000000284a8a0+0x524]
j a.b.c.Test.main([Ljava/lang/String;)V+89

Javascript key handlers are not called after focus change

We have event handlers for shortcut keys in our web application.
When the page is loaded, the key handlers work fine, but when the chromium browser lost and regained focus, the event handlers are not called until the user clicks on the page.

Expected behaviour
Key events are handled after focus lost/regained without the user clicking on the page.

This worked as expected with the 0.5.0 version and is broken in the 0.6.0 and 0.7.0 version

Steps to reproduce

  • Compile/run the attached sample java program
  • type keys a b c typed letter is shown in the page
  • type key d an alert dialog is shown
  • close the dialog (click OK) main window regains focus do not click on the browser window
  • type any key the key should show on the page but it does not because the event handler is not called
  • click in the browser window
  • event handling is restored

Environment
Windows 10 Version 1607
org.eclipse.swt.chromium-0.7.0
org.eclipse.swt.chromium.win32.win32.x86_64-0.7.0
org.eclipse.swt.win32.win32.x86_64_3.106.2.v20171129-0543.

Linux GTK3 support

The README says only GTK2 is supported currently. Is GTK3 on the roadmap? Can/will they be supported concurrently?

Menu handler not implemented

We would like to set a custom menu in the browser. As well as remove the chromium menu items like Print and Inspect.

The required methods seem not to be implemented yet

image001

Near production quality, please update

Hi dear team at maketechnology

You did such a great job with the long demanding integration of a state of the art HTML5 browser into eclipse. The current development can almost be used for any application. Unfortunately, there are some really nasty and blocking bugs in the version 0.8.1, some of them are new, that were already working with 0.7.

I'd really like to encourage your team to solve these blocking issues, as then the RCP developers could start using Chromium for there applications.

From our point of view, those are the most severe bugs:

#45: New encoding problem with 0.8.1
#44 New scaling problem on Mac with 0.8.1, everything x2 in size
#42 Crashes with EXCEPTION_ACCESS_VIOLATION (0xc0000005):
#49 Menu context not implemented

Could you please try fixing them and release a new version. We would also prefer the log level to warn instead of debug.

Many thanks for your update. We really would appreciate it.

Daniel

browser.evaluate is blocking when browser did not finish creating

We observe a blocking main thread in the following scenario. Tested with 0.6 and 0.7 on Windows 10, Chromium 64 bit as well on macOS Mojave.

  1. A new part is instantiated, that contains a chromium browser widget.
  2. In the createControl method, the browser is created.
  3. Before the html page is send to the browser.setText(), the window size is being asked from the browser (used to know how to scale).
  4. This is done with chromium.evaluate("return window.innerWidth");
  5. The call blocks and will never return

On a mac, waiting 200ms before calling browser.evaluate() helps, on Windows not.
So it seems that the evaluate function is blocking when the browser widget is not completely initialized. It happens also sometimes on an initialized widget, after letting the browser completely instantiate.

image001

image001

This is the debug log

J1:on_address_change:http://text/ true http://text
J1:on_before_browse http://text
J1:on_before_browse:http://localhost/portalV2/loaded http://text
new client: V4(127.0.0.1:59161)
read from socket: 18 24 [1, 0, 0, 0, 0, 0, 0, 0, 1, 3, 1, 0, 0, 0, 0, 0, 49, 0]
st: ReturnSt { kind: Bool, str_value: "1" }
J2:initCef Done empty url
create_browser in 593064
parent 0x90ca8
Calling cef_browser_host_create_browser
J2:on_after_created jnr.ffi.provider.jffi.DirectMemoryIO[address=0x25905580]:null about:blank
J2:GetFocusHandler about:blank
J2:CALLBACK OnSetFocus FOCUS_SOURCE_NAVIGATION about:blank
2018-12-04 08:48:45,632 INFO  RCPBrowser - Created SWT Browser: Chromium
J3:initCef Done empty url
create_browser in 1706754
parent 0x1a0b02
Calling cef_browser_host_create_browser
J3:on_after_created jnr.ffi.provider.jffi.DirectMemoryIO[address=0x25905a80]:null about:blank
J3:GetFocusHandler about:blank
J3:CALLBACK OnSetFocus FOCUS_SOURCE_NAVIGATION about:blank
2018-12-04 08:48:45,686 INFO  RCPBrowser - Created SWT Browser: Chromium
J2:on_after_created handling jnr.ffi.provider.jffi.DirectMemoryIO[address=0x25905580]:null about:blank
J3:on_after_created handling jnr.ffi.provider.jffi.DirectMemoryIO[address=0x25905a80]:null http://text
Evaluating:  window.innerWidth 

Many thanks for your help and your good work so far.

Custom arguments for CEF process

Can you add ability to specify custom arguments for CEF GPU process "cefrust_subp.exe"?
I try to use Chromium Browser as SWT control on windows.x86_64 platform.
On some machines I get black page instead of HTML page.
Errors in log:
[1109/100403.538:ERROR:gles2_cmd_decoder.cc(15368)] Context lost because SwapBuffers failed. [1109/100403.538:ERROR:gles2_cmd_decoder.cc(5282)] Error: 5 for Command kPostSubBufferCHROMIUM [1109/100403.539:ERROR:gpu_channel_manager.cc(218)] Exiting GPU process because some drivers cannot recover from problems.
It is reproduced with Chromium SWT Demo application.
The problem can be resolved by specifying "--disable-gpu" argument for CEF GPU process.
May be there is another solution?

Error on Linux "No more handles"

Hi,

I tested this plugin (0.9.0) on Linux with Photon 2019-03. I just created a simple view with a browser, and when I open the view it shows following error. The errors appear all the time while the view is active.

org.eclipse.swt.SWTError: No more handles
	at org.eclipse.swt.SWT.error(SWT.java:4725)
	at org.eclipse.swt.SWT.error(SWT.java:4614)
	at org.eclipse.swt.SWT.error(SWT.java:4585)
	at org.eclipse.swt.widgets.Widget.error(Widget.java:530)
	at org.eclipse.swt.widgets.Control.drawBackground(Control.java:219)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:6751)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:6035)
	at org.eclipse.swt.internal.gtk.GTK._gtk_main_do_event(Native Method)
	at org.eclipse.swt.internal.gtk.GTK.gtk_main_do_event(GTK.java:4135)
	at org.eclipse.swt.widgets.Display.eventProc(Display.java:1407)
	at org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Native Method)
	at org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(OS.java:1584)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4577)
	at org.eclipse.ui.statushandlers.WorkbenchErrorHandler.showStatusAdapter(WorkbenchErrorHandler.java:89)
	at org.eclipse.ui.statushandlers.WorkbenchErrorHandler.handle(WorkbenchErrorHandler.java:52)
	at org.eclipse.ui.internal.ide.IDEWorkbenchErrorHandler.handle(IDEWorkbenchErrorHandler.java:105)
	at org.eclipse.ui.internal.WorkbenchErrorHandlerProxy.handle(WorkbenchErrorHandlerProxy.java:34)
	at org.eclipse.ui.statushandlers.StatusManager.handle(StatusManager.java:216)
	at org.eclipse.ui.statushandlers.StatusManager.handle(StatusManager.java:263)
	at org.eclipse.ui.statushandlers.StatusManager.handle(StatusManager.java:274)
	at org.eclipse.ui.application.WorkbenchAdvisor.eventLoopException(WorkbenchAdvisor.java:333)
	at org.eclipse.ui.internal.Workbench$1.eventLoopException(Workbench.java:490)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.handle(PartRenderingEngine.java:1195)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1185)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1062)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:644)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:566)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at phasereditor.ide.ModifiedIDEApplication.start(ModifiedIDEApplication.java:179)
	at phasereditor.ide.intro.PhaserIDE2.start(PhaserIDE2.java:75)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:137)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:107)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:661)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:597)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1476)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1449)

Custom arguments for CEF process (2)

This is directly related to #16 in that it does not appear (I could be mistaken) that updating to 8081 has resolved the problem. While on 'most' machines the widget works wonderfully, I experienced a couple of situations where the widget could not be displayed. Curiously, while running from an Eclipse (2018-12) IDE (both using a Java 8 u191 SDK) the widget does display properly. It's only when running from an executable (either built on that machine or from another machine) that the widget seems to consistently fail, but only on specific machines. I am inquiring as to whether or not there may be additional security measures on those machines, but the fact that it runs from Eclipse on the machine is perplexing.

The CEF log file for those computers contains the following:

[0313/103139.303:ERROR:gles2_cmd_decoder.cc(17652)] [.DisplayCompositor-0000000057A710C0]GL ERROR :GL_INVALID_OPERATION : glCreateAndConsumeTextureCHROMIUM: invalid mailbox name
[0313/103139.313:ERROR:gles2_cmd_decoder.cc(9709)] [.DisplayCompositor-0000000057A710C0]RENDER WARNING: texture bound to texture unit 0 is not renderable. It maybe non-power-of-2 and have incompatible texture filtering.
[0313/103139.316:ERROR:gles2_cmd_decoder.cc(17652)] [.DisplayCompositor-0000000057A710C0]GL ERROR :GL_INVALID_OPERATION : glCreateAndConsumeTextureCHROMIUM: invalid mailbox name
[0313/103139.316:ERROR:gles2_cmd_decoder.cc(9709)] [.DisplayCompositor-0000000057A710C0]RENDER WARNING: texture bound to texture unit 0 is not renderable. It maybe non-power-of-2 and have incompatible texture filtering.
[0313/103139.317:ERROR:gles2_cmd_decoder.cc(17652)] [.DisplayCompositor-0000000057A710C0]GL ERROR :GL_INVALID_OPERATION : glCreateAndConsumeTextureCHROMIUM: invalid mailbox name
[0313/103139.317:ERROR:gles2_cmd_decoder.cc(9709)] [.DisplayCompositor-0000000057A710C0]RENDER WARNING: texture bound to texture unit 0 is not renderable. It maybe non-power-of-2 and have incompatible texture filtering.
[0313/103139.317:ERROR:gles2_cmd_decoder.cc(15567)] Context lost because SwapBuffers failed.
[0313/103139.317:ERROR:gles2_cmd_decoder.cc(5318)] Error: 5 for Command kPostSubBufferCHROMIUM
[0313/103139.317:ERROR:gpu_channel_manager.cc(188)] Exiting GPU process because some drivers cannot recover from problems.
[0313/103139.520:ERROR:main_delegate.cc(714)] Could not load cef_extensions.pak

The content of the widget is visible (I can right-click and View Source and the expected content is there) and it also appears as though I can interact with the navigable areas of the page, the widget simply does not draw.

Callback with empty string causing browser failure

Windows 7, 64 bit
JDK 1.8.0_121
SWT: 4.922
chromium.swt: master
jnr-ffi: 2.1.9
jffi: 1.2.18
asm: 7.0
CEF Version: 3.3071.1649.g98725e6
Chromium Verison: 59.0.3071.109

A callback with an argument of '' causes the browser to turn into a grey-screen-of-death.

To reproduce simply take the existing basic callback test and add '' to the invocation:

@test
public void test_BrowserFunction_callback () {
// On webkit1, this test works if ran on it's own. But sometimes in test-suite with other tests it causes jvm crash.
// culprit seems to be the main_context_iteration() call in shell.setVisible().
// See Bug 509587. Solution: Webkit2.
assumeFalse(webkit1SkipMsg(), isWebkit1);

AtomicBoolean javaCallbackExecuted = new AtomicBoolean(false);

class JavascriptCallback extends BrowserFunction { // Note: Local class defined inside method.
	JavascriptCallback(Browser browser, String name) {
		super(browser, name);
	}

	@Override
	public Object function(Object[] arguments) {
		javaCallbackExecuted.set(true);
		return null;
	}
}

String htmlWithScript = "<html><head>\n"
		+ "<script language=\"JavaScript\">\n"
		+ "function callCustomFunction() {\n"  // Define a javascript function.
		+ "     document.body.style.backgroundColor = 'red'\n"
		+ "		jsCallbackToJava('')\n"        // CHANGED HERE!
		+ "}"
		+ "</script>\n"
		+ "</head>\n"
		+ "<body> I'm going to make a callback to java </body>\n"
		+ "</html>\n";

browser.setText(htmlWithScript);
new JavascriptCallback(browser, "jsCallbackToJava");

browser.addProgressListener(callCustomFunctionUponLoad);

shell.open();
boolean passed = waitForPassCondition(javaCallbackExecuted::get);
String message = "Java failed to get a callback from javascript. Test timed out";
assertTrue(message, passed);

}

no content

logs:
cefrust.path: C:\Users\Administrator.swt\lib\win32\x86_64\chromium-3071
DLL init
subp: "C:\Users\Administrator\.swt\lib\win32\x86_64\chromium-3071\chromium_subp-0300.exe"
Calling cef_initialize
J:OnContextInitialized empty url
J:initCef Done empty url
create_browser
create_browser in 1381430
parent 0x151436
Calling cef_browser_host_create_browser
[0803/155641.984:ERROR:browser_gpu_channel_host_factory.cc(103)] Failed to launch GPU process.
J:GetFocusHandler http://www.baidu.com
J:CALLBACK OnSetFocus FOCUS_SOURCE_NAVIGATION http://www.baidu.com
J:Disallowing focus to SWT canvas http://www.baidu.com
J:STARTING MSG LOOP http://www.baidu.com
J:setUrl: https://www.baidu.com http://www.baidu.com
url: "https://www.baidu.com"
J:GetFocusHandler http://www.baidu.com
J:CALLBACK OnSetFocus FOCUS_SOURCE_NAVIGATION http://www.baidu.com
J:Disallowing focus to SWT canvas http://www.baidu.com

no page is show in my shell?

Closing a "popup" browser window closes the orignal browser.

HI! Take this HTML that opens a new window:

<!DOCTYPE html>
<html>
<body>

<a href="https://www.google.com" target="_blank">Click here to visit Google!

<p>The link above will open in a new browser window or a new tab.

</body>
</html>

I saved this in a file called popup.html.

I have create a view in my eclipse plugin that creates a org.eclipse.swt.chromium.Browser. With this browser I do a setUrl("file:///E:/popup.html"). I open my view and the popup.html is displayed. When I click the 'Click here to visit Google' link a new window is opened and google.com loaded. When I click the X button to close the "popup" browser, the 'parent', or originally opened browser contained in my view is closed. When I hit the X button a second time, the "popup" browser finally closes. Is there any way to fix this? Closing the second ("popup") browser should not close the first browser.
If you want me to send to you my plugin I will, but all it is a 'sample view' (from the samples templates) created in the Eclipse RCP, where the view instantiates the Browser. Nothing special at all.

NPE when creating a browser

I'm not sure this is the right place to report, but I get the exception below when trying to instantiate a Chromium browser (with fBrowser = new Browser(parent, SWT.NONE);). Is it anything I am doing wrong?

java.lang.NullPointerException
at jnr.ffi.provider.converters.StructByReferenceFromNativeConverter.fromNative(StructByReferenceFromNativeConverter.java:54)
at jnr.ffi.provider.converters.StructByReferenceFromNativeConverter.fromNative(StructByReferenceFromNativeConverter.java:33)
at jnr.ffi.provider.jffi.NativeClosureProxy$$impl$$2.invoke(Unknown Source)
at com.kenai.jffi.Foreign.invokeArrayO2Int32(Native Method)
at com.kenai.jffi.Invoker.invokeArrayWithObjectsInt32(Invoker.java:2162)
at com.kenai.jffi.Invoker.invokeInt(Invoker.java:1942)
at org.eclipse.swt.chromium.Chromium$Lib$jnr$ffi$0.cefswt_init(Unknown Source)
at org.eclipse.swt.chromium.Chromium.initCEF(Chromium.java:238)
at org.eclipse.swt.chromium.Chromium.create(Chromium.java:172)
at org.eclipse.swt.chromium.Browser.(Browser.java:35)

Right-click crashes application

While evaluating the project to make a potential donation I noticed that a right-click into the browser crashes the application in OSX. I assume this is the relevant output in the stdout/stderr:

J:get_context_menu_handler
2017-08-09 13:40:40.990 java[28644:521060] -[SWTApplication isHandlingSendEvent]: unrecognized selector sent to instance 0x7fa5865586b0

Here is the detailed log:
hs_err_pid28644.txt

No javascript dialog on Linux

window.alert() does not show a popup on Linux.

Instead, a message is logged:

[1226/223828.668051:WARNING:javascript_dialog_manager.cc(122)] No javascript dialog runner available for this platform

See the sample program in issue #34
Hit the 'd' key in the browser window, it should show a dialog.

Running the same code with the swt browser (webkit) does give a javascript dialog.

Environment
Ubuntu 18.04.1 LTS
com.make.chromium.cef.gtk.linux.x86_64_0.3.0.201807050001
org.eclipse.swt_3.107.0.v20180611-0422
org.eclipse.swt.gtk.linux.x86_64_3.107.0.v20180611-0422
org.eclipse.swt.chromium_0.7.0.201811300653
org.eclipse.swt.chromium.gtk.linux.x86_64_0.7.0.201811300653

Missing executable permission for chromium_subp

When running the Chromium browser the first time on a packaged and signed RCP Runtime on macOS, the executable file attribute is not set for the file chromium_subp.

The reason is most likely to find here:

org.eclipse.swt.internal.chromium.ResourceExpander.class
   static void chmod(String permision, String path) {
        if (os().equals ("win32")) return; //$NON-NLS-1$
        try {
            Runtime.getRuntime ().exec (new String []{"chmod", permision, path}).waitFor(); //$NON-NLS-1$
        } catch (Throwable e) {}
    }

Runtime.exec with a System command is not allowed on a signed App on macOS. Therefore, the file attributes are not set to 755 and so Chromium does not work. Manually setting the permission and restarting the app works

chmod a+x ~/.swt/lib/macosx/x86_64/chromium-3071/chromium_subp-0700.app/Contents/MacOS/chromium_subp

I suggest to use File.setExecutable(true) instead Runtime.getRuntime ().exec (new String []{"chmod", permision, path}).waitFor();.

Thanks for fixing this in the next release.

Bidirectional API calls cause crashes

System: Windows 10 x64

In the case the browser instance and the application need to communicate during their respective api calls a crash may occur caused by a refused connection attempt.
If the application crashed this way, a process "chromium_subp-0600.exe" is created (can be seen in the Task Manager)

Use case:
Application tells JS that it is ready to communicate (via a function call with browser.execute(...))
JS calls one or multiple BrowserFunction(s) to retrieve some data to display (within that function call)
Within these BrowserFunction calls there may even be other script invocations (not necessary AFAIK)

An example on how to reproduce this can be found at https://github.com/MichaelFroeschen/chromium-swt-spc-poc

Steps to reproduce:

  • Open the application
  • Klick "Views" in the Menubar
  • Klick "Open Issue 31 Example"

The application will (most likely) crash.
Sometimes the crash does not occur. In that case, retry

Menu handler not working

Thanks for the fix. But we still do not get a custom menu in the browser.

For example, like this:

@Override
public void createPartControl(Composite parent) {
        Composite composite = new Composite(parent, SWT.NONE);
	FillLayout layout = new FillLayout();
	composite.setLayout(layout);
	browser = new Browser(composite, SWT.NONE);
	browser.setText(htmlText);
	menu = new Menu(browser);
	addMenuItems(menu);
	menu.setVisible(false);
	browser.setMenu(menu);
 }

Right click in a chromium web page brings the standard chrome menu

image

Originally posted by @dstainhauser in #49 (comment)

mvn build error

Hi,
I've got an error on build project with maven:

It seems than there is no pom.xml in the child modules:

  • org.eclipse.swt.chromium
  • org.eclipse.swt.chromium.feature

C:\git\external\chromium.swt>mvn clean dist
[INFO] Scanning for projects...
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project org.eclipse:swt.chromium:0.8.1-SNAPSHOT (C:\git\external\chromium.swt\pom.xml) has 2 errors
[ERROR] Child module C:\git\external\chromium.swt\org.eclipse.swt.chromium\pom.xml of C:\git\external\chromium.swt\pom.xml does not exist
[ERROR] Child module C:\git\external\chromium.swt\org.eclipse.swt.chromium.feature\pom.xml of C:\git\external\chromium.swt\pom.xml does not exist
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
C:\git\external\chromium.swt>

Socket server panic

When there are multiple browsers all refreshing at the same time, sometimes a socket server panic error happens here:

https://github.com/maketechnology/chromium.swt/blob/b0b88febdde12f513360eeb888e28c4ab2f402f2/chromium-library/chromium_subp/src/app/mod.rs#L358

The exception message is Only one usage of each socket address (protocol/network address/port) is normally permitted. (os error 10048).

The problem seems to be that the code to select an available port finds one by iteration through ports 8001 to 9999 until it can bind to one. But then it binds to it again to actually use it. So there's a race condition where another browser can bind to that port in between.

https://github.com/maketechnology/chromium.swt/blob/b0b88febdde12f513360eeb888e28c4ab2f402f2/chromium-library/chromium_subp/src/socket.rs#L123-L128

https://github.com/maketechnology/chromium.swt/blob/b0b88febdde12f513360eeb888e28c4ab2f402f2/chromium-library/chromium_subp/src/socket.rs#L207-L212

command line arguments (or just remote debug startup) support

I read (including in the doc of the CEF or CEFFactory classes that there should be a CefSettings:

	///
	/// Provides an opportunity to view and/or modify command-line arguments before
	/// processing by CEF and Chromium. The |process_type| value will be NULL for
	/// the browser process. Do not keep a reference to the cef_command_line_t
	/// object passed to this function. The CefSettings.command_line_args_disabled
	/// value can be used to start with an NULL command-line object. Any values
	/// specified in CefSettings that equate to command-line arguments will be set
	/// before this function is called. Be cautious when using this function to
	/// modify command-line arguments for non-browser processes as this may result
	/// in undefined behavior including crashes.
	///
	public Function<on_before_command_line_processing> on_before_command_line_processing = function(
			on_before_command_line_processing.class);

But where is that CefSettings class/struct?

so this could be used: https://stackoverflow.com/questions/29117882/debugging-javascript-in-chromium-embedded-framework

or http://magpcss.org/ceforum/viewtopic.php?f=6&t=15099 also talks about on_before_command_line_processing

but that doesn't seem to work:

mapTypeForClosure(cef_string_t.class); // first make sure that parameter type is registered
app.on_before_command_line_processing .set((cef_app_t self_, cef_string_t process_type, jnr.ffi.Pointer command_line) -> {
System.err.println(self_);
System.err.println(process_type);
System.err.println(command_line);
});

that is never called, and if it was how can i really add/change arguments to

BrowserFunctions returning arrays cause issues

System: Windows 10 x64

There are several issues with BrowserFunctions returning arrays.

  1. Returning an empty array freezes the page.
  2. Returning an array that contains primitive values causes an exception to be thrown (und subsequenty the page to freeze). The exception is:

java.lang.ClassCastException: [I cannot be cast to [Ljava.lang.Object;
at org.eclipse.swt.chromium.Chromium.convertType(Chromium.java:989)
at org.eclipse.swt.chromium.Chromium.browserFunctionCalled(Chromium.java:964)
at org.eclipse.swt.chromium.Chromium.lambda$8(Chromium.java:382)
at jnr.ffi.provider.jffi.NativeClosureProxy$$impl$$16.invoke(Unknown Source)
at com.kenai.jffi.Foreign.invokeArrayReturnInt(Native Method)
at com.kenai.jffi.Invoker.invokeInt(Invoker.java:1944)
at org.eclipse.swt.chromium.Chromium$Lib$jnr$ffi$0.cefswt_do_message_loop_work(Unknown Source)
at org.eclipse.swt.chromium.Chromium.safe_loop_work(Chromium.java:309)
at org.eclipse.swt.chromium.Chromium.lambda$2(Chromium.java:244)
at org.eclipse.swt.chromium.Chromium.lambda$5(Chromium.java:269)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:40)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:185)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3919)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3550)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1173)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1062)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:636)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:563)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:151)
at chromiumpoc.Application.start(Application.java:18)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:137)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:107)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:595)
at org.eclipse.equinox.launcher.Main.run(Main.java:1501)
at org.eclipse.equinox.launcher.Main.main(Main.java:1474)

  1. Returning an array of strings containing a comma will result in incorrect string literals.
    Examples: Returning new String[] { "a,b", "a", "a=b" } will be converted to a,a,a=b
    Another example would be to return json objects as string literals.
    This does not happen if the return value is just a string (instead of an array)

I extended my previous poc project to include a demo for the mentioned issues.
Just open the application and open the demo via "Views" - "Open Issue 58 Example".
Clicking any of the first 4 buttons demonstrates the mentioned issues.

The Buttons "Should return ["String"]" and "Should return 0" demonstrate what is expected to happen.

None of these issues occur in the default swt browser.

Edit: Added case 3

BrowserFunction called after dispose

BrowserFunctions can sometimes be invoked after dispose() was called. I think this is because the dispose is asynchronous. I can reproduce this consistently in the proprietary application I'm working on. I tried to create a standalone example that disposes repeatedly but I couldn't get it to happen there.

Workaround is to check if the browser is disposed in the BrowserFunction. Potential proper fix is to return early if disposing is true inside browserFunctionCalled

Cant type into textfield

  1. Open https://github.com/login in the browser
  2. try to enter username or password -> nothing happens

Seem to be a focus issue, Using shortkey (SHIFT+POS1) inside another textfield (e.g. google search page) makes the mouse unusable

The log is hung with

J1:main:CALLBACK OnGotFocus (https://google.de)
J1:main:GetFocusHandler (https://google.de)
J1:main:CALLBACK OnGotFocus (https://google.de)
J1:main:GetFocusHandler (https://google.de)

Only Solution seem to kill the App with ALT+F4

"Not allowed to load local resource"

I'm not sure if this is in the scope of this project, or if it is a general CEF issue.

I am rendering some HTML that uses resources provided by my plugins. Chrome doesn't let me load these local files, with the error in the title. I understand why this is an important issue on the web, but for this use case, it feels it should be allowed. Otherwise it can only be used as a "general web" browser, not for rendering application views, which is a bit underwhelming...

Is there a way to make it work? Is this related to #26?

focus is constantly shifted between the chromium swt object and the browser itself..

opening the browser works (as an editor tab)
but when i go to another editor and then back
Then it can happen that eclipse completely freezes and it the log i see never ending statements like this:

<<<<<<<< set_focus 1 J:GetFocusHandler http://localhost:8080/rfb/angular/index.html?s=Test&l=absolute&f=Test&w=640.0&h=480.0&editorid=8df42a0c-5c05-40a5-90fc-c410ef88542d&c_sessionid=ae1e68bd-4ee8-4381-965c-3647a615b4d4 J:CALLBACK OnSetFocus FOCUS_SOURCE_SYSTEM http://localhost:8080/rfb/angular/index.html?s=Test&l=absolute&f=Test&w=640.0&h=480.0&editorid=8df42a0c-5c05-40a5-90fc-c410ef88542d&c_sessionid=ae1e68bd-4ee8-4381-965c-3647a615b4d4 <<<<<<<< set_focus 1 J:GetFocusHandler http://localhost:8080/rfb/angular/index.html?s=Test&l=absolute&f=Test&w=640.0&h=480.0&editorid=8df42a0c-5c05-40a5-90fc-c410ef88542d&c_sessionid=ae1e68bd-4ee8-4381-965c-3647a615b4d4 J:CALLBACK OnSetFocus FOCUS_SOURCE_SYSTEM http://localhost:8080/rfb/angular/index.html?s=Test&l=absolute&f=Test&w=640.0&h=480.0&editorid=8df42a0c-5c05-40a5-90fc-c410ef88542d&c_sessionid=ae1e68bd-4ee8-4381-965c-3647a615b4d4 J:GetFocusHandler http://localhost:8080/rfb/angular/index.html?s=Test&l=absolute&f=Test&w=640.0&h=480.0&editorid=8df42a0c-5c05-40a5-90fc-c410ef88542d&c_sessionid=ae1e68bd-4ee8-4381-965c-3647a615b4d4 J:CALLBACK OnGotFocus http://localhost:8080/rfb/angular/index.html?s=Test&l=absolute&f=Test&w=640.0&h=480.0&editorid=8df42a0c-5c05-40a5-90fc-c410ef88542d&c_sessionid=ae1e68bd-4ee8-4381-965c-3647a615b4d4 J:Forcing focus to SWT canvas: true http://localhost:8080/rfb/angular/index.html?s=Test&l=absolute&f=Test&w=640.0&h=480.0&editorid=8df42a0c-5c05-40a5-90fc-c410ef88542d&c_sessionid=ae1e68bd-4ee8-4381-965c-3647a615b4d4 <<<<<<<< set_focus 1 J:GetFocusHandler http://localhost:8080/rfb/angular/index.html?s=Test&l=absolute&f=Test&w=640.0&h=480.0&editorid=8df42a0c-5c05-40a5-90fc-c410ef88542d&c_sessionid=ae1e68bd-4ee8-4381-965c-3647a615b4d4 J:CALLBACK OnSetFocus FOCUS_SOURCE_SYSTEM http://localhost:8080/rfb/angular/index.html?s=Test&l=absolute&f=Test&w=640.0&h=480.0&editorid=8df42a0c-5c05-40a5-90fc-c410ef88542d&c_sessionid=ae1e68bd-4ee8-4381-965c-3647a615b4d4 <<<<<<<< set_focus 0

i can fix this by disabling the setFocus() call to the browser instance by changing \

focusHandler.on_set_focus.set((focusHandler, browser_1, focusSource) -> {
        debugPrint("CALLBACK OnSetFocus " + focusSource);
        if (!isFocusControl() && false) {

in Chromium.java (so adding that false)

Then everything works fine for me, what are we trying to do there?

Why do we call isFocusControl() om the WebBrowser instance which as far as i can see quickly always will return false
And then set the focus to the chromium?
or do we kind of mean that we want todo: if (!chromium.isFocusControl()
and if that is not the case then transfer the focus to it?
That also seems to work for me

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.