Is DX11VideoRenderer thread safe? - directx

I'm using the Microsoft sample DX11VideoRenderer to render real time video in Windows 10. When I run just one stream, the video looks great. However when I run more than 4 or 5 streams, some of the video in their respective windows start blanking out intermittently. The effect can be over just a portion or all of each video window.
Also I get a few intermittent errors from this function call in my log file:
hr = pVideoContext->VideoProcessorBlt(m_pVideoProcessor, pOutputView, 0, 1, &StreamData );
The error returned is: E_INVALIDARG One or more arguments are not valid 0x80070057
I'm only using the Presenter.cpp and display.cpp modules of the DX11VideoRenderer in my code. The source is located at:
DirectX video rendering sample
My initial suspicion at this stage is that DXVideoRenderer may not be thread safe. I found this information about multithreading: Introduction to Multithreading in Direct3D 11 which states:
While the use of a device context (ID3D11DeviceContext) is not thread-safe, the use of a Direct3D 11 device (ID3D11Device) is thread-safe.
But it seems that since I'm using separate instances of the CPresenter class for each window, there should not be a problem with ID3D11DeviceContext not being thread safe because each window should have it's own instance of ID3D11DeviceContext.
Does anyone have any experience or ideas about this DX11VideoRenderer software sample and what might be causing this problem?
Thank you!
-UPDATE-
I have been able to duplicate the problem with just one window so it no longer appears to be a threading issue. If I manually resize the window many times I can sometimes get the video in the window to flicker. When this happens I see in my log that the same function call to VideoProcessorBlt() had a failure with the same return code, E_INVALIDARG.

If I manually resize the window many times I can sometimes get the video in the window to flicker. When this happens I see in my log that the same function call to VideoProcessorBlt() had a failure with the same return code, E_INVALIDARG.
This behaviour is not documented by Microsoft.
The problem is the same with DirectX9, but the error occurs with IDirect3DDevice9::Present, just after VideoProcessBltHD.
The HRESULT code is 0x88760872, and 0x88760872 is not documented.
So when resizing window, the error can occur.
See H264Dxva2Decoder :
In Dxva2Renderer.cpp, check for HANDLE_DIRECTX_ERROR_UNDOCUMENTED.
The strategy I choosed is to pause the video if playing (see WindowsFormProc and WM_ENTERSIZEMOVE/WM_SYSCOMMAND),
also, this avoid flickering.
Doing this, the error disappears.
PS: normally this error can be safely ignored.
I think this error is just there to tell you that when the window is resized, the underlying API is struggling to synchronize the DirectX presentation with your HWND, which changes size quickly.

Related

WASM memory access out of bounds using threejs DracoLoader on Mobile Browsers

