Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugger Viewer doesn't work, can't connect to ScrollView server #3000

Closed
ellislau opened this issue Jun 2, 2020 · 3 comments · Fixed by #4162
Closed

Debugger Viewer doesn't work, can't connect to ScrollView server #3000

ellislau opened this issue Jun 2, 2020 · 3 comments · Fixed by #4162

Comments

@ellislau
Copy link

ellislau commented Jun 2, 2020

Environment

  • Tesseract Version: 4.1.1
  • Commit Number: 4.1.1 Release
  • Platform: MacOS Catalina 10.15.5, Darwin Kernel Version 19.5.0

Current Behavior:

When using the parameter inter or interactive_display_mode, the application hangs.

Expected Behavior:

The debugger viewer window should open.

Suggested Fix:

The issue seems to be that ScrollView uses java.net.ServerSocket which always uses TCP, whereas the SVNetwork logic in svutil.cpp may look for either a TCP or UDP socket. In my case, it was looking for a UDP socket and was not able to successfully connect. Tentatively, it seems that passing an addrinfo hints object that sets ai_protocol to IPPROTO_TCP was sufficient to work around the problem (https://www.man7.org/linux/man-pages/man3/getaddrinfo.3.html).

@zdenop
Copy link
Contributor

zdenop commented Jun 4, 2020

please provide full information how to reproduce your problem.

@ivan-alaffia
Copy link

ivan-alaffia commented Feb 26, 2021

Seconded - the inter flag hangs indefinitely for me both on 4.1.1 and 5.0.0alpha, but works correctly on 4.0.0.

Platform: MacOS Big Sur 11.1

Steps to reproduce:

  1. Build Tesseract from source following this guide.
    Summary of steps:
export JAVA_VERSION=1.8
export PATH=/usr/local/bin:/usr/local/lib:/usr/local/sbin:$PATH

git clone https://github.com/tesseract-ocr/tesseract/
cd tesseract
./autogen.sh
./configure LDFLAGS="-L/usr/local/opt/icu4c/lib" \ 
    CPPFLAGS="-I/usr/local/opt/icu4c/include" \
    PKG_CONFIG_PATH=/usr/local/opt/icu4c/lib/pkgconfig:/usr/local/opt/libarchive/lib/pkgconfig:/usr/local/opt/libffi/lib/pkgconfig:/usr/local/opt/leptonica/lib/pkgconfig  \
    --enable-debug
make -j
sudo make install
make training
cd java
SCROLLVIEW_PATH=$(pwd) JAVA_VERSION=1.8 make ScrollView.jar
  1. Download English trained data following https://tesseract-ocr.github.io/tessdoc/Data-Files.html
  2. Download phototest.tif
  3. From the root tesseract directory, run TESSDATA_PREFIX=$(pwd)/tessdata SCROLLVIEW_PATH=$(pwd)/java tesseract phototest.tif test1 segdemo inter, following the Debug Viewer guide.

tfmorris added a commit to tfmorris/tesseract that referenced this issue Nov 11, 2023
Without any hints, we can end up with a UDP socket which won't
work with the TCP socket that the Java display server is
listening on. Use hints for TCP v4 so that we get the right
kind of socket returned.

Also, delete some obsolete comments nearby.
@tfmorris
Copy link
Contributor

I just ran into this as well and it took a fair amount of debug setup and head scratching to figure out what was going on, particularly since both sides of the communication are error free, but nothing happens because they're talking past each other. Lucky issue 3000!

@ellislau Thanks for reporting the problem. Your analysis was spot on. Here's what it looks like on my system:

$ java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=1044 -Xms512m -Xmx1024m -Djava.library.path=$SCROLLVIEW_PATH -cp $SCROLLVIEW_PATH/ScrollView.jar:$SCROLLVIEW_PATH/piccolo-1.2.jar:$SCROLLVIEW_PATH/piccolox-1.2.jar com.google.scrollview.ScrollView &
Listening for transport dt_socket at address: 1044
Socket started on port 8461
$ sudo lsof -i :8461
COMMAND    PID     USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
tesseract 3155 tfmorris    6u  IPv6 0xfb0634dc780d2b35      0t0  UDP localhost:57154->localhost:8461
java      3177 tfmorris    8u  IPv6 0xfb0634dca1d53275      0t0  TCP *:8461 (LISTEN)

Note that the display server is listening on TCP port 8461 while the client is connected to UDP port 8461, which, of course, isn't the same thing at all.

I put PR #4162 up with a tested fix which works for me. @ellislau I suspect you had the same fix. If you state your suggestion in the form of a PR, that'd probably get things fixed quicker. The project operates with pretty much a skeleton crew, so every little contribution helps.

stweil added a commit that referenced this issue Nov 11, 2023
Force TCP v4 for socket to ScrollView server. Fixes #3000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants