Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7458957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T13:50:41+00:00 2026-05-29T13:50:41+00:00

I’ve got a Heisenbug in my code. It only appears every now and then

  • 0

I’ve got a Heisenbug in my code. It only appears every now and then and can’t be triggered deliberately.

FireBug throws an exception like “An invalid or illegal string was specified” at me and refers to a different line every time.

I’m using FireFox 10.0. The website is located at http://www.roboter-club-hamburg.de. I’ve already tried with FireQuery but that interferes with my code so it’s no option.


I’ve tracked it down to a line that looks like this:

context.fillText("[[*longtitle]]", x + 4, y + h + 15, w);

I’m using MODX CMS to build that website (that’s where [[*longtitle]] and [[*id]] and stuff come from; they are template placeholders).

Here’s the full function that this line is in:

($("imagecvs-[[*id]]").ready(function() {
    var canvas = $("#imagecvs-[[*id]]").get(0);
    if (canvas.getContext) {
    var context = canvas.getContext('2d');
    var img = new Image();

    img.src = "[[*Photo]]";

    var scale = 0.6;
    var ratio = img.width / img.height;

    var w = Math.min(img.width * scale, 120);
    var h = w / ratio;
    var x = 0;
    var y = (canvas.height / 2.0) - (h / 2.0);

    var deg = -8;
    var rad = (deg * Math.PI / 180);
    // y += (h / 2) * -Math.sin( rad );
    context.rotate(rad);

    context.fillStyle = "#FFF";
    context.fillRect(x - 5, y - 5, w + 10, h + 30);
    context.drawImage(img, x, y, w, h);

    context.font = "Italic Bold 10px Serif";
    context.textAlign = "left";
    context.textBaseline = "ideographic";
    context.fillStyle = "#000";
    context.fillText("This is a test", x + 4, y + h + 15, w); // Exception thrown here; even with 'This is a test'
    }
    return true;
  }));
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T13:50:53+00:00Added an answer on May 29, 2026 at 1:50 pm

    Alright, I’ve found the cause of this bug. It’s been caused by the fact that the image (img) sometimes was not completely loaded at the time the script asked for its width and height. Hence both were NaN and the script crashed (fillText apparently doesn’t work with a width of NaN).

    Now, all I’ve done to solve this problem is to move the drawing steps into the onload callback of img. That works. This Heisenbug is no more.

    Thanks a lot!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Got a real simple question but can't figure out the solution. Got following code.
got code looking like this: // This is com.n.common.Networking.downloadBmp( ) function // ... byte[]
Got a question regarding SQL and ColdFusion: I can't write SQL code properly, so
Got the guestbook working alright. New messages are building up nicely. Now, only the
Got a bluescreen in windows while cloning a mercurial repository. After reboot, I now
Got some code that is not mine and its producing this warning atm: iehtmlwin.cpp(264)
got a little problem im hoping someone can enlighten me on. Trying to serialise
Got issue My javascript array contains dates for ex. 19.4.2003,28.11.1997,3.1,,29.6,7.11.2008 (date-month-year). As you can
Got some code here that isn't working: $(#sidebar ul li:last).each(function(){ $(this).addClass(last); }); Basically I
Got a mobile site with a jquery mobile menu (nested-list). Every item in the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.