I’m currently running into an issue where I’m trying to load a Draco compressed model using the Draco Loader of threejs on mobile browsers and it seems to hard crash during the call to the `.load method. IOS Safari not and Chrome version 88.0.4324.93 on an Android - Pixel 2 XL are the ones I’ve tested so far. The exact same models seem to render completely fine on web browsers with no issues.
This is a screenshot of the error I’m receiving which states memory access out of bounds
RuntimeError: memory access out of bounds
at <anonymous>:wasm-function[377]:0x18a28
at <anonymous>:wasm-function[358]:0x170b9
at <anonymous>:wasm-function[354]:0x16f17
at <anonymous>:wasm-function[446]:0x21f40
at <anonymous>:wasm-function[323]:0x1371f
at <anonymous>:wasm-function[23]:0x2cb1
at emscripten_bind_Decoder_DecodeBufferToMesh_2 (<anonymous>:wasm-function[119]:0x934e)
at a._emscripten_bind_Decoder_DecodeBufferToMesh_2 (blob:https://bdd35c37d00a.ngrok.io/95a82b20-81cc-451e-a630-f47694de7a0f:51:560)
at g.DecodeBufferToMesh.g.DecodeBufferToMesh (blob:https://bdd35c37d00a.ngrok.io/95a82b20-81cc-451e-a630-f47694de7a0f:92:54)
at decodeGeometry (blob:https://bdd35c37d00a.ngrok.io/95a82b20-81cc-451e-a630-f47694de7a0f:189:29)
I’ve tried adding console logs to the onProgress, onLoad, and onError callbacks. The onProgress seems to fully complete but after that, before the onLoad callback can run, it crashes and the onError callback isn’t called either.
Anyone have any ideas on how to go about solving this?

Parsing error log messages to String in iOS

Is there a way to parse iOS's log to a String at run time when it occurred? I need to parse a certain error log from UIKit and assert it at once when it appeared for debugging.
What we want to do is to parse the console for this error: This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes. We've found and fixed the line that causes this error, but we need to prevent this for happening again. FYI, the culprit is a line that changes a constant of an Autolayout in a background thread. And unfortunately it is not recognized by the compiler as an error like when we do the same thing with UIButton or anything that is derived from UIView (which will give an error at compile time when we try putting it in a background thread).
After much googling for the answer, I've finally found the answer. I found this article:
So here's what I did:
Eavesdropping on stderr stream
Duplicate it into another string
Parse the string for "weird crashes"
If found, it will crash immediately (instead of still running the app and waiting for the app to crash at indefinite time)
Added a DEBUG guard so that this functionality doesn't get carried over to production

Delphi - ISAPI DLL Application hanging on Fastreport

Found this this post ISAPI web application hanging if FastReport.PrepareReport is called
It helped solving my problem partially. As well I´ve turned Wisiyng property to False on frxRichView. Since I'm retunrnig a base 64 string I've also tryed switched loading from StrToStream/LoadFromStream to LoadFromFile. The problem persist with multiple acess, 2 out of 10 process can finish loading my Pdf file. All the others requests hangs until timeout. Does anyone have an idea what else can I do? is there anyother way to retunr rtf format into Fastreport report Thanks.
I could only get time-out error using Selenium to test multiples request from the client side.
Update: I've figured that just having a TfrxRichView component in the report causes the hanging, it doesn't even need to have a rtf text on it. Replacing it to a memo all request are answered.
UPDATE: Got a answer from fast report and I wold like your opinion.
ok,
I had similar problems, and it is not easy to find out the reason, but maybe you can find your solution in between my considerations..
1) Stack Size
When ran in IIS your ISAPI is only a DLL called by a process, you are not the main process so you have to pay attention to stack dimension.
Normally a Delphi application have a default stack size of 1Mb, in ISAPI DLL you will have only 256Kb of stack.
Maybe you are facing a stack overflow exception.. it can explain why it does not occurr always but only in some circumstances..
2) Trapped Exception
In general you get some error during the preparation of report (aka all the job of working with data, expressions, variables, formulas etc etc..) can bring to a trapped exception. You may be unable to see it from outside but code execution was broken somwhere and report preparation had not finished.
3) MessageBoxes and/or standard Exceptions
when running in ISAPI you should not output anything to user interface,
maybe a message dialog (or an exception) can bring to unexpected behaviour.
4) Global Var
You should avoid global var because in ISAPI they will be common across threads
So, if you have sources, debug the application.. at first exception you should understand where is your problem..
If you have not sources.. chek the above list.. I hope you can find some useful information.
You have two ways to solve this:
1- Try to recreate this behavior while debugging your ISAPI DLL. If you are lucky, you can identify the thread that is hanging your application. Sometimes this is hard or even impossible to recreate.
2- If you have access to the hung ISAPI application instance, use a tool like SysInternals Process Explorer to create a minidump file. Your application must be built using full debug symbols and you should have the corresponding map file. With one (or more - even better) dump files obtained from your hung application plus the map file, you can use another tool, WinDbg to analyze it and find the cause. (Sometimes) WinDbg can show exactly which thread is hanging the whole application and the line of code that causes it.
If you have never done that, I must warn you that this kind of analysis is almost a gamble... You have to use several different tools with little
or no documentation, read heaps of technical info in various places. In the end, sometimes it works wonderfully and sometimes it fails miserably.
Because debugging ISAPI is not obvious, but also because I wanted to be able to switch easily between more different hosting solutions — and wanted to update my website on the fly without a restart of the web-server/service — I created xxm. It has a singular interface to the HTTP context, your DLL gets loaded by either a IIS ISAPI handler, or a HTTP.SYS handler, or an Apache httpd module, or for debugging locally you can just set xxmHttp.exe as host application to get IIS out of the way.

CGContext errors in iOS application

When I run my application it works well, but during transitions between its views I have a lot of CGContext errors in the console output, but the app still works well, no crashes or bugs I didn't see. Description: so I only run my app - all work well - but there appears error messages in the console:
And after any other view transition they appear again and again. So the question - how to fix this? And what may be the reason of this error messages? There a lot of views and code in my application so I don't even know what part is error-prone.But these messages appear after transitions between all views in my app. Thanks in advance.
Look for some method in your code where you call CGContextSaveGState, CGContextSetBlendMode, CGContextSetApha, etc. Chances are that you won´t find many places where you do that.
Well, if you find it, look for some statement (just before those listed in your console log) where a context is created, and try to understand why it fails. You may set a breakpoint on that line and inspect the parameters to the CGContextCreate call.
If you need more help, paste the code you have (hopefully) found.

Error deserializing wallpaper image : iPad

What does the following error indicates
5/19/11 8:06:45 PM SpringBoard[9712] Error deserializing
wallpaper image: Error
Domain=CPBitmapErrorDomain Code=0 "The
operation couldn’t be completed.
(CPBitmapErrorDomain error 0 - No data
provided to
CPBitmapCreateImagesFromData)"
UserInfo=0x70b9c80 {NSDescription=No
data provided to
CPBitmapCreateImagesFromData}
Well, if you read the error message, it is telling you that a wallpaper was unable to be deserialised because no data was provided to the function named CPBitMapCreateImagesFromData. Pretty self explanitory.
Other than that, it sounds like you're either working on a jailbroken phone or trying to do things that aren't supported by the official iOS SDK - in which case my help ends here.
Or you're a user who is trying to understand why an image they set as a wallpaper isn't displaying and found their way to the iPad's console - in which case, this isn't the place to be asking.
This happened to me also, I think it's because most of the tutorials are written with an iphone in mind and I was using an iPad. I was working with an ipad and when following these tutorials i was getting this problem.
When you are creating the project I choose View based application. In the same wizard there's a combo box for 'iPhone' and 'iPad'.. If I leave that as iPhone then my application doesnt start in the simulator and I see the error you mention. If I set that to iPad then everything works fine.
I dont understand why that should make a difference tbh..
This happened to me, but only when I was not debugging, what happened was that in the dealloc function [super dealloc] was called at the top of the function rather than at the end. The "deserializing wallpaper" message is probably due to some sort of memory corruption that occurred since I had code after [super dealloc] trying to use pointers that were now garbage. I had NSZombie activated but it had no effect. Why this only crashed when I was not hooked up to the debugger is beyond me at the moment.
Thankfully this bug was fixed after a few diffs in source control, but initially I was pretty perplexed at the message and the fact that it was a bug where the debugger couldn't be used only induced more panic.
I'm sure you've long fixed your problem but I thought it'd be helpful to put this out there for others.

Resources