Throwable.printStackTrace(PrintStream)

36 views
Skip to first unread message

reportm...@gmail.com

unread,
May 15, 2021, 3:28:15 PM5/15/21
to TeaVM
I've added a developer console to my app and I when my app hits an uncaught exception, it tries to print the exception and stack trace to a text area in the window.

My problem is that throwable.printStackTrace(printStream) only prints the throwable message and doesn't seem to have any StackTraceElements (even if I call fillInStackTrace() explicitly).

I see in the source for TThrowable that fillInStackTrace() short-circuits if PlatformDetector.isLowLevel(). Is there any way for me to get a full stack trace string?

jeff

Alexey Andreev

unread,
May 17, 2021, 2:51:57 AM5/17/21
to TeaVM
Hello. I believe that exposing stack trace to a user is a bad idea. Regular users have no clue how to deal with stack trace. If your application is not open source, stack traces can expose internal details of your application, which is not desirable in most cases.

But you mentioned "developer console". Does this mean you allow users Java code, compile it somehow and run JS? If you need stacktrace in this case, please note that JS is not sufficient for this purpose. You also need debugging information which is huge. You should also define $rt_decodeStack function before loading TeaVM code. This function takes native JavaScript stack trace and produces array of objects that represent JavaScript stack trace (you better examine runtime.js to find how this object should look like). You can look at devserver source code to see how it produces Java stack traces (tools/devserver). Also take a look at org.teavm.tooling.deobfuscate.js.Deobfuscator class.

Jeff Martin

unread,
May 17, 2021, 9:32:31 AM5/17/21
to TeaVM, Alexey Andreev
Thanks Alexey! No my ‘SnapKit developer console’ isn’t anything that fancy, it mostly has tools to inspect the SnapKit view hierarchy and other graphics information (repaint regions, repaint frame rate). It is available under the “Tools” menu (or by hitting ‘control-control’ quickly).


https://reportmill.com/snaptea/SnapCharts/

I hadn’t thought of the security issue (all my apps have source code available, but I see how it makes sense), and it makes perfect sense that the stack would be useless when the JS is minimized. But the stack traces you provide when I am in development mode on Chrome are amazing (I’m not sure why Safari doesn’t do quite as well).

I recently added an “Exceptions” tab to the console that shows up when the app hits a (hopefully rare) uncaught exception. I have always had an ‘uncaught exception’ handler on ReportMill to send me unexpected user exceptions, which has greatly helped with software quality.

I will take a look at $rt_decodeStack - thanks for the pointer! Good to hear from you, I hope things are going well.

jeff
On May 17, 2021, 1:51 AM -0500, Alexey Andreev <konsol...@gmail.com>, wrote:
Hello. I believe that exposing stack trace to a user is a bad idea. Regular users have no clue how to deal with stack trace. If your application is not open source, stack traces can expose internal details of your application, which is not desirable in most cases.

But you mentioned "developer console". Does this mean you allow users Java code, compile it somehow and run JS? If you need stacktrace in this case, please note that JS is not sufficient for this purpose. You also need debugging information which is huge. You should also define $rt_decodeStack function before loading TeaVM code. This function takes native JavaScript stack trace and produces array of objects that represent JavaScript stack trace (you better examine runtime.js to find how this object should look like). You can look at devserver source code to see how it produces Java stack traces (tools/devserver). Also take a look at org.teavm.tooling.deobfuscate.js.Deobfuscator class.

--
You received this message because you are subscribed to a topic in the Google Groups "TeaVM" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/teavm/HBFCxeceqmA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to teavm+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/teavm/450b4f00-5ddd-4d57-a35e-7ac45c32cbf2n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages