Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

Crash when stop browser and browser again with Rx2dnssd #69

Open
tungds opened this issue Apr 18, 2019 · 2 comments
Open

Crash when stop browser and browser again with Rx2dnssd #69

tungds opened this issue Apr 18, 2019 · 2 comments

Comments

@tungds
Copy link

tungds commented Apr 18, 2019

Hello,
I using Rx2Dnssd to discovery ip address for my host.
I add timeout 15s. If after timeout ip cannot resolve, i stop browser and discovery again.
Sometimes, native crash happens

2019-04-18 09:52:21.195 JNI DETECTED ERROR IN APPLICATION: thread Thread[42,tid=17775,Native,Thread*=0x73fdcd4800,peer=0x12e40aa8,"DNS-SDEmbedded"] using JNIEnv* from thread Thread[33,tid=17897,Runnable,Thread*=0x73fdcd6000,peer=0x12e416c8,"DNS-SDEmbedded"]
2019-04-18 09:52:21.196 in call to NewByteArray
2019-04-18 09:52:21.196 from int com.github.druk.dnssd.DNSSDEmbedded.nativeLoop()
2019-04-18 09:52:21.196 "DNS-SDEmbedded" daemon prio=10 tid=42 Runnable
2019-04-18 09:52:21.196 | group="main" sCount=0 dsCount=0 flags=0 obj=0x12e40aa8 self=0x73fdcd4800
2019-04-18 09:52:21.196 | sysTid=17775 nice=-8 cgrp=default sched=0/0 handle=0x73ffd374f0
2019-04-18 09:52:21.196 | state=R schedstat=( 7815268 4084309 21 ) utm=0 stm=0 core=4 HZ=100
2019-04-18 09:52:21.196 | stack=0x73ffc34000-0x73ffc36000 stackSize=1041KB
2019-04-18 09:52:21.196 | held mutexes= "mutator lock"(shared held)
2019-04-18 09:52:21.196 native: #00 pc 00000000003cb35c /system/lib64/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits>&, int, BacktraceMap*, char const*, art::ArtMethod*, void*, bool)+220)
2019-04-18 09:52:21.196 native: #1 pc 000000000049aca8 /system/lib64/libart.so (art::Thread::DumpStack(std::__1::basic_ostream<char, std::__1::char_traits>&, bool, BacktraceMap*, bool) const+352)
2019-04-18 09:52:21.196 native: #2 pc 00000000002ec584 /system/lib64/libart.so (art::JavaVMExt::JniAbort(char const*, char const*)+972)
2019-04-18 09:52:21.196 native: #3 pc 00000000002ec9a4 /system/lib64/libart.so (art::JavaVMExt::JniAbortV(char const*, char const*, std::__va_list)+108)
2019-04-18 09:52:21.196 native: #4 pc 00000000000fddf8 /system/lib64/libart.so (art::(anonymous namespace)::ScopedCheck::AbortF(char const*, ...)+144)
2019-04-18 09:52:21.196 native: #5 pc 00000000000fc4d0 /system/lib64/libart.so (art::(anonymous namespace)::ScopedCheck::CheckPossibleHeapValue(art::ScopedObjectAccess&, char, art::(anonymous namespace)::JniValueType)+416)
2019-04-18 09:52:21.196 native: #6 pc 00000000000fbb1c /system/lib64/libart.so (art::(anonymous namespace)::ScopedCheck::Check(art::ScopedObjectAccess&, bool, char const*, art::(anonymous namespace)::JniValueType*)+628)
2019-04-18 09:52:21.196 native: #7 pc 0000000000106c5c /system/lib64/libart.so (art::(anonymous namespace)::CheckJNI::NewPrimitiveArray(char const*, _JNIEnv*, int, art::Primitive::Type)+684)
2019-04-18 09:52:21.196 native: #8 pc 0000000000047a98 /data/app/com.vin.smarthome-akda4OtlY4kurNBT928u7w==/lib/arm64/libjdns_sd_embedded.so (???)
2019-04-18 09:52:21.196 native: #9 pc 0000000000031d68 /data/app/com.vin.smarthome-akda4OtlY4kurNBT928u7w==/lib/arm64/libjdns_sd_embedded.so (???)
2019-04-18 09:52:21.196 native: #10 pc 0000000000005b30 /data/app/com.vin.smarthome-akda4OtlY4kurNBT928u7w==/lib/arm64/libjdns_sd_embedded.so (???)
2019-04-18 09:52:21.196 native: #11 pc 000000000000fedc /data/app/com.vin.smarthome-akda4OtlY4kurNBT928u7w==/lib/arm64/libjdns_sd_embedded.so (???)
2019-04-18 09:52:21.196 native: #12 pc 0000000000011750 /data/app/com.vin.smarthome-akda4OtlY4kurNBT928u7w==/lib/arm64/libjdns_sd_embedded.so (???)
2019-04-18 09:52:21.196 native: #13 pc 000000000002f6d0 /data/app/com.vin.smarthome-akda4OtlY4kurNBT928u7w==/lib/arm64/libjdns_sd_embedded.so (???)
2019-04-18 09:52:21.196 native: #14 pc 000000000002f4e8 /data/app/com.vin.smarthome-akda4OtlY4kurNBT928u7w==/lib/arm64/libjdns_sd_embedded.so (???)
2019-04-18 09:52:21.196 native: #15 pc 000000000002faa8 /data/app/com.vin.smarthome-akda4OtlY4kurNBT928u7w==/lib/arm64/libjdns_sd_embedded.so (???)
2019-04-18 09:52:21.196 native: #16 pc 000000000003d6b0 /data/app/com.vin.smarthome-akda4OtlY4kurNBT928u7w==/lib/arm64/libjdns_sd_embedded.so (???)
2019-04-18 09:52:21.196 native: #17 pc 000000000003d7d8 /data/app/com.vin.smarthome-akda4OtlY4kurNBT928u7w==/lib/arm64/libjdns_sd_embedded.so (???)
2019-04-18 09:52:21.196 native: #18 pc 000000000056a9e0 /system/lib64/libart.so (art_quick_generic_jni_trampoline+144)
2019-04-18 09:52:21.196 native: #19 pc 0000000000561c4c /system/lib64/libart.so (art_quick_invoke_static_stub+604)
2019-04-18 09:52:21.196 native: #20 pc 00000000000cff60 /system/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+232)
2019-04-18 09:52:21.196 native: #21 pc 00000000002862f8 /system/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+344)
2019-04-18 09:52:21.196 native: #22 pc 00000000002802b4 /system/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+948)
2019-04-18 09:52:21.196 native: #23 pc 0000000000532154 /system/lib64/libart.so (MterpInvokeStatic+204)
2019-04-18 09:52:21.196 native: #24 pc 0000000000554194 /system/lib64/libart.so (ExecuteMterpImpl+14612)
2019-04-18 09:52:21.196 native: #25 pc 000000000031959c /dev/ashmem/dalvik-classes.dex extracted in memory from /data/app/com.vin.smarthome-akda4OtlY4kurNBT928u7w==/split_lib_dependencies_apk.apk_17263_17263 (deleted) (com.github.druk.dnssd.DNSSDEmbedded$1.run+116)
2019-04-18 09:52:21.196 native: #26 pc 0000000000259db0 /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.3150795007+496)
2019-04-18 09:52:21.196 native: #27 pc 0000000000521390 /system/lib64/libart.so (artQuickToInterpreterBridge+1032)
2019-04-18 09:52:21.196 native: #28 pc 000000000056aafc /system/lib64/libart.so (art_quick_to_interpreter_bridge+92)
2019-04-18 09:52:21.196 native: #29 pc 0000000000561988 /system/lib64/libart.so (art_quick_invoke_stub+584)
2019-04-18 09:52:21.196 native: #30 pc 00000000000cff40 /system/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+200)
2019-04-18 09:52:21.196 native: #31 pc 0000000000467d60 /system/lib64/libart.so (art::(anonymous namespace)::InvokeWithArgArray(art::ScopedObjectAccessAlreadyRunnable const&, art::ArtMethod*, art::(anonymous namespace)::ArgArray*, art::JValue*, char const*)+104)
2019-04-18 09:52:21.196 native: #32 pc 0000000000468e28 /system/lib64/libart.so (art::InvokeVirtualOrInterfaceWithJValues(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, jvalue*)+424)
2019-04-18 09:52:21.196 native: #33 pc 00000000004946b0 /system/lib64/libart.so (art::Thread::CreateCallback(void*)+1120)
2019-04-18 09:52:21.197 native: #34 pc 0000000000084df8 /system/lib64/libc.so (__pthread_start(void*)+208)
2019-04-18 09:52:21.197 native: #35 pc 0000000000023ac4 /system/lib64/libc.so (__start_thread+68)
2019-04-18 09:52:21.197 at com.github.druk.dnssd.DNSSDEmbedded.nativeLoop(Native method)
2019-04-18 09:52:21.197 at com.github.druk.dnssd.DNSSDEmbedded$1.run(DNSSDEmbedded.java:84)

