I am developing an App with an iOS Deployment target 15.6.
The App uses WKWebview for obtaining url information such as html. When I run a webView.load(url) function in the main thread it works but issues a warning "This method should not be called on the main thread as it may lead to UI unresponsiveness."
Although the function should not be used in a background thread I tried it but of course I got an error message "WKWebView.load(_:) must be used from main thread only".
How can I use the load function correctly so that I receive no warnings?
Related
Link to full sample app
C# Winform application built in Visual Studio 2019 libvlcsharp runtime version v4.0.30319 version 3.4.4.0
I built a simpler application that has the same problem as one that is currently deployed.
Here's where the code gets the player started:
videoView1.MediaPlayer.Play(new Media(_libVLC, URI,FromType.FromLocation));
Here's the cleanup code snip:
videoView1.MediaPlayer.Stop();
videoView1.MediaPlayer.Dispose();
videoView1.Dispose();
//dispose glibvlc at higher level
The MediaPlayer dispose works OK no errors. However, videoview dispose causes a Memory Access Violation. I know this isn't normal because I built a simple c# application without using a task to dispose and clean up the objects and that worked just fine.
However the application I'm trying to debug has one thread per stream that is being displayed to manage setting up and shutting down each connection.
If the code just calls dispose on the mediaplayer and does not dispose the videoview object then the object that contains the libvlcsharp objects causes a Memory Access Violation when it gets disposed.
If I don't dispose of the MediaPlayer object any subsequent object dispose calls work OK.
I have verified that this leaks memory.
In UI class
Setup all the form variables.
instantiate LibVLC
StartVideo(); This ends with the Play method
Task.Run(() => Ask()); This emulates what may be happening in the
real app
The Ask function asks if the user wants to exit the program or kill the current player and build and start it again.
if user cancels it exits through the On Application Exit handler which
does executes the Dispose sequence shown above. This works as designed.
If user kills and restarts then it fails on the videoView1 dispose as
described above.
Here's the c# sample ask function.
public void Ask()
{
while (true)
{
DialogResult r = MessageBox.Show("Dispose and Start Again?", "Memory Access Violation Test", MessageBoxButtons.OKCancel);
if (r == DialogResult.OK)
{
videoView1.MediaPlayer.Stop();
videoView1.MediaPlayer.Dispose();
videoView1.Dispose();
StartVideo();
}
else
{
Invoke(new Action(() => this.Close()));
}
}
}
To fix problem upgrade to version 3.6.1.0 for both libvlcsharp and libvlcwinforms.winforms
We are on CC&B 2.6. We run base process PUPL Payment Upload on 8 threads. Occasionally the process fails on a thread. The other threads run successfully. And when we restart the job, that thread recovers and completes successfully.
The error message shown is:
SQL Error code 000099997 occurred in module CIPPUPFN:HA100 - UPDATE TCTL
Has anyone encountered this?
This problem might have been caused by a bug in the product that handles the interaction of
sessions and the ThreadlocalStorage object. Some session-related state, such
as the map of DBLocalCobolSQLProcessBackend instances was stored on
ThreadlocalStorage, when it should be on FrameworkSession.
If another session is temporarily "pushed" onto ThreadlocalStorage (e.g. via
SessionExecutable>>doInReadOnlySession()) the original session is set aside
but the map of DBLocalCobolSQLProcessBackend was improperly destroyed and could not be restored when the original session was restored.
If a subsequent db-related call from COBOL into Java requires access to an instance of DBLocalCobolSQLProcessBackend, the desired instance was missing and a new, empty one was created, which lead to a NPE in downstream code.
We have integrated flash game (crazytaxi.swf) inside Windows form application in VS Express 2012 for Windows Desktop.We are controlling game with the help of gestures using leapmotion controller.
What happens is when we run project in VS2012,game starts normally.We play game using gesture (left,right etc.).But after some time controller stops listening by exiting its thread.We can see that in output window.
"The thread '' (0x1b50) has exited with code 0 (0x0)." this we get in output window.
We are not getting how to overcome this challenge.
You didn't provide enough information but from what I gather, your LEAP thread ran to completion and closed. This can occur if you declare and initialize your listener and controller variables in a function and the variables go out of scope when the function is executed. This causes Garbage Collector to dispose both controller and listener at what might seemingly appear as random (non reproductable) moments. To fix this issue, create a singleton for the controller and listener - this can boil down to simply defining a static controller and listener variables in some class. This way the listener and controller objects will never go out of scope and get disposed by the GC.
"The thread '' (0x1b50) has exited with code 0 (0x0) basically says that:
The thread with the ID 6992 ran and completed the operation successfully.
System Error Codes (0-499)
The question is, does the device stop tracking?
Here are my 0x0's from my Leap Motion app (its working fine):
The thread 'vshost.NotifyLoad' (0x364) has exited with code 0 (0x0).
The thread '' (0x3348) has exited with code 0 (0x0).
The thread 'vshost.LoadReference' (0x37c8) has exited with code 0 (0x0).
Also, on a side note, because it has nothing to do with the error code - are you removing the listener from the controller, and then disposing of them both when the application is being closed? Not properly disposing of objects will cause problems.
A second note - onExit and onDisconnet are two different things.
onDisconnect(controller:Controller):void
Called when the Controller object disconnects from the Leap Motion software.
Listener
onExit(controller:Controller):void
Called when this Listener object is removed from the Controller or the Controller instance is destroyed.
In case somebody is having similar problems here is the reply I sent over email after having a look at the code:
I've looked at the code, since you only sent me a few files I had to comment out the the references to classes that was not included in the zip.
The code runs fine with 3 different Leap Motion devices - when I comment out from the method, what I suggest is:
Update the SDK. I used .Net 4 dll and the latest version of the SDK which today is: v.1.0.8.7665
Dispose the objects once you are done using them. Dispose Frames after using them, Remove listener from the Controller, and dispose Controller when the device isn't used anymore or the application is being closed.
I noticed some Timers and DispatcherTimers they were being created, but I couldn't find any references to where they were being used. What are these being used for? DispatcherTimer doesn't belong in a windows forms application.
My best guess - and I hate to guess - is that there is a threading problem OR that the objects aren't being disposed correctly - OR you are using an SDK version that had bugs.
I have two applications on GitHub - feel free to use the code as you want. There is one for WPF and one for Windows Forms - both need to be updated for latest SDK as some things have been deprecated (such as the Screen class) in later versions of the SDK.
WPF:
https://github.com/IrisClasson/Leap-Motion
Windows Forms:
https://github.com/IrisClasson/LeapMotion_WinForms_Demo_OLD_SDK
Disclaimer: I don't do much, if any WinForms development
I had a same issue with my WPF application and Leap Motion code but the code works fine with a console application.
In WPF when I globally declared the Leap-Listener and the controller Object, I did not face the error any more and the Listener is active all time.
Just declare the listener and controller in the class (globally) from which you call the listener
public static LeapListener listener;
public static Controller controller;
Now use this listener object, and add it to the controller and enable gesture property of the controller in a function or a constructor.
listener = new LeapListener();
controller.AddListener(listener);
controller = new Controller();
This should solve the issue. If the problem still persists (detection problem), simply initialize and add the same listener object to the controller object onExit event. Now the gesture and other properties exist as you are not creating a new instance of the controller again.
I started with a simple Python 2.5 app engine app and migrated it to Python 2.7 in hopes of taking advantage of its multithreaded abilities. After migrating, I noticed that webapp2.RequestHandler instances are all being called from the Main Thread.
I have an AJAX client firing up multiple asynchronous requests. One of the requests I'd like to respond only when certain event occurs on server side. Let's just say that event sleeps for 10 seconds for now. The problem is that sleep occurs in the Main Thread and occupies the thread before processing my second ASYNC request from AJAX. What am I missing?
Here's a stack trace:
PyDevDebug [PyDev Google App Run]
dev_appserver.py
MainThread - pid4276_seq4
post [test1.py:53]
dispatch [webapp2.py:570]
call [webapp2.py:1102]
default_dispatcher [webapp2.py:1278]
call [webapp2.py:1529]
Handle [wsgi.py:223]
HandleRequest [wsgi.py:298]
HandleRequest [runtime.py:151]
ExecutePy27Handler [dev_appserver.py:1525]
ExecuteCGI [dev_appserver.py:1701]
Dispatch [dev_appserver.py:1803]
Dispatch [dev_appserver.py:719]
_Dispatch [dev_appserver.py:2870]
_HandleRequest [dev_appserver.py:3001]
do_POST [dev_appserver.py:2794]
handle_one_request [BaseHTTPServer.py:328]
handle [BaseHTTPServer.py:340]
init [SocketServer.py:638]
init [dev_appserver.py:2780]
finish_request [SocketServer.py:323]
process_request [SocketServer.py:310]
_handle_request_noblock [SocketServer.py:284]
handle_request [dev_appserver.py:3991]
serve_forever [dev_appserver.py:4028]
main [dev_appserver_main.py:721]
[dev_appserver_main.py:747]
run_file [dev_appserver.py:167]
[dev_appserver.py:171]
run [pydevd.py:1090]
[pydevd.py:1397]
Thread-4 - pid4276_seq5
dev_appserver.py
It seems that in the dev (local) server parallel threads are not executed in parallel, but serial.
There is an "experimental dev server" here which you just reminded me of:
An experimental new development server for Google App Engine.
Multithreaded serving for better performance for complex applications and more correct semantics e.g. accessing your own application through urlfetch no longer deadlocks.
That might solve it locally, but I've not tried it personally.
In my iphone application i am getting an error 'EXEC_BAD_ACCESS'.First time when i run application it ran and at some point of time i got this error and the application terminated.After that i am not able to run it.
The error occurred at main.m in second line of code.
Check that you're not overreleasing something or that you are not calling on an object you have not allocate for, if you post a small code snippet we can possibly help you some more.