JabRef / JabRef-Browser-Extension

Browser extension for JabRef to allow importing of new items directly from the browser.
https://www.jabref.org/
GNU Affero General Public License v3.0
84 stars 22 forks source link

Import does not "reuse" Jabref window #443

Closed funnym0nk3y closed 2 years ago

funnym0nk3y commented 2 years ago

Importing a entry via the extension does not use the open Jabref window but instead opens a new jabref window. The Firefox extension shows grafik and I'm using

Restarting Firefox and Jabref does not help.

tobiasdiez commented 2 years ago

You might want to configure JabRef so that new entries are always imported in an already opened instance of JabRef. For this, activate "Listen to remote operation on port" under the "Network" tab of the JabRef Preferences.

Does this help?

funnym0nk3y commented 2 years ago

That option is activated in my configuration and listens on port 6050. Sometimes the extension reports a connection loss, though I could not reproduce that. The entry shows up in jabref though.

EDIT

Just as I tried it again there was another connection loss. This is the console output grafik

tobiasdiez commented 2 years ago

These errors are strange but shouldn't be related to the "new window" issue. Maybe https://stackoverflow.com/questions/65310749/failed-to-fetch-region-new-errorno-result-resource-gre-modules-region is helpful for fixing this.

For the new window, do you see a difference in the behavior in the following two settings?

Siphalor commented 2 years ago

I think I have the same issue with the following setup:

JabRef 5.5--2022-01-17--27a05c7
Linux 5.4.0-105-generic amd64 
Java 16.0.2 
JavaFX 17.0.1+1

The extension version is 2.5, Firefox finds no updates.

I also already had the port activated in JabRef, and the extension preferences look exactly the same as posted by funnym0nk3y.

Now for your two suggested settings:

1. Existing JabRef instance

When JabRef is already opened, then a new instance is created that shows the import screen. No errors in the extension log. The JabRef log of the new extension obviously fails to listen on the port as the old instance is already blocking it:

Event log
Fix SSL exceptions by accepting ALL certificates
  Port is blocked
  java.net.BindException: Address already in use
    at java.base/sun.nio.ch.Net.bind0(Native Method)
    at java.base/sun.nio.ch.Net.bind(Unknown Source)
    at java.base/sun.nio.ch.Net.bind(Unknown Source)
    at java.base/sun.nio.ch.NioSocketImpl.bind(Unknown Source)
    at java.base/java.net.ServerSocket.bind(Unknown Source)
    at java.base/java.net.ServerSocket.(Unknown Source)
    at org.jabref@5.5.60000/org.jabref.logic.remote.server.RemoteListenerServer.(Unknown Source)
    at org.jabref@5.5.60000/org.jabref.logic.remote.server.RemoteListenerServerThread.(Unknown Source)
    at org.jabref@5.5.60000/org.jabref.logic.remote.server.RemoteListenerServerLifecycle.open(Unknown Source)
    at org.jabref@5.5.60000/org.jabref.logic.remote.server.RemoteListenerServerLifecycle.openAndStart(Unknown Source)
    at org.jabref@5.5.60000/org.jabref.gui.JabRefMain.handleMultipleAppInstances(Unknown Source)
    at org.jabref@5.5.60000/org.jabref.gui.JabRefMain.start(Unknown Source)
    at org.jabref.merged.module@5.5.60000/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(Unknown Source)
    at org.jabref.merged.module@5.5.60000/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(Unknown Source)
    at org.jabref.merged.module@5.5.60000/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(Unknown Source)
    at java.base/java.security.AccessController.doPrivileged(Unknown Source)
    at org.jabref.merged.module@5.5.60000/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(Unknown Source)
    at org.jabref.merged.module@5.5.60000/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
    at org.jabref.merged.module@5.5.60000/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
    at org.jabref.merged.module@5.5.60000/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(Unknown Source)
    at java.base/java.lang.Thread.run(Unknown Source)

  Not updating theme because it hasn't changed
  Theme set to Theme{type=EMBEDDED, name='Dark.css'} with base css StyleSheet{jrt:/org.jabref/org/jabref/gui/Base.css}
  Index path for /d/university/sem/report/bibliography.bib is /home/siphalor/.local/share/JabRef/0.5a
  Import canceled

When the new instance is now closed, then an error is logged by the extension:

Extension error

    Uncaught (in promise) Error: Could not establish connection. Receiving end does not exist.
      sendBibTexToJabRef moz-extension://cbff6c43-c57a-4666-98f9-00645ee90c93/connector.js:134
  connector.js:134:22
      apply self-hosted:2675
      applySafeWithoutClone resource://gre/modules/ExtensionCommon.jsm:694
      wrapPromise resource://gre/modules/ExtensionCommon.jsm:942
      (Async: promise callback)
      wrapPromise resource://gre/modules/ExtensionCommon.jsm:903
      wrapPromise resource://gre/modules/ExtensionCommon.jsm:902
      callAsyncFunction resource://gre/modules/ExtensionCommon.jsm:1139
      callAsyncFunction resource://gre/modules/ExtensionChild.jsm:733
      callAndLog resource://gre/modules/ExtensionChild.jsm:704
      callAsyncFunction resource://gre/modules/ExtensionChild.jsm:732
      stub resource://gre/modules/Schemas.jsm:2838
      sendBibTexToJabRef moz-extension://cbff6c43-c57a-4666-98f9-00645ee90c93/connector.js:134
      (Async: promise callback)
      sendBibTexToJabRef moz-extension://cbff6c43-c57a-4666-98f9-00645ee90c93/connector.js:131
      callMethodWithCookies moz-extension://cbff6c43-c57a-4666-98f9-00645ee90c93/connector.js:44
      (Async: promise callback)
      callMethodWithCookies moz-extension://cbff6c43-c57a-4666-98f9-00645ee90c93/connector.js:44
      (Async: promise callback)
      callMethodWithCookies moz-extension://cbff6c43-c57a-4666-98f9-00645ee90c93/connector.js:17
      receiveMessage moz-extension://cbff6c43-c57a-4666-98f9-00645ee90c93/external-scripts/messaging.js:85
      init moz-extension://cbff6c43-c57a-4666-98f9-00645ee90c93/external-scripts/messaging.js:179
      apply self-hosted:2675
      raw resource://gre/modules/ExtensionCommon.jsm:2560
      wrapResponse resource://gre/modules/ExtensionChild.jsm:219
      responses resource://gre/modules/ExtensionChild.jsm:188
      map self-hosted:183
      emit resource://gre/modules/ExtensionChild.jsm:188
      recvRuntimeMessage resource://gre/modules/ExtensionChild.jsm:370
      recvRuntimeMessage self-hosted:1121
      _recv resource://gre/modules/ConduitsChild.jsm:82
      receiveMessage resource://gre/modules/ConduitsChild.jsm:188

2. JabRef is not running

Having no instances opened correctly opens a new instance of JabRef with the import screen. The JabRef instance also correctly binds to the port. Triggering a second import directly results in the behavior described at 1.

I'm ready to provide more information if needed.

pashadag commented 2 years ago

same problem here

tobiasdiez commented 2 years ago

Just to make sure we rule out the obvious, only one instance is opened of JabRef even if you start JabRef a second time manually say through the startmenu/taskbar or desktop icon, right?

One final thing to hopefully track down the root for this issue, could you please run <path to jabref install directory >/jabref.exe and <path to jabref install directory >/jabref.exe -importToOpen <path to some bib file> from the command console (on linux replace jabref.exe by bin/JabRef)? Thanks for your help!

Siphalor commented 2 years ago

Indeed, launching JabRef multiple times seems to generally create new instances.

Running the instances from command line leads to the same result, logs are below:

First Instance

Apr 18, 2022 10:43:36 PM com.sun.javafx.application.PlatformImpl startup
WARNING: Unsupported JavaFX configuration: classes were loaded from 'module org.jabref.merged.module', isAutomatic: false, isOpen: true
2022-04-18 22:43:36 [JavaFX Application Thread] org.jabref.logic.net.URLDownload.bypassSSLVerification()
WARN: Fix SSL exceptions by accepting ALL certificates
2022-04-18 22:43:38 [JavaFX Application Thread] org.jabref.gui.theme.ThemeManager.updateThemeSettings()
INFO: Not updating theme because it hasn't changed
2022-04-18 22:43:38 [JavaFX Application Thread] org.jabref.gui.theme.ThemeManager.updateThemeSettings()
INFO: Theme set to Theme{type=EMBEDDED, name='Dark.css'} with base css StyleSheet{jrt:/org.jabref/org/jabref/gui/Base.css}