And mycode below:

        try {
            mDisposable = mRxDnssd?.browse(SERVICE_TYPE, DOMAIN)
                    ?.compose(mRxDnssd?.resolve())
                    ?.compose(mRxDnssd?.queryIPRecords())
                    ?.subscribeOn(Schedulers.io())
                    ?.observeOn(AndroidSchedulers.mainThread())
                    ?.subscribe({ bonjourService ->

                        try {
                            val address = bonjourService.inetAddresses
                            for (inetAddress in address) {

                                if (inetAddress is Inet4Address) {
                                    val host = inetAddress.hostAddress
                                    mNsdDiscoveryListener.onDiscoveryResolveSuccess(host)
                                    LogUtils.d("address $host")
                                } else {
                                    //metaInfo.put("Address IPv6", service.getInet6Address().getHostAddress() + ":" + service.getPort())
                                }
                            }

                            isDoneResolver = true
                        } catch (e: UnknownHostException) {
                            e.printStackTrace()
                        }
                    }, { throwable ->
                        LogUtils.e("error: ${throwable.message}")
                        mNsdDiscoveryListener.onDiscoveryFail()
                    })
        } catch (e: DNSSDException) {
            e.printStackTrace()
            LogUtils.e("error: ${e.message}")
            mNsdDiscoveryListener.onDiscoveryFail()
        }

