Questions tagged [tearing]

An issue with operations on 64 bit value not being atomic on 32 bit machines

On 32 bit machines, only 32 bits are written at a time.

If you are writing a 64 bit value on a 32 bit machine, and writing to the same address at the same time on two different threads, you actually have four writes, not two, because the writes are done 32 bits at a time.

It is therefore possible for the threads to race, and when the smoke clears the variable contains the top 32 bits written by one thread, and the bottom 32 bits written by the other. So you can write 0xDEADBEEF00000000 on one thread and 0x00000000BAADF00D on another, and end up with 0x0000000000000000 in memory.

See this question for a code sample displaying tearing in C#.

39 questions
54
votes
3 answers

Can DateTime tear in a 64 bit environment?

In C# setting a value to a variable is atomic as long as its size is at most native int (i.e. 4 bytes in a 32-bit runtime environment and 8 bytes on a 64-bit one). In a 64-bit environment that includes all references types and most built-in value…
i3arnon
  • 113,022
  • 33
  • 324
  • 344
13
votes
3 answers

WPF Animation has Tearing and Flicker

I'm having trouble with tearing and flickering in WPF animations. I have a toy app that demonstrates the problems. The app animates squares across the screen. The edges of the squares show tearing and the animation as a whole does not feel smooth.…
Tristan
  • 1,466
  • 1
  • 16
  • 24
13
votes
5 answers

BitmapFactory.Options.inBitmap causes tearing when switching ImageView bitmap often

I've encountered a situation where I have to display images in a slideshow that switches image very fast. The sheer number of images makes me want to store the JPEG data in memory and decode them when I want to display them. To ease on the Garbage…
Joakim Berglund
  • 2,859
  • 1
  • 22
  • 30
13
votes
2 answers

Missing or Incorrect images and backgrounds randomly throughout app lifecycle

I was hoping someone here might have an idea what causes this sort of behaviour: Throughout my application, in seemingly random places and in random conditions I'm observing this strange UI issue. Images are on occasion being loaded black (with the…
Graeme
  • 25,714
  • 24
  • 124
  • 186
9
votes
3 answers

WPF: How do I prevent tearing with WriteableBitmap?

I'm using a WriteableBitmap to display images I process myself at around 20 frames per second. This question (WPF: More efficient way of displaying quickly-changing images?) and this question (How to display quick-updating images without large…
Rob
  • 25,984
  • 32
  • 109
  • 155
7
votes
1 answer

How can I make code that concurrently reads and modifies an array well-defined without introducing locking?

I'm writing a program that computes an endgame tablebase for a chess variant. The algorithm for filling the tablebase works like this: Start with a huge array of unsigned char, each member representing one position (we always assume that it's…
fuz
  • 88,405
  • 25
  • 200
  • 352
7
votes
1 answer

Tearing in HTML5 canvas?

I'm making a small game using the HTML5 canvas element. It works great, except that it has a scrolling background with obvious tearing happening in Firefox and Chromium browsers in Ubuntu. I'm pretty sure it's buffered because there isn't any of…
Sydius
  • 13,567
  • 17
  • 59
  • 76
7
votes
4 answers

SurfaceView flickering/tearing

I'm trying to figure out how to work around my problem. I've read http://groups.google.com/group/android-developers/browse_thread/thread/a2aac88a08cb56c2/b7dff4ba388cd664?lnk=gst&q=SurfaceView#b7dff4ba388cd664 which sort of answers my question but…
Sonoman
  • 3,379
  • 9
  • 45
  • 61
4
votes
2 answers

How to avoid flash.display flickering

Coming from a more 'traditional' C++ background so more used to dealing with low level API's rather than something like the flash.display API. My issue is rather rudimentary, but my searches haven't found a solution. How does one avoid screen…
Casper Beyer
  • 2,203
  • 2
  • 22
  • 35
3
votes
1 answer

wpf wait for vsync (Image)

I use a UDP API that updates a camera feed to a ImageSource, I have a timer that updates the ViewModel's ImageSource and then WPF databinds the Image on screen. The timer has an interval that fires as many times as the refresh rate, but offourse…
Anders
  • 17,306
  • 10
  • 76
  • 144
3
votes
1 answer

C# Is value type assignment atomic?

Is the assignement of a value type considered to be atomic in .Net? For example, consider the following program: struct Vector3 { public float X { get; private set; } public float Y { get; private set; } public float Z { get; private…
3
votes
3 answers

What can one do about WPF render tearing of the UI?

To my disappointment I found out that one of the applications I'm working on renders rather poorly on certain computers. The UI static graphics and text suffer from a severe case of tearing without doing any kind of animations. This makes text…
Mike Dinescu
  • 54,171
  • 16
  • 118
  • 151
3
votes
2 answers

Skipping and Tearing in Java Animation

the following code draws a square with two smaller square rotating inside it. whenever you click an arrow on the keyboard, the whole system will move in that direction. however i'm having some problems with the image tearing and at times skipping…
resotpvl
  • 59
  • 1
  • 7
3
votes
1 answer

XNA weird terrain tearing

Let me post the images first... Solid shot where tearing occurs And wireframe shot of that place I am mostly using mostly using Riemers tutorial while the render code is.. Main render public void Render() { …
Fireant
  • 33
  • 4
2
votes
2 answers

OpenGL tearing effect when rendering on EGL

I have some Qt applications rendered using OpenGL on surfaces provided by an EGL implementation on an ARM board. I'm experiencing some kind of tearing in rendering. By reading around, I found out it may be a problem related to vsync, so I used the…
Luca Carlon
  • 9,546
  • 13
  • 59
  • 91
1
2 3