Closed
Bug 601484
Opened 15 years ago
Closed 4 years ago
canvas.getContext("2d") is crashing when called from JS xpcom components
Categories
(Core :: Graphics: Canvas2D, defect, P3)
Tracking
()
RESOLVED
WORKSFORME
People
(Reporter: srihari.m, Unassigned)
Details
(Keywords: stackwanted)
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.5; rv:2.0b6) Gecko/20100101 Firefox/4.0b6
Build Identifier:
canvas.getContext("2d") in the following code is crashing. The only time it's working fine is the FIRST time whenever i switch from 3.6 to 4.0 beta. Is it because of any start up delay?
var canvas = CC["@mozilla.org/xul/xul-document;1"].createInstance(CI.nsIDOMDocument).implementation.createDocument("http://www.w3.org/1999/xhtml", "html", null).createElementNS("http://www.w3.org/1999/xhtml", "canvas") ;
canvas = canvas.QueryInterface(Components.interfaces.nsIDOMHTMLCanvasElement);
canvas.setAttribute("height", 32);
canvas.setAttribute("width", 32);
canvas.getContext("2d"); /* THIS IS LINE WHICH IS CRASHING */
Reproducible: Always
1. I opened the error console
2. I entered:
var CC=Components.classes, CI=Components.interfaces;var canvas = CC["@mozilla.org/xul/xul-document;1"].createInstance(CI.nsIDOMDocument).implementation.createDocument("http://www.w3.org/1999/xhtml", "html", null).createElementNS("http://www.w3.org/1999/xhtml", "canvas") ; canvas = canvas.QueryInterface(Components.interfaces.nsIDOMHTMLCanvasElement); canvas.setAttribute("height", 32); canvas.setAttribute("width", 32); prompt('',canvas.getContext("2d"));
3. I clicked evaluate
[object CanvasRenderingContext2D]
I'm using:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0b6) Gecko/20100101 Firefox/4.0b6
https://developer.mozilla.org/En/How_to_get_a_stacktrace_for_a_bug_report
please provide a sample component.
Note that DOM nodes should *not* be created on other threads...
Keywords: stackwanted
Comment 2•15 years ago
|
||
At what point are you running this in your XPCOM component?
What's a crash report incident ID for this crash?
I'm calling that code in the constructor of my JS XPCOM component which is registered for 'profile-after-change' category.
Shall i delay it?
Here is the crash report -
http://crash-stats.mozilla.com/report/index/42db90cf-aa95-44e4-a8fd-d051d2101004
Comment 5•15 years ago
|
||
Yes; you're running it before the graphics module has loaded, (gfxPlatform::GetPlatform() is null).
Benjamin, what's the right place to run these sorts of things?
Comment 6•15 years ago
|
||
XPCOM registration is finished already. It looks like content code *assumes* that the graphics module has loaded. In this case that assumption is incorrect.
I'm a bit mystified why an extension would need to create a canvas before there was a window showing, but if it is actually necessary, either the content code (specifically http://hg.mozilla.org/mozilla-central/annotate/633e895d5e84/content/canvas/src/nsCanvasRenderingContext2D.cpp#l1099 ) or the extension would need to be modified to load something from the graphics module and explicitly initialize it.
Comment 7•15 years ago
|
||
Hmm. I thought we enforced graphics module load when the layout module loads... Is that not the case anymore?
Comment 8•15 years ago
|
||
See bug 576540, gfx from layout breaks stuff and the easiest way to fix that was delay loading imgloader from layout module ctor.
I shifted the component code to initialize after listening to window's 'load' event. Still it's crashing, but i'm unable to get the crash record (http://crash-stats.mozilla.com/about/throttling).
Please let me know which function/service to call to initialize the graphics module from a JS XPCOM component.
Comment 10•15 years ago
|
||
> (http://crash-stats.mozilla.com/about/throttling).
You can manually submit this from about:crashes, right?
It sounds like the canvas code needs to either ensure gfx is loaded or throw if GetPlatform() is null.
Status: UNCONFIRMED → NEW
Ever confirmed: true
| Reporter | ||
Comment 11•15 years ago
|
||
I'm unable to submit that crash (526A3A76-8C0C-42A7-A2BF-273BA15E9C8D) from about:crashes.
For the time being, which function/service should i call from my JS XPCOM component to load the required gfx module?
| Reporter | ||
Comment 12•15 years ago
|
||
I tried calling Components.classes["@mozilla.org/gfx/region;1"].createInstance(Components.interfaces.nsIScriptableRegion).init() before canvas.getContext("2d") and it worked. Any better way?
Comment 14•4 years ago
|
||
Closing this as resolved:worksforme since there were no crashes in the last 6 months for this signature.
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → WORKSFORME
You need to log in
before you can comment on or make changes to this bug.
Description
•