{"id":231,"date":"2009-08-04T05:44:33","date_gmt":"2009-08-04T10:44:33","guid":{"rendered":"http:\/\/billdwhite.com\/?p=231"},"modified":"2009-08-04T05:44:33","modified_gmt":"2009-08-04T10:44:33","slug":"the-getstacktrace-super-bug","status":"publish","type":"post","link":"https:\/\/billdwhite.com\/wordpress\/2009\/08\/04\/the-getstacktrace-super-bug\/","title":{"rendered":"The getStackTrace Super Bug"},"content":{"rendered":"<p>If you happen to be hitting an issue where an application runs fine in the debug version of the Flash player but hangs up in the normal version, read on.  This could be your problem.  <\/p>\n<p>I&#8217;ve made good use of a <a href=\"http:\/\/dougmccune.com\/blog\/2008\/02\/21\/sneaky-flex-trick-to-get-the-name-of-any-calling-functions\/\">tip I picked up from McCune<\/a> on generating a stacktrace in my logging statements so that I can not only see the method that was called but also from where it was being called.<br \/>\n<!--more--><br \/>\nIn this particular case, I was trying to determine why my component was getting its maxWidth value changed at some point in the lifecycle.  I overrode the maxWidth accessor using this snippet:<\/p>\n<pre line=\"1\" lang=\"actionscript\">\noverride public function set maxWidth(value:Number):void {\n    trace(\"set maxWidth = \" + value);\n    var stackTrace:String = new Error().getStackTrace();\n    var callStackString:String = stackTrace.substring(stackTrace.indexOf(\"n\"), 500);\n    trace(\"---- call stack: \" + callStackString + \"... n\");\n    super.maxWidth = value;\n}<\/pre>\n<p>The result is a nice log statement showing me what led up to the call:<\/p>\n<pre line=\"1\" lang=\"actionscript\">\nset maxWidth = 757\n---- call stack:\nat BaseContainer\/set maxWidth()[\/Users\/white\/dev\/workspace\/FlexContainerTesting\/src\/BaseContainer.as:45]\nat layouts::HorizontalFlowLayout\/updateDisplayList()[\/Users\/white\/dev\/workspace\/FlexContainerTesting\/src\/layouts\/HorizontalFlowLayout.as:96]\nat BaseContainer\/updateDisplayList()[\/Users\/white\/dev\/workspace\/FlexContainerTesting\/src\/BaseContainer.as:85]\nat mx.core::UIComponent\/validateDisplayList()[C:autobuild3.2.0frameworksprojectsframeworksrcmxcoreUICompone...<\/pre>\n<p>Now this works great until you run into the issue that I did the other day.   According to the Doug&#8217;s posted (at the bottom) and according to the docs, there is a gotcha that I wish I had paid attention to before hitting this problem. Doug&#8217;s post mentions that this only works in the debug player, but to get more specific, the docs point out that it returns a null value:<\/p>\n<p><code>getStackTrace(): Returns the call stack for an error as a string at the time of the error's construction (for the debugger version of Flash Player and the AIR Debug Launcher (ADL) only; returns null if not using the debugger version of Flash Player or the ADL.<\/code><\/p>\n<p>So this means that the <code>stackTrace<\/code> variable will be valid when I&#8217;m using the debug version of the Flash player.  But in the normal player, the third line will throw a nullpointer exception.   However, in my application, these null pointers were getting &#8216;eaten&#8217; by the application and never being shown.   <\/p>\n<p>The result?  <strong>The perfect bug<\/strong>.  One that hides when you look for it.  Because the <code>getStackTrace()<\/code> method of the Error object returns a valid object in the debug version of the Flash player and a null in the regular version, it was a real pain to figure out why my app worked great on my dev box (with the debug player) and would never finish loading in the regular version of the flash player.   The answer, of course, would be to have runtime errors correctly bubble up to an error dialog in the application so non-debug flash players could indicate that something is wrong.  Alternatively, something like this would also work:<\/p>\n<pre line=\"1\" lang=\"actionscript\">\noverride public function set maxWidth(value:Number):void {\n    trace(\"set maxWidth = \" + value);\n    var stackTrace:String = new Error().getStackTrace();\n    if (stackTrace != null) {\n        var methodNameString:String = stackTrace.substring(stackTrace.indexOf(\"n\"), 500);\n        trace(\"----&gt; call stack method: \" + methodNameString + \"... n\");\n    }\n    super.maxWidth = value;\n}<\/pre>\n<p>Just wanted to post this in case anyone else ever got bitten by the same issue.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you happen to be hitting an issue where an application runs fine in the debug version of the Flash player but hangs up in the normal version, read on. This could be your problem. I&#8217;ve made good use of a tip I picked up from McCune on generating a stacktrace in my logging statements\u2026 <span class=\"read-more\"><a href=\"https:\/\/billdwhite.com\/wordpress\/2009\/08\/04\/the-getstacktrace-super-bug\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-231","post","type-post","status-publish","format-standard","hentry","category-adobe-flex"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>The getStackTrace Super Bug - Bill White<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/billdwhite.com\/wordpress\/2009\/08\/04\/the-getstacktrace-super-bug\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"The getStackTrace Super Bug - Bill White\" \/>\n<meta property=\"og:description\" content=\"If you happen to be hitting an issue where an application runs fine in the debug version of the Flash player but hangs up in the normal version, read on. This could be your problem. I&#8217;ve made good use of a tip I picked up from McCune on generating a stacktrace in my logging statements\u2026 Read More &raquo;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/billdwhite.com\/wordpress\/2009\/08\/04\/the-getstacktrace-super-bug\/\" \/>\n<meta property=\"og:site_name\" content=\"Bill White\" \/>\n<meta property=\"article:published_time\" content=\"2009-08-04T10:44:33+00:00\" \/>\n<meta name=\"author\" content=\"Bill White\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@bill_d_white\" \/>\n<meta name=\"twitter:site\" content=\"@bill_d_white\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Bill White\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/billdwhite.com\/wordpress\/2009\/08\/04\/the-getstacktrace-super-bug\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/billdwhite.com\/wordpress\/2009\/08\/04\/the-getstacktrace-super-bug\/\"},\"author\":{\"name\":\"Bill White\",\"@id\":\"https:\/\/billdwhite.com\/wordpress\/#\/schema\/person\/ea6b87554d0eed13a0152765dd01d314\"},\"headline\":\"The getStackTrace Super Bug\",\"datePublished\":\"2009-08-04T10:44:33+00:00\",\"dateModified\":\"2009-08-04T10:44:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/billdwhite.com\/wordpress\/2009\/08\/04\/the-getstacktrace-super-bug\/\"},\"wordCount\":372,\"commentCount\":5,\"publisher\":{\"@id\":\"https:\/\/billdwhite.com\/wordpress\/#\/schema\/person\/ea6b87554d0eed13a0152765dd01d314\"},\"articleSection\":[\"Adobe Flex\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/billdwhite.com\/wordpress\/2009\/08\/04\/the-getstacktrace-super-bug\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/billdwhite.com\/wordpress\/2009\/08\/04\/the-getstacktrace-super-bug\/\",\"url\":\"https:\/\/billdwhite.com\/wordpress\/2009\/08\/04\/the-getstacktrace-super-bug\/\",\"name\":\"The getStackTrace Super Bug - Bill White\",\"isPartOf\":{\"@id\":\"https:\/\/billdwhite.com\/wordpress\/#website\"},\"datePublished\":\"2009-08-04T10:44:33+00:00\",\"dateModified\":\"2009-08-04T10:44:33+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/billdwhite.com\/wordpress\/2009\/08\/04\/the-getstacktrace-super-bug\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/billdwhite.com\/wordpress\/2009\/08\/04\/the-getstacktrace-super-bug\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/billdwhite.com\/wordpress\/2009\/08\/04\/the-getstacktrace-super-bug\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/billdwhite.com\/wordpress\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"The getStackTrace Super Bug\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/billdwhite.com\/wordpress\/#website\",\"url\":\"https:\/\/billdwhite.com\/wordpress\/\",\"name\":\"Bill White's Blog\",\"description\":\"UI Development and Data Visualization:  Angular \/ React \/ D3 \/ Typescript \/ Javascript \/ UI \/ UX \/ Etc\",\"publisher\":{\"@id\":\"https:\/\/billdwhite.com\/wordpress\/#\/schema\/person\/ea6b87554d0eed13a0152765dd01d314\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/billdwhite.com\/wordpress\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/billdwhite.com\/wordpress\/#\/schema\/person\/ea6b87554d0eed13a0152765dd01d314\",\"name\":\"Bill White\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/billdwhite.com\/wordpress\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/3c3595ee8305a186eea4ea5286143893?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/3c3595ee8305a186eea4ea5286143893?s=96&d=mm&r=g\",\"caption\":\"Bill White\"},\"logo\":{\"@id\":\"https:\/\/billdwhite.com\/wordpress\/#\/schema\/person\/image\/\"},\"sameAs\":[\"http:\/\/www.billdwhite.com\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"The getStackTrace Super Bug - Bill White","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/billdwhite.com\/wordpress\/2009\/08\/04\/the-getstacktrace-super-bug\/","og_locale":"en_US","og_type":"article","og_title":"The getStackTrace Super Bug - Bill White","og_description":"If you happen to be hitting an issue where an application runs fine in the debug version of the Flash player but hangs up in the normal version, read on. This could be your problem. I&#8217;ve made good use of a tip I picked up from McCune on generating a stacktrace in my logging statements\u2026 Read More &raquo;","og_url":"https:\/\/billdwhite.com\/wordpress\/2009\/08\/04\/the-getstacktrace-super-bug\/","og_site_name":"Bill White","article_published_time":"2009-08-04T10:44:33+00:00","author":"Bill White","twitter_card":"summary_large_image","twitter_creator":"@bill_d_white","twitter_site":"@bill_d_white","twitter_misc":{"Written by":"Bill White","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/billdwhite.com\/wordpress\/2009\/08\/04\/the-getstacktrace-super-bug\/#article","isPartOf":{"@id":"https:\/\/billdwhite.com\/wordpress\/2009\/08\/04\/the-getstacktrace-super-bug\/"},"author":{"name":"Bill White","@id":"https:\/\/billdwhite.com\/wordpress\/#\/schema\/person\/ea6b87554d0eed13a0152765dd01d314"},"headline":"The getStackTrace Super Bug","datePublished":"2009-08-04T10:44:33+00:00","dateModified":"2009-08-04T10:44:33+00:00","mainEntityOfPage":{"@id":"https:\/\/billdwhite.com\/wordpress\/2009\/08\/04\/the-getstacktrace-super-bug\/"},"wordCount":372,"commentCount":5,"publisher":{"@id":"https:\/\/billdwhite.com\/wordpress\/#\/schema\/person\/ea6b87554d0eed13a0152765dd01d314"},"articleSection":["Adobe Flex"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/billdwhite.com\/wordpress\/2009\/08\/04\/the-getstacktrace-super-bug\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/billdwhite.com\/wordpress\/2009\/08\/04\/the-getstacktrace-super-bug\/","url":"https:\/\/billdwhite.com\/wordpress\/2009\/08\/04\/the-getstacktrace-super-bug\/","name":"The getStackTrace Super Bug - Bill White","isPartOf":{"@id":"https:\/\/billdwhite.com\/wordpress\/#website"},"datePublished":"2009-08-04T10:44:33+00:00","dateModified":"2009-08-04T10:44:33+00:00","breadcrumb":{"@id":"https:\/\/billdwhite.com\/wordpress\/2009\/08\/04\/the-getstacktrace-super-bug\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/billdwhite.com\/wordpress\/2009\/08\/04\/the-getstacktrace-super-bug\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/billdwhite.com\/wordpress\/2009\/08\/04\/the-getstacktrace-super-bug\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/billdwhite.com\/wordpress\/"},{"@type":"ListItem","position":2,"name":"The getStackTrace Super Bug"}]},{"@type":"WebSite","@id":"https:\/\/billdwhite.com\/wordpress\/#website","url":"https:\/\/billdwhite.com\/wordpress\/","name":"Bill White's Blog","description":"UI Development and Data Visualization:  Angular \/ React \/ D3 \/ Typescript \/ Javascript \/ UI \/ UX \/ Etc","publisher":{"@id":"https:\/\/billdwhite.com\/wordpress\/#\/schema\/person\/ea6b87554d0eed13a0152765dd01d314"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/billdwhite.com\/wordpress\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/billdwhite.com\/wordpress\/#\/schema\/person\/ea6b87554d0eed13a0152765dd01d314","name":"Bill White","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/billdwhite.com\/wordpress\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/3c3595ee8305a186eea4ea5286143893?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3c3595ee8305a186eea4ea5286143893?s=96&d=mm&r=g","caption":"Bill White"},"logo":{"@id":"https:\/\/billdwhite.com\/wordpress\/#\/schema\/person\/image\/"},"sameAs":["http:\/\/www.billdwhite.com"]}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/billdwhite.com\/wordpress\/wp-json\/wp\/v2\/posts\/231","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/billdwhite.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/billdwhite.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/billdwhite.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/billdwhite.com\/wordpress\/wp-json\/wp\/v2\/comments?post=231"}],"version-history":[{"count":0,"href":"https:\/\/billdwhite.com\/wordpress\/wp-json\/wp\/v2\/posts\/231\/revisions"}],"wp:attachment":[{"href":"https:\/\/billdwhite.com\/wordpress\/wp-json\/wp\/v2\/media?parent=231"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/billdwhite.com\/wordpress\/wp-json\/wp\/v2\/categories?post=231"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/billdwhite.com\/wordpress\/wp-json\/wp\/v2\/tags?post=231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}