<html>
    <head>
      <base href="https://bugs.documentfoundation.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_UNCONFIRMED "
   title="UNCONFIRMED - Use a single thread for data transmission"
   href="https://bugs.documentfoundation.org/show_bug.cgi?id=111398">111398</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Use a single thread for data transmission
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>Impress Remote
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>UNCONFIRMED
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Android app
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>libreoffice-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>andrzej@ahunt.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>We currently try to spawn a new thread every time we need to post a command
from the app:
<a href="https://gerrit.libreoffice.org/gitweb?p=impress_remote.git;a=blob;f=android/sdremote/mobile/src/main/java/org/libreoffice/impressremote/communication/CommandsTransmitter.java;h=1c01618741b64938f24be6edbbe4d8665cfd5ec2;hb=refs/heads/master#l42">https://gerrit.libreoffice.org/gitweb?p=impress_remote.git;a=blob;f=android/sdremote/mobile/src/main/java/org/libreoffice/impressremote/communication/CommandsTransmitter.java;h=1c01618741b64938f24be6edbbe4d8665cfd5ec2;hb=refs/heads/master#l42</a>

I'm currently converting this to an AsyncTask which is already an improvement
(depending on version, AsyncTask uses a single thread, or pool of threads) -
however we should ideally ensure only a single thread is used for all
communication, which we could do by creating a handler specific to the socket
and posting the AsyncTask to that handler.

Rather oddly, this method actually crashed on my N6P running Android 7.1 (i.e.
before the AsyncTask conversion):
<span class="quote">> android.os.NetworkOnMainThreadException
> at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1303)
> at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:111)</span >

I'm guessing Android's StrictMode thread detection gets confused when you
create arbitrary threads, there's probably not much point in debugging that
since creating Thread's in that way is very un-Androidy anyway.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>