Windows Phone 7 XNA game quits on load, no error messages - windows-phone-7

I'm trying to get a Windows Phone 7 XNA game to run in the emulator, however it simply quits after calling the Game.Initialize function. The only output it gives is:
A first chance exception of type
'System.NotSupportedException'
occurred in
Microsoft.Xna.Framework.Graphics.dll
'taskhost.exe' (Managed): Loaded
'Microsoft.Xna.Framework.GamerServices.dll'
A first chance exception of type
'System.Threading.ThreadAbortException'
occurred in
Microsoft.Xna.Framework.dll
No idea why, the same program runs fine when running for Windows desktop.
OK upon further investigation I've found that the error occurs because I'm initailizing spritebatch in Game.Initialize:
base.Initialize();
if (spriteBatch == null)
{
spriteBatch = new SpriteBatch(GraphicsDevice);
}
If I remove spriteBach = new ... it runs fine, however when I initialize it the update/draw functions the game WILL just exit...

You cannot use the GraphicsDevice (like, for example, by having SpriteBatch create the various graphics device resources it requires) until LoadContent is called, as the graphics device is not ready until then.
See Game.GraphicsDevice on MSDN:
Do not access this property until LoadContent is called.

OK I found out what the problem was. I was basically trying to draw a non power of 2 texture while using texture wrapping which the reach API of Windows Phone 7 does not like. I'm not sure why I didn't get an exception thrown for this (last time I did something like this I actually got an exception thrown).
I should have been more clear in my question, when I didn't initialize spritebatch I was also skeeping draw calls too.
At any rate that was the problem.

Related

Input.GetAxis("Mouse X") not working on some Windows configurations

public float GetAxis()
{
if (inputDevice == InputDevice.MouseKeyboard)
{
return Input.GetAxis(this.buttonName);
}
}
This code is working perfectly on my Windows 7 x64 PC. My Project Input settings are ordinal:
Input settings:
But I watched some videos on youtube where people playing my game. And they can't use mouse in it. Looks like Input.GetAxis("Mouse X") and Input.GetAxis("Mouse Y") has not returning proper values for them and they can't control camera in game.
Other input is working fine for them.
My Unity version is 5.6.0f3 and I can't upgrade to actual version because game's code is too complex.
How to troubleshot and fix it? I have not build for other platforms then windows x86 and x64.
Input object was constructed:
public GenericInput rotateCameraXInput = new GenericInput("Mouse X", "RightAnalogHorizontal");
To read delta mouse movement I am running this method in LateUpdate():
protected virtual void CameraInput()
{
if (tpCamera == null || cc.lockCamera)
return;
var Y = rotateCameraYInput.GetAxis();
var X = rotateCameraXInput.GetAxis();
}
I've come across this issue myself while using an RDP session or some kind of remote viewer such as TeamViewer. Mouse X and Mouse Y read the output directly from a device. If the device is not directly plugged into the machine that the player is being ran on then the inputs will not be properly retrieved. I'm not sure if this is the case for you, but this is the only instance I can think of these not being picked up.
Maybe you should add a bit of code that gets the mouse position each frame and outputs the difference, this would bypass the Mouse X/Y inputs anyways.
Update. It is not a bug. I've just missed something in my project.
I have a script to control the speed of mouse-controlled camera and PlayerPrefs variable to change it. And, in some conditions, that variable was set to 0. But for my case, it has already been set to registry and on my PC everything was working fine.
Maybe I need to delete this question, because it has not provided enough data.
I found this thread at unity forum There are some people who encountered the same issue on real Windows PC with different Unity versions and different mouse drivers.
This is an old Unity hardware compatibility bug. Looks like it can't be fixed other then upgrading Unity or using other Input system.

How do I detect "invalid drawable" in Mac OS X?

I am working on a cross platform application that is over a decade old. The UI is by Qt and backend rendering is done with OpenGL. OpenGL contexts are managed in the back end, not by Qt.
I have recently added error checking and reporting for all OpenGL code in our app. Occasionally a situation arises where the first render initiated by Qt causes an "invalid drawable" error message in the terminal and all subsequent OpenGl calls fail with an "invalid framebuffer" error reported. These invalid drawable error messages have been treated as innocuous in the past, since before the user sees it the drawable eventually becomes valid and the scene is rendered correctly. However, with the new OpenGL error check/report it's not possible since there are large numbers of errors reported.
I would like to test if the drawable is valid. If it is not, it should return before the render starts. How can I verify that the drawable is valid?
MacBook Pro, OS X Mountain Lion (10.8.3), ati graphics card
I don't know at what API level you're working. I'm not sure it's possible to detect the problem after the fact. That is, if all you have is a context (perhaps implicit as the thread's current context) that failed to connect to its drawable.
I presume that Qt is using Cocoa under the hood. I further assume it has created an NSOpenGLContext and is invoking -setView: on it. You get that "invalid drawable" error if, at the time of that call, the view's window doesn't have a window device.
One common technique is to defer setting the context's view until the view has -drawRect: called on it, since at that point you're sure that the view has a window and the window has a device. (Although that ignores the possibility of forced drawing outside of the normal window display mechanism. For example, -cacheDisplayInRect:toBitmapImageRep:.)
If you just want to know at the point of the call to -setView: whether it's safe or not, I think you can rely on checking the value of [[view window] windowNumber]. The docs for -windowNumber say:
If the window doesn’t have a window device, the value returned will be equal to or less than 0.
Another approach is to prevent the problem rather than detect it. The strategy for that is basically to make sure the window has been shown and drawn before the call to -setView:. You may be able to force that by ordering it on-screen and invoking -display on it.
Ken Thomases post gave me the basic info I needed to find a workable solution. An additional conditional was needed. Here's what worked
//----------------------------------------------------------------------------
bool vtkCocoaRenderWindow::IsDrawable()
{
// you must initialize it first
// else it always evaluates false
this->Initialize();
// first check that window is valid
NSView *theView = (NSView*)this->GetWindowId();
bool win =[[theView window] windowNumber]>0;
// then check that the drawable is valid
NSOpenGLContext *context = (NSOpenGLContext *)this->GetContextId();
bool ok = [context view] != nil;
return win && ok;
}

Application crash on ios6 but working fine in ios5

I have an application for audio/video call using SIP protocol.It working fine when i tried to make a call with ios5 device or used it on ios 5 device but it crash when i tried to call or use it on ios 6. It crash on only when i tried to make a video call with ios6 device to ios5 device. Crash message
Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [2.74665e-34 nan]'
Check this answer link
Probably you are calculating the value of some frame and it is a NaN (not a number).
For SIP calls the best is iDoubs, a very easy API
It's hard to know what's wrong without more code, but here are my two cents: If you have a view (something like a UIWebView) in your code, and you are using the plain init method to initialize it, try changing it to initWithFrame to give it a frame right away. The problem might be that you are trying to use the element before a frame is allocated to it, thus resulting in a CALayerInvalidGeometry error.
After analyzing my crash report and my code
*** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan 96]'
I found the bug. I am using a method which is override from another class but somehow it's not working in iOS 6 and that's why it return some zero value because of this zero value it returns nan value and it crashed.

CGContextSetCompositeOperation error for some users when drawing NSWindow

A simple 10.6 Cocoa app I wrote that basically draws a regular window with some buttons and text has been spewing hundreds of console log messages:
<Error>: CGContextSetCompositeOperation: invalid context 0x0
I do not directly call drawRect: and always use setNeedsDisplay:YES when I need to refresh.
Interestingly, this error does not happen on all machines, I'd say about 50% get the error. However, the program works fine in either case!
Anyone got any clue as to what this error means, where it's stemming from, and more importantly, how can I suppress/get rid of it?
Thanks
Try setting a breakpoint on CGPostError. If you can break on the logging, you can hopefully figure out what's going on.
You shouldn't be looking to just suppress it. It means context creation is failing (thus NULL gets passed for some context parameter), and that's not good.

Flash AS3 animation in Mac vs Windows

I am working on a short animated story, which has a scrubbable timeline and chapter headings. I used TimelineMax for sequencing it. For the most part, it is working fine. I am seeing some strange behavior that pop up, though: sprites disappear, functions stop responding to user input, seams of the sprites become transparent -- all small issues but pretty hard to nail down because they happen in Mac only.
So I am wondering what is wrong with Flash, and why it misbehaves on a Mac?
I frequently work on the same projects on Windows at work and then my Mac at home. I also see some difference on the Mac compared to Windows. I find that various Flash Player versions for the Mac are generally slower than the Windows players, and I've seen some odd behavior on the Mac that is not happening on Windows.
In most cases I've narrowed this down to AS3's garbage collection. Garbage collection happens when the player determines that an object no longer has a reference in the movie, so it removes that object to free up memory. Let's say you have a class method like this:
function myTweenFunction():void {
var myTween:Tween = new Tween(myDisplayObject, 'x', Strong.easeInOut, 0, 500, 10, true);
myTween.addEventListener(TweenEvent.MOTION_FINISH, onMyTweenDone);
}
The method above will tween myDisplayObject's x value from 0 to 500 over the course of 10 seconds. When that tween is done, it should fire the onMyTweenDone method (not shown). However, myTween was created inside myTweenFunction so it only exists in the scope of myTweenFunction. When myTweenFunction is done, the myTween object is no longer referenced by any object in the movie so it becomes a candidate for garbage collection. You will start to see the tween, but at some point it will stop before it gets to 500 and the finish event will not fire. This means that myTween has been destroyed. To fix this problem, myTween needs to be a member of the class, or just needs to have a reference outside of a class function.
Getting back to the Mac vs. Windows issues, I see that garbage collection on runtime-created objects on the Mac is more apparent than on Windows. Garbage collection happens in the Windows Flash Player, but the tweens and other events may be finishing before garbage collection occurs since the Windows Flash Player has better performance. If the Mac Flash Player is slower (ie. the same tween might take longer), then the garbage collection might happen before the tween is done. Garbage collection does not occur frame-by-frame like an animation; it's a background process that can happen at any time, or not at all if there's enough memory for the Flash Player. Your windows machine might have a pile of RAM and the movie can play fine without the need for garbage collection, so myTween might never go away. If your Mac has less memory, or if you have a ton of apps open at once and the Flash Player memory allotment is limited, then the Flash Player will perform garbage collection more frequently.
I've also used TimelineMax, and there's an auto garbage collection feature that is turned on by default. Try turning that off and test on the Mac.
Ultimately, you should design your project with the assumption that a user may have very limited memory, so your objects need to be created, referenced, and garbage collected accordingly.
I've encountered some rendering issues between plugin versions especially when dealing with transparency, fonts, and embed settings.
If you are doing this in a web browser try playing with the WMODE embed setting and see if your results change.

Resources