(JabRef:498198): Gdk-WARNING **: 22:43:39.783: XSetErrorHandler() called with a GDK error trap pushed. Don't do that.
2022-04-18 22:43:40 [JavaFX Application Thread] org.jabref.model.database.BibDatabaseContext.getFulltextIndexPath()
INFO: Index path for /d/example/bibliography.bib is /home/siphalor/.local/share/JabRef/0.5a
Second Instance with -importToOpen

Apr 18, 2022 10:44:34 PM com.sun.javafx.application.PlatformImpl startup
WARNING: Unsupported JavaFX configuration: classes were loaded from 'module org.jabref.merged.module', isAutomatic: false, isOpen: true
2022-04-18 22:44:34 [JavaFX Application Thread] org.jabref.logic.net.URLDownload.bypassSSLVerification()
WARN: Fix SSL exceptions by accepting ALL certificates
Importing in unknown format: ../example/bibliography.bib
Format used: BibTeX
2022-04-18 22:44:36 [JavaFX Application Thread] org.jabref.logic.remote.server.RemoteListenerServerLifecycle.open()
WARN: Port is blocked: java.net.BindException: Address already in use
    at java.base/sun.nio.ch.Net.bind0(Native Method)
    at java.base/sun.nio.ch.Net.bind(Unknown Source)
    at java.base/sun.nio.ch.Net.bind(Unknown Source)
    at java.base/sun.nio.ch.NioSocketImpl.bind(Unknown Source)
    at java.base/java.net.ServerSocket.bind(Unknown Source)
    at java.base/java.net.ServerSocket.(Unknown Source)
    at org.jabref@5.5.60000/org.jabref.logic.remote.server.RemoteListenerServer.(Unknown Source)
    at org.jabref@5.5.60000/org.jabref.logic.remote.server.RemoteListenerServerThread.(Unknown Source)
    at org.jabref@5.5.60000/org.jabref.logic.remote.server.RemoteListenerServerLifecycle.open(Unknown Source)
    at org.jabref@5.5.60000/org.jabref.logic.remote.server.RemoteListenerServerLifecycle.openAndStart(Unknown Source)
    at org.jabref@5.5.60000/org.jabref.gui.JabRefMain.handleMultipleAppInstances(Unknown Source)
    at org.jabref@5.5.60000/org.jabref.gui.JabRefMain.start(Unknown Source)
    at org.jabref.merged.module@5.5.60000/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(Unknown Source)
    at org.jabref.merged.module@5.5.60000/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(Unknown Source)
    at org.jabref.merged.module@5.5.60000/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(Unknown Source)
    at java.base/java.security.AccessController.doPrivileged(Unknown Source)
    at org.jabref.merged.module@5.5.60000/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(Unknown Source)
    at org.jabref.merged.module@5.5.60000/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
    at org.jabref.merged.module@5.5.60000/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
    at org.jabref.merged.module@5.5.60000/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(Unknown Source)
    at java.base/java.lang.Thread.run(Unknown Source)
2022-04-18 22:44:36 [JavaFX Application Thread] org.jabref.gui.theme.ThemeManager.updateThemeSettings()
INFO: Not updating theme because it hasn't changed
2022-04-18 22:44:36 [JavaFX Application Thread] org.jabref.gui.theme.ThemeManager.updateThemeSettings()
INFO: Theme set to Theme{type=EMBEDDED, name='Dark.css'} with base css StyleSheet{jrt:/org.jabref/org/jabref/gui/Base.css}

(JabRef:498378): Gdk-WARNING **: 22:44:37.897: XSetErrorHandler() called with a GDK error trap pushed. Don't do that.
2022-04-18 22:44:38 [JavaFX Application Thread] org.jabref.model.database.BibDatabaseContext.getFulltextIndexPath()
INFO: Index path for /d/example/bibliography.bib is /home/siphalor/.local/share/JabRef/0.5a
2022-04-18 22:44:54 [JavaFX Application Thread] org.jabref.gui.JabRefDialogService.notify()
INFO: Import canceled

Running with --debug or without leads to no differences in the log.

Siphalor commented 2 years ago

Looking through the JabRef issues, this is probably a result of JabRef/jabref#8653.

jakkarth commented 2 years ago

Hopefully this is fixed in the next release of JabRef :)