openstreetmap / trac-tickets

Archived Trac Tickets
1 stars 1 forks source link

osmosis on android stops functioning after reading the first node #5461

Open openstreetmap-trac opened 3 years ago

openstreetmap-trac commented 3 years ago

Reporter: spyhunter99 [Submitted to the original trac issue database at 12.41pm, Tuesday, 8th August 2017]

Running osmosis 0.45 against the same dataset (tried with both pbf and bz2) . On JRE/JDK is performs well and reads the files with no problems. On Android, (v6). it looks like it reads the bounds of the document, then the first node, and then suddenly stops without warning, exception or output.

I've attempted stepping through the debugger but I've been unable to find the source of the issue. The callback for process(Entity...) just stop firing. I think what's happening is that android is seeing some api call and is changing it to NOOP at some point but I'm not sure what's going on.

Sample code below. Please source is here https://github.com/spyhunter99/osmreader

boolean pbf = false; CompressionMethod compression = CompressionMethod.None;

    if (file.getName().endsWith(".pbf")) {
        pbf = true;
    } else if (file.getName().endsWith(".gz")) {
        compression = CompressionMethod.GZip;
    } else if (file.getName().endsWith(".bz2")) {
        compression = CompressionMethod.BZip2;
    }

    RunnableSource reader;
    FileInputStream fis = null;
    if (pbf) {
        fis = new FileInputStream(file);
        reader = new crosby.binary.osmosis.OsmosisReader(
            fis);
    } else {
        reader = new XmlReader(file, false, compression);
    }

    reader.setSink(this);

    System.out.println("starting import");
    Thread readerThread = new Thread(reader);
    readerThread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
        Override
        public void uncaughtException(Thread thread, Throwable throwable) {
            System.out.println("import failed!");
            throwable.printStackTrace();

        }
    });
    readerThread.start();

    while (readerThread.isAlive()) {
        try {
            readerThread.join();
        } catch (InterruptedException e) {
    /* do nothing */
        }
    }