Our company's app encountered a crash, but this problem is not necessarily present, I can not reproduce the problem now, we can provide me with the next solution to ideas
id.finalize() id is RandomAccessFile's Subclass .
this STACK_TRACE is :
java.util.concurrent.TimeoutException: id.finalize() timed out after 10 seconds
at libcore.io.Posix.fstat(Native Method)
at libcore.io.ForwardingOs.fstat(ForwardingOs.java:56)
at libcore.io.BlockGuardOs.close(BlockGuardOs.java:60)
at libcore.io.IoUtils.close(IoUtils.java:43)
at java.io.RandomAccessFile.close(RandomAccessFile.java:166)
at java.io.RandomAccessFile.finalize(RandomAccessFile.java:175)
at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:194)
at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:176)
at java.lang.Thread.run(Thread.java:841)
This sounds like broken memory that caused writes to it to take too long. Happens when you use bad sd cards. You should do a stress test and write many bytes to a file and close it.
Related
I'm pretty new to Android programming and I had a little project for an Android VPN firewall-sortofthing in mind, based on this GitHub repo: https://github.com/hexene/LocalVPN (so on top of VpnService)
The problem is that, no edits done to the code from the original repo, the VPN stops working after a while (after seconds usually). By that I mean internet connection is lost in all applications, so I guess packets stop flowing through the VPN. It happens randomly and seemingly with no triggering event. Again, I edited 0 lines from the code.
What I've tried so far is:
Using startForeground() as suggested here. Nothing changes.
Having a permanent high priority notification showing to prevent the service from stopping (although I don't know if the service stopping is the cause.
Only allowing certain apps in the VPN with Builder.addAllowedApplication(). This didn't work, as expected.
Anyone have any ideas or wisdom to share? Would be much appreciated!
Edit: the Log, when internet stops working, says this:
03-16 00:52:18.904 13182-13260/xyz.hexene.localvpn E/TCPInput: Network read error: 172.217.23.67:443:42746
java.io.IOException: Connection reset by peer
at sun.nio.ch.FileDispatcherImpl.read0(Native Method)
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43)
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
at sun.nio.ch.IOUtil.read(IOUtil.java:192)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:382)
at xyz.hexene.localvpn.TCPInput.processInput(TCPInput.java:133)
at xyz.hexene.localvpn.TCPInput.run(TCPInput.java:72)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:776)
I've seen that there is tons of posts like this, but couldn't find one that helps me.
I've read in one of them that this a generic error, and it depends on what you are doing.
In my case, I've created a socket, got its input and output stream and use the output to send some data. The strange thing is that I can send things and the server receives them. But I get this error pretty often. Like, once every 5 minutes.
Don't know if might help, but at first I had the soTimeout of the socket as 10 seconds. After reading some articles, I've increased it to 1 minute.
Don't know if I can add code that helps, because I litterally have the error when I do
output.write(byte[])
but if you think it might be something I could add, feel free to ask
Thanks in advance
In my android app when I want to upload a file with size of 2MB and more, it throws this Exception:
java.net.SocketTimeoutException: timeout at java.lang.Thread.run(Thread.java:841)
caused by: java.net.SocketException: Socket is closed at
org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.checkOpen(OpenSSLSocketImpl.java:237) at
org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.access$100(OpenSSLSocketImpl.java:63) at
org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl$SSLOutputStream.write(OpenSSLSocketImpl.java:723) at
okio.Okio$1.write(Okio.java:80) at
okio.AsyncTimeout$1.write(AsyncTimeout.java:155)
There is no problem with uploading less than 2MB and every thing work fine.
How do I modify file upload socket timeout and exception?
ok, for one whom might get stuck on this like me I must say there is some reasons for this exception like weak connection,wifi poor signal,low read write and connect time out and etc...
check all the situations and if did't got work you can use below lines:
i ended up this by adding this line of code:
OkHttpClient.setRetryOnConnectionFailure(true);
and setting more time out period
OkHttpClient.setConnectTimeout(10, TimeUnit.MINUTES);
OkHttpClient.setReadTimeout(10, TimeUnit.MINUTES);
OkHttpClient.setWriteTimeout(10, TimeUnit.MINUTES);
I want to know if setting this 10 minutes may cause a problem?
i will be so grateful if some one could tell me
First of all thanks in advance....i hope you can help me, i am a bit lost in this.
I am asking here besides there is a lost of threads talking about this, because i do not find a solution here neither in internet.... it seems to happen 99% on Samsung devices, since 4.2 version. And i really hope i am not the first one asking this and you can give me an answer, whatever is good or bad :). But i do not know if it is a Samsung issue or general, i also have seen it in other devices but only a few crashes...in samsung is thousands... ¿?¿?
We have in our apps crashlitycs integrated, and from some time ago, we started to receive different crashes, but we do not even know if they are crashes for real or not. The exception is being throw is:
Fatal Exception: java.util.concurrent.TimeoutException
com.android.internal.os.BinderInternal$GcWatcher.finalize() timed out after 10 seconds
It happens in different objects: BinderInternal, Binder, NativeDecimalFormat, BinderProxy, CloseGuard, WindowsCursor etc.
This did not happen before...and when i am trying to look in internet i just get a lot people is affected but there is no solution.
My biggest fear is....when is happening? is crashing people when using the app or just in background? is it crashing with the Android OS message "the app stopped suddenly"? or is something internal i can "ignore" ?
Is it happening all days a lot times every day, is it constant....but we cannot reproduce it anyway.......do you know what is this?
I give you some links they talk about garbage collector issue, or bad finalize/internet call issue....
How to handle :java.util.concurrent.TimeoutException: android.os.BinderProxy.finalize() timed out after 10 seconds errors?
https://www.reddit.com/r/androiddev/comments/3am3yb/some_crash_reports_have_nothing_to_do_with_my_app/
https://github.com/andstatus/andstatus/issues/301
http://openstackwiki.org/wiki/Java.util.concurrent.TimeoutException_(android.media.MediaMetadataRetriever.finalize)_Zeit%C3%BCberschreitung_nach_10_Sekunden
We solved the problem by stopping the FinalizerWatchdogDaemon.
public static void fix() {
try {
Class clazz = Class.forName("java.lang.Daemons$FinalizerWatchdogDaemon");
Method method = clazz.getSuperclass().getDeclaredMethod("stop");
method.setAccessible(true);
Field field = clazz.getDeclaredField("INSTANCE");
field.setAccessible(true);
method.invoke(field.get(null));
}
catch (Throwable e) {
e.printStackTrace();
}
}
You can call the method in Application's lifecycle, like attachBaseContext().
For the same reason, you also can specific the phone's manufacture to fix the problem, it's up to you.
I got mail from a user who has a lot of apps installed that he has problems when my app gathers activity info with this code:
getPackageManager().queryIntentActivities(mAinIntent, 0)
whole source here: https://github.com/ligi/FAST
this is what happens
Caused by: java.lang.RuntimeException: Package manager has died
at android.app.ApplicationPackageManager.queryIntentActivities(ApplicationPackageManager.java:479)
at org.ligi.fast.BaseAppGatherAsyncTask.doInBackground(BaseAppGatherAsyncTask.java:34)
at org.ligi.fast.BaseAppGatherAsyncTask.doInBackground(BaseAppGatherAsyncTask.java:1)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
... 5 more
Caused by: android.os.TransactionTooLargeExceptionTransactionTooLargeException
at android.os.BinderProxy.transact(Native Method)
at android.content.pm.IPackageManager$Stub$Proxy.queryIntentActivities(IPackageManager.java:2230)
at android.app.ApplicationPackageManager.queryIntentActivities(ApplicationPackageManager.java:473)
... 9 more
Log:
0 D: Writing unhandled exception to: /data/data/org.ligi.fast/files/3.7-1364933885194.tracedroid
there seems to be a problem that I am running against the 1mb border, but how to get out of there? How else can I get the needed info? Is there a way to chunk up the data?
I ran into this error a while ago with the same user input. Though my thrown event was different. I ended up catching the exception and reporting back the user gracefully that there were too many apps installed with the ability to handle . Out of several hundred thousand installs I have only seen this error off-handedly less than five times for a project, I know that isn't an excuse but some devices just don't have the heap to handle indexing the intents of each application installed on the device.