StackTrace in release flash player - actionscript-3

I have problem with getting stacktrace of errors.
When i use error.getStackTrace() in debug player it works fine.
ReferenceError: Error #1056: Не удается создать свойство asdad в starling.display.Stage. at app.views::MachineHeader/onSoundButtonTriggered()
[/var/lib/jenkins/jobs/.../src/app/views/MachineHeader.as:111] at starling.events::EventDispatcher/invokeEvent()
[/var/lib/jenkins/jobs/.../workspace/src/starling/events/EventDispatcher.as:141] at starling.events::EventDispatcher/dispatchEvent()
[/var/lib/jenkins/jobs/.../workspace/src/starling/events/EventDispatcher.as:112] at starling.events::EventDispatcher/dispatchEventWith()
[/var/lib/jenkins/jobs/.../workspace/src/starling/events/EventDispatcher.as:190] at org.feathers.controls::Button/button_touchHandler()
[/var/lib/jenkins/jobs/.../workspace/src/org/feathers/controls/Button.as:3052] at starling.events::EventDispatcher/invokeEvent()
[/var/lib/jenkins/jobs/.../workspace/src/starling/events/EventDispatcher.as:141] at starling.events::TouchEvent/dispatch()
[/var/lib/jenkins/jobs/.../workspace/src/starling/events/TouchEvent.as:174] at starling.events::Touch/dispatchEvent()
[/var/lib/jenkins/jobs/.../workspace/src/starling/events/Touch.as:231]
But on release player stackTrace looks like:
ReferenceError: Error #1056
Code:
this.loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, onGlobalErrorsHandler);
private function onGlobalErrorsHandler(e:UncaughtErrorEvent):void {
if (_errorList[e.errorID]) {
e.preventDefault();
return;
}
trace(e.error.getStackTrace());
var data:Object = {};
data["login"] = AMFService.instance.login;
data["error_type"] = String(e.error.errorID);
data["stacktrace"] = e.error.getStackTrace();
AMFService.instance.sendError("statistics.error_send", data);
_errorList[e.errorID] = e.error;
e.preventDefault();
}
Debug player: Linux 11.2
Release player: PepperFlash 11.9
What i'm doing wrong? How can i get stacktrace on release player?
Than you.

To enable stacktraces in release player(11.5+), you have to compile your swf with swf-version=18
http://www.adobe.com/devnet/articles/flashplayer-air-feature-list.html

According to Adobe's API Reference for Error.getStackTrace() ...
"For Flash Player 11.4 and earlier and AIR 3.4 and earlier, stack
traces are only available when code is running in the debugger version
of Flash Player or the AIR Debug Launcher (ADL). In non-debugger
versions of those runtimes, calling this method returns null."
Sorry, but there's just no way around it. :(

Related

How can I stop navigator (HTML5) from being undefined when running in node

I'm receiving and error when running a webrtc node service. I get an error when trying to use navigator. Here is the error when running
node client.js:
navigator.mediaDevices.getUserMedia = navigator.mediaDevices.getUserMedia || navigator.mediaDevices.webkitGetUserMedia
^
ReferenceError: navigator is not defined
I am using angular and node to run the file that has webrtc in it. Here is my setup:
Angular CLI: 8.0.1
Node: 10.16.0
Angular: 8.0.0
Package Version
-----------------------------------------------------------
#angular-devkit/architect 0.800.1
#angular-devkit/build-angular 0.800.1
#angular-devkit/build-optimizer 0.800.1
#angular-devkit/build-webpack 0.800.1
#angular-devkit/core 8.0.1
#angular-devkit/schematics 8.0.1
#angular/cdk 7.0.4
#angular/cli 8.0.1
#angular/http 6.0.9
#angular/material 6.4.7
#ngtools/webpack 8.0.1
#schematics/angular 8.0.1
#schematics/update 0.800.1
rxjs 6.5.2
typescript 3.4.5
webpack 4.30.0
and here is my client.js code:
//checks if the browser supports WebRTC
function hasUserMedia() {
navigator.mediaDevices.getUserMedia = navigator.mediaDevices.getUserMedia || navigator.mediaDevices.webkitGetUserMedia
|| navigator.mediaDevices.mozGetUserMedia || navigator.mediaDevices.msGetUserMedia;
return !!navigator.mediaDevices.getUserMedia;
}
if (true) {
navigator.mediaDevices.getUserMedia = navigator.mediaDevices.getUserMedia || navigator.mediaDevices.webkitGetUserMedia
|| navigator.mediaDevices.mozGetUserMedia || navigator.mediaDevices.msGetUserMedia;
//get both video and audio streams from user's camera
navigator.mediaDevices.getUserMedia({ video: true, audio: true }, function (stream) {
var video = document.querySelector('video');
//insert stream into the video tag
video.src = window.URL.createObjectURL(stream);
}, function (err) {});
}else {
alert("Error. WebRTC is not supported!");
}
I started to add navigator.mediaDevice because of a post I saw about a new WebRTC version. I'm not entirely sure if I need it for every method.
If the community thinks WebRTC isn't the preferred way to go, let me know. I'm still trying to figure out the best option for a live streaming application. But I thought WebRTC would be the best.

Processing error after upgrade to Version 6.0

With the following function I am trying to load the model into the earlier initialized viewer.
viewer.loadModel("https://developer.api.autodesk.com/modelderivative/v2/designdata/dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6aW1wbGVuaWFfaW1kL1JhaV8wNC4zZHM/manifest/urn%3Aadsk.viewing%3Afs.file%3AdXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6aW1wbGVuaWFfaW1kL1JhaV8wNC4zZHM%2Foutput%2FRai_04.3ds.svf")
Unfortuneately I get the following error for the function:
viewer3D.js:74844 Error while processing SVF: {"url":"https://developer.api.autodesk.com/modelderivative/v2/designdata/dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6aW1wbGVuaWFfaW1kL1JhaV8wNC4zZHM/manifest/urn%253Aadsk.viewing%253Afs.file%253AdXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6aW1wbGVuaWFfaW1kL1JhaV8wNC4zZHM%252Foutput%252FRai_04.3ds.svf?domain=http%3A%2F%2Flocalhost%3A3002","httpStatus":400,"httpStatusText":"Bad Request","data":{"url":"https://developer.api.autodesk.com/modelderivative/v2/designdata/dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6aW1wbGVuaWFfaW1kL1JhaV8wNC4zZHM/manifest/urn%253Aadsk.viewing%253Afs.file%253AdXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6aW1wbGVuaWFfaW1kL1JhaV8wNC4zZHM%252Foutput%252FRai_04.3ds.svf?domain=http%3A%2F%2Flocalhost%3A3002"}}
This is the way I initialize my viewer:
function onInitialized() { //console.log("viewer inizialized");
var config = Autodesk.Viewing.createViewerConfig();
config.extensions.push('Autodesk.Viewing.ZoomWindow');
config.startOnInitialize = true;
config.theme = 'light-theme';
viewerApp = new Autodesk.Viewing.ViewingApplication('main-viewer');
viewerApp.registerViewer(viewerApp.k3D,Autodesk.Viewing.Private.GuiViewer3D ,config);
viewer = viewerApp.getViewer(config);
viewer.start();
If I use the version 4.1 of the viewer, the model can be loaded this way. Changing to 6.0 the above described error appears.
I would really appreaciate a hint to a solution of my problem!
Thanks a lot in advance!
Cheers,
Felix
With v6 and onwards, call wrapper method Viewer3D.load insteadof .loadModel so that the resource requests made to Forge endpoints can be formed properly:
viewer.load('https://developer.api.autodesk.com/derivativeservice/v2/derivatives/urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2IyMzMvd2Fycmlvci4zZHM/output/warrior.3ds.svf');
or simply:
viewer.start(svfUrl)
Code sample: https://jsfiddle.net/dukedhx/9qncbuLt

cocos2d-js: Error: Invalid Native Object using setPhysicsBody

I'm trying to implement chipmunk physics engine for a cocos2d-js game. I'm getting the following error when i run it.
jsb: ERROR: File Y:\Documents\cocos\PrebuiltRuntimeJs\frameworks\js-bindings\bindings\auto\jsb_cocos2dx_auto.cpp: Line: 2143, Function: js_cocos2dx_Node_setPhysicsBody
Invalid Native Object
JS: D:/PROJECTS/cocos/Sliderule/runtime/win32/../../src/app.js:32:Error: Invalid Native Object
Here is the code i'm working with
`init:function () {
this._super();
var size = cc.winSize;
this.rect1 = new cc.Sprite(res.null_png,cc.rect(0,0, 200, 25));
this.rect1.setColor(cc.color(255,50,50,1));
this.rect1.setPosition(size.width/2, size.height-12.5);
this.rect1._setAnchorX(0.5);
this.rect1._setAnchorY(0.5);
this.rectbody1 = new cp.Body(1,cp.momentForBox(1,this.rect1.getContentSize().width, this.rect1.getContentSize().height));
this.rectbody1.p = cc.p(size.width/2, size.height-12.5);
this.space.addBody(this.rectbody1);
this.rectshape1 = new cp.BoxShape(this.rectbody1, this.rect1.getContentSize().width - 14, this.rect1.getContentSize().height);
this.space.addShape(this.rectshape1);
this.rect1.setPhysicsBody(this.rectbody1);
this.addChild(this.rect1,1);
`
I get the problem when setting the body to the sprite. Thanks in Advance.
This error message usually appears because of a missing retain(). You have to explicitly set sprites to be kept by the native system (Android, iOS) otherwise it's not valid after some time. And then, if you don't need it anymore: release it.
Try:
this.rect1.retain()
after you created the sprite. And then
this.rect1.release()
when you don't need it anymore.

sendToURL not working in flashplayer 14

This piece of code is working in flashplayer 11 but it's not working in flashplayer 14.
AS3 code :
private function savePDF(pdfBinary:ByteArray, urlString:String):void{
try{
//result comes back as binary, create a new URL request and pass it back to the server
var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");
var sendRequest:URLRequest = new URLRequest(urlString);
sendRequest.requestHeaders.push(header);
sendRequest.method = URLRequestMethod.POST;
sendRequest.data = pdfBinary;
sendToURL(sendRequest);
} catch (e:Error) {
// handle error here
trace("Error in savePDF "+e.message);
trace("StackTrace : "+e.getStackTrace());
}
}
and these are the errors I got :
Error in savePDF Error #3769: Security sandbox violation: Only simple headers can be used with navigateToUrl() or sendToUrl().
StackTrace : SecurityError: Error #3769: Security sandbox violation: Only simple headers can be used with navigateToUrl() or sendToUrl().
at global/flash.net::sendToURL()
at Export2Publish/savePDF()[my_project_dir\src\Export2Publish.mxml:158]
at Export2Publish/GeneratePDF()[my_project_dir\src\Export2Publish.mxml:386]
at Export2Publish/getUrl()[my_project_dir\src\Export2Publish.mxml:138]
at Export2Publish/___Export2Publish_Application1_creationComplete()[my_project_dir\src\Export2Publish.mxml:3]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()[my_framework_dir\src\mx\core\UIComponent.as:9051]
at mx.core::UIComponent/set initialized()[my_framework_dir\src\mx\core\UIComponent.as:1167]
at mx.managers::LayoutManager/doPhasedInstantiation()[my_framework_dir\src\mx\managers\LayoutManager.as:698]
at Function/http://adobe.com/AS3/2006/builtin::apply()
at mx.core::UIComponent/callLaterDispatcher2()[my_framework_dir\src\mx\core\UIComponent.as:8460]
at mx.core::UIComponent/callLaterDispatcher()[my_framework_dir\src\mx\core\UIComponent.as:8403]
Any fix for this issue ?
You can start by using a try and catch like this :
try {
sendToURL(request);
}
catch (e:Error) {
// handle error here
}
If the problem is not visible on dev environment, I recommand you to install a flash debug player which you can download here : Flash Player Downloads to see what kind of error your code will fire.
If your code is fine, in dev and prod environment, you should debug your server side script.

Flash update 12 broke my video recorder

When flash pushed the 12.0.0.70 version to Chrome it broke my video recorder.
According to the patch notes here, one thing was changed that might have broken my flash-based recorder
[3689061] [Video] Resolves an issue injected in Flash Player
11.9.900.170 that caused the video buffer to no longer be filled if the buffer was emptied while playing an RTMP stream
My recorder breaks when it's time to stop the stream and save the video to the Adobe Media Server.
I tried debugging it with the 12.0.0.70 flash debugger, but it doesn't crash when I'm using the debugger. Only when using the non-debugger Chrome version does it crash.
I can't debug it and get any useful information out of my swf, apart from making a bunch of external calls to console.log to see where it fails.
If someone also ran into a similar issue with flash-based, media-server-connected webcam recorders, and can guess at what might fix my problem, I'd be grateful.
I'm building this swf with Flex 4.6.0
Here's the function that stops the video recorder.
public function doStop():void{
if(status=="paused"){
doResume();
}
rectColor.color=0x000000;
rectColor.alpha=1;
var timer:Timer=new Timer(1 * 10);
timer.addEventListener(TimerEvent.TIMER,function(e:TimerEvent):void{
timer.stop();
timer.reset();
myns.close();
myTimer.stop();
if(!thumbBeginning){
if(status=="recording"){
takeScreenShot();
}
}else{
if(status=="recording"){
recordingTime = formatTime(realTime);
recordingLength = myTimer.currentCount;
if(!redoFlag){
ExternalInterface.call("CTRecorder.stopOk");
myTime.text = formatTime(0);
VD1.attachCamera(myCam);
setState("ready");
status = "stopped, ready"
playbackTimer.reset();
msg(recordingTime);
recording=false;
pauseTime=0;
}else{
pauseTime=0;
myTime.text = formatTime(0);
VD1.attachCamera(myCam);
playbackTimer.reset();
msg(recordingTime);
recording=false;
}
}
if(shutterGroup.visible){
toggleShutter();
}
myTimer.stop();
myTimer.reset();
if(redoFlag){
doRecord();
redoFlag=false;
trace("redoFlag turned off");
}
}
rectColor.alpha=.5;
});
timer.start();
}
This isn't really an answer, but it's too long for a comment.
"I can't debug it" - it only breaks in the release version? Is the release version the pepper plugin (i.e. Chrome's version of Flash), and the debug is the NPAPI plugin (i.e. Adobe's version)?
A likely candidate for where it's breaking is the ExternalInterface.call("CTRecorder.stopOk"); call. Are you testing this locally, or remotely? If locally, then you might be running into this bug: https://code.google.com/p/chromium/issues/detail?id=137734 where the Flash <-> JS communication is broken because of Trusted locations being ignored in PPAPI flash. In any case, try installing the release NPAPI version of Flash and see does it still crash (you can verify which one is running by visiting chrome://plugins/)
To help debugging the release version, you need a logging system - instead of making trace() calls, you call a custom log() function, that, as well as trace()ing, also stores the message somewhere, like in an Array. Then, in your SWF, when you hit a certain key, show a TextField on the screen, and populate it with your log() messages. That way, you'll be able to see trace() statements in release mode.
Also, don't forget to listen to any relative error events and thrown exceptions - ExternalInterface.call() will throw an Error and SecurityError for example. You can also set the marshallExceptions property, which will pass ActionScript exceptions to the browser and JavaScript exceptions to the player: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/external/ExternalInterface.html#marshallExceptions
Finally, add a listener for the UncaughtErrorEvent.UNCAUGHT_ERROR event on your main class, which will catch any uncaught thrown errors (funnily enough), which will at least mean that your app doesn't collapse:
mainClass.loaderInfo.uncaughtErrorEvents.addEventListener( UncaughtErrorEvent.UNCAUGHT_ERROR, this._onUncaughtErrorEvent );
private function _onUncaughtErrorEvent( e:UncaughtErrorEvent ):void
{
var message:String = null;
var stackTrace:String = null;
// get the message
if ( e.error is Error )
{
message = ( e.error as Error ).message;
try { stackTrace = ( e.error as Error ).getStackTrace(); }
catch ( error:Error ) { stackTrace = "No stack trace"; }
}
else if ( e.error is ErrorEvent )
message = ( e.error as ErrorEvent ).text;
else
message = e.error.toString();
// show an alert
trace( "An uncaught exception has occurred: " + e.errorID + ": " + e.type + ": " + message + ", stack:\n" + stackTrace );
e.preventDefault();
}