Could you help me?
I uploaded full log with attached file.

full_log.txt

@bobekos
Copy link

bobekos commented Feb 17, 2021

@andriydruk
Any news to this? It seems like the flowable does nothin on dispose. It should stop the service handler.

@bobekos
Copy link

bobekos commented Feb 18, 2021

@andriydruk @tungds
No this was my fault. I have tested the scenario were you are start and stop the search multiple types with the sample app and there is nothing crashing. That means there had to be a bug on my side.

And yes houston we have a problem here. This was my subscription for a "timeout-search":

//the _search.searchService() just return the default rxdnssd browse flowable.

Disposable job = _search.searchService()
	.startWith(//dummy item) //necessary because of the buffer compose which start only after first emission
	.distinct(//distinct double results)
	.compose(Transformers.buffer(50, timeout, TimeUnit.SECONDS)) //use buffer to collect services within the timeout
	.map(//remove the dummyitem)
	.observeOn(AndroidSchedulers.mainThread())
	.subscribe(result -> {
	    //do stuff
	}, throwable -> {
		//do stuff    
	});

I thought after the timeout the subscription would dispose itself. But thats wrong, because the flowable stream is of course still active. So i decied to take only the first element of the stream which is the result of the compose function and map the flowable to single. And TaDa everything is working fine now:

Disposable job = _search.searchService()
	.startWith(//dummy item) //necessary because of the buffer compose which start only after first emission
	.distinct(//distinct double results)
	.compose(Transformers.buffer(50, timeout, TimeUnit.SECONDS)) //use buffer to collect services within the timeout
	.map(//remove the dummyitem)
	.take(1)
        .singleOrError()
	.observeOn(AndroidSchedulers.mainThread())
	.subscribe(result -> {
	    //do stuff
	}, throwable -> {
		//do stuff    
	});

Now you can start this multiple times and nothing crashes.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants