Constraint Layout memory leak on Fragment - android-fragments

So, i'am trying to learn about memory leaking with Leak Canary, and found that every fragment that i have is leaking. I'am using viewbinding in here, and here is the log:
androidx.constraintlayout.widget.ConstraintLayout instance
Leaking: YES (ObjectWatcher was watching this because com.lelestacia.lelenimexml.feature.anime.ui.home.
AnimeFragment received Fragment#onDestroyView() callback (references to its views should be cleared to prevent leaks))
Retaining 3.0 kB in 63 objects
key = e41d026f-fe51-475c-bb6a-ddbb25fe0bd0
watchDurationMillis = 13782
retainedDurationMillis = 8781
View not part of a window view hierarchy
View.mAttachInfo is null (view detached)
View.mWindowAttachCount = 1
mContext instance of dagger.hilt.android.internal.managers.ViewComponentManager$FragmentContextWrapper, wrapping
activity com.lelestacia.lelenimexml.MainActivity with mDestroyed = false
Even when i tried to set the binding to null inside onDestroyView, the constraint layout of all fragment is still leaking.

Related

What could cause .wasm to load images so slowly?

In my Uno test project, it takes about 4 seconds to load 50 images into an ItemsWrapGrid on the UWP platform. The same images take 225 seconds (3 minute 45 seconds) to load into a WrapPanel. Since the only difference in the code is ItemsWrapGrid or WrapPanel, I'm thinking the problem is the WrapPanel, but I can't be sure, it could be in how the platforms implement the <Image ItemsSource=""/.
I don't have any experience with .wasm so I don't know if this is expected (is it?). Is there something I can do to Optimize for wasm?
or any other thoughts? 4- minutes is just not acceptable compared to about 4 seconds.
Thanks
Thanks for asking if I could repro in Uno Playground. I was unaware of the site.
I was NOT ABLE to repro on the playground, which led me to investigate other possibilities.
I have resolved the issue.
My design pattern was to define a single ObservableCollection without a property change notification:
public ObservableCollection<PictureViewModel> Pictures {get;set }
I would bind that to my UserControl and update by Pictures.Clear().
This is my snippet that resulted in the long render time:
List<Picture> PictList = await DataService.GetPicturesByEvent(this.SelectedEvent.EvtKey, clubkey, skipPosition, this.PagingViewModel.PageSize);
List<PictureViewModel> PictVMList = mapper.Map<List<Picture>, List<PictureViewModel>>(PictList);
if (PictVMList != null && this.SelectedEvent != null && !string.IsNullOrEmpty(SelectedEvent.FilePath))
{
this.Pictures.Clear();
foreach (PictureViewModel item in PictVMList)
{
item.Parent = this;
item.SetURL(SelectedEvent);
this.Pictures.Add(item);
}
this.SelectedPicture = PictVMList.Count > 0 ? PictVMList.First() : null;
}
To resolve the long render time. I:
Made my ObservableCollection observable.
Removed all instances of Picture.Clear();
Created a new ObservableCollection whenever it needed updating.
The Resolved code snippet is:
List<Picture> PictList = await DataService.GetPicturesByEvent(this.SelectedEvent.EvtKey, clubkey, skipPosition, this.PagingViewModel.PageSize);
List<PictureViewModel> PictVMList = mapper.Map<List<Picture>, List<PictureViewModel>>(PictList);
if (PictVMList != null && this.SelectedEvent != null && !string.IsNullOrEmpty(SelectedEvent.FilePath))
{
foreach (PictureViewModel item in PictVMList)
{
item.Parent = this;
item.SetURL(SelectedEvent);
}
this.SelectedPicture = PictVMList.Count > 0 ? PictVMList.First() : null;
}
Pictures = new ObservableCollection<PictureViewModel>(PictVMList);
I don't understand why my initial code pattern did not work as expected, but can live with adding an OnPropertyChanged("Pictures") notification.
As of Uno 3.10, ItemWrapGrid is not supported on WebAssembly. Using the WrapPanel control will force the materialization of all the items in the list, making the performance particularly slow.
You're not specifying which control you're using as a panel, but if you're using a ListView control, the virtualization will be enabled, though not with the layout wrapping that you need.
If you want virtualizing grid-like layouts, you can also use the ItemsRepeater control, and its layouts (e.g. FlowLayout, StackLayout, or WCT's WrapLayout).

WF4 Ready Instances

How can I find out what items in the database are ready to be ran. In other words, I want to query the persistence tables to identify what items have the lock that expired. I can't seem to find any fields that would show this.
I've never worked it out either.
I've used workflow.Load and caught the exception; which is nasty but worked.
On an WorkflowApplication instance, you can use the LoadRunnableInstance method which automatically loads the next available workflow in the instance store whose lock has expired.
AutoResetEvent sync = new AutoResetEvent(false);
Workflow1 myWorkflow = new Workflow1();
SqlWorkflowInstanceStore instanceStore = new SqlWorkflowInstanceStore("<my connection string>");
WorkflowApplication wfApp = new WorkflowApplication(myWorkflow);
wfApp.InstanceStore = instanceStore;
wfApp.Completed += (eventArgs) => sync.Set();
wfApp.LoadRunnableInstance();
wfApp.Run();
sync.WaitOne();

Cocos3d:OpenGL error 0x0506 in -[EAGLView swapBuffers] and blank scene

In my cocos3d application, i have a UIViewController as rootview controller and from there i'll launch again Cocos3d scenes when use clicking on an option.
Here is my code below to launch scene from this view controller. Issue is, if i open uiviewcontroller and then move to scene by clicking on an option more than twice, then i'm getting error as "OpenGL error 0x0506 in -[EAGLView swapBuffers]
[GL ERROR] Unknown GL error (1286), before drawing HomeOwners3DScene Unnamed:1691. To investigate further, set the preprocessor macro GL_ERROR_TRACING_ENABLED=1 in your project build settings."
[This issue doesn't come first time when i view the scene, it shows properly. But if i go back and click back to show the scene more than twice or more, then it appeared to be blank scene with the below error in xcode]
Code below to move from my viewcontroller to further scenes:
-(void) launchMainScene :(UIViewController *) uiViewCrtller
{
[uiViewCrtller.view removeFromSuperview];
// This must be the first thing we do and must be done before establishing view controller.
if( ! [CCDirector setDirectorType: kCCDirectorTypeDisplayLink] )
[CCDirector setDirectorType: kCCDirectorTypeDefault];
// Default texture format for PNG/BMP/TIFF/JPEG/GIF images.
// It can be RGBA8888, RGBA4444, RGB5_A1, RGB565. You can change anytime.
CCTexture2D.defaultAlphaPixelFormat = kCCTexture2DPixelFormat_RGBA8888;
// Create the view controller for the 3D view.
viewController = [CC3DeviceCameraOverlayUIViewController new];
//viewController.supportedInterfaceOrientations = UIInterfaceOrientationLandscapeRight | UIInterfaceOrientationMaskLandscapeLeft;
// Create the CCDirector, set the frame rate, and attach the view.
CCDirector *director = CCDirector.sharedDirector;
//director.runLoopCommon = YES; // Improves display link integration with UIKit
[director setDeviceOrientation:kCCDeviceOrientationPortrait];
director.animationInterval = (1.0f / kAnimationFrameRate);
director.displayFPS = YES;
director.openGLView = viewController.view;
// Enables High Res mode on Retina Displays and maintains low res on all other devices
// This must be done after the GL view is assigned to the director!
[director enableRetinaDisplay: YES];
[director setDepthTest:NO];
// Create the window, make the controller (and its view) the root of the window, and present the window
[window addSubview: viewController.view];
CCDirector.sharedDirector.displayFPS = NO;
[CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA8888];
// Set to YES for Augmented Reality 3D overlay on device camera.
// This must be done after the window is made visible!
viewController.isOverlayingDeviceCamera = NO;
// Create the customized CC3Layer that supports 3D rendering and schedule it for automatic updates.
CC3Layer* cc3Layer = [HomeOwners3DLayer node];
[cc3Layer scheduleUpdate];
// Create the customized 3D scene and attach it to the layer.
// Could also just create this inside the customer layer.
cc3Layer.cc3Scene = [HomeOwners3DScene scene];
// Assign to a generic variable so we can uncomment options below to play with the capabilities
CC3ControllableLayer* mainLayer = cc3Layer;
CCScene *scene = [CCScene node];
[scene addChild: mainLayer];
[[CCDirector sharedDirector] runWithScene: scene];
}
Below Error is throwing in Xcode console when i launch scene and go back viewcontroller and launch scene multiple times with showing blank screen in the scene:
*[This issue doesn't come first time when i view the scene, it shows properly. But if i go back and click back to show the scene more than twice or more, then it appeared to be blank scene with the below error in xcode]*
OpenGL error 0x0506 in -[EAGLView swapBuffers]
[GL ERROR] Unknown GL error (1286), before drawing HomeOwners3DScene Unnamed:1691. To investigate further, set the preprocessor macro GL_ERROR_TRACING_ENABLED=1 in your project build settings.
Please help to solve my problem.
Thank you.

DirectShow .Net AddSourceFilter Release file

I have an application which plays video using DirectShow.Net and also records video. When I try to record to a filename that has just been used for playback by DirectShow it fails as the file is still in use. Sometimes it will work but take anywhere from 5 - 60 seconds until the file is unlocked. Before the recording is attempted the playback graph has definitely been destroyed. The code for creating and destroying the graph is below. If I stop and start my application following playback I can record to the same filename and there are no file locking issues.
Can anyone advise how I can correctly release the source filter so the file is not locked?
Creating the graph
try
{
graphBuilder = (IGraphBuilder)new FilterGraph();
#if DEBUG
// "Connect to remote graph" in GraphEdit
rotEntry = new DsROTEntry(graphBuilder);
#endif
hr = graphBuilder.AddSourceFilter(filename, filename, out baseFilter);
DsError.ThrowExceptionForHR(hr);
vmr9 = (IBaseFilter)new VideoMixingRenderer9();
ConfigureVMR9InWindowlessMode();
hr = graphBuilder.AddFilter(vmr9, "Video Mixing Renderer 9");
DsError.ThrowExceptionForHR(hr);
FilterGraphTools.ConnectFilters(graphBuilder, baseFilter, "Output", vmr9, "VMR Input0", true);
}
Destroying the graph
if (vmr9 != null)
{
Marshal.ReleaseComObject(vmr9);
vmr9 = null;
windowlessCtrl = null;
}
if (graphBuilder != null)
{
// Remove and release all filters
FilterGraphTools.RemoveAllFilters(graphBuilder);
Marshal.ReleaseComObject(graphBuilder);
graphBuilder = null;
baseFilter = null;
}
#if DEBUG
if (rotEntry != null)
{
rotEntry.Dispose();
rotEntry = null;
}
#endif
Eventually the graph is a set of connected COM objects, and successful graph termination depends on correct release, without any leaked references. References that you might have left unreleased are leading to objects kept alive and possibly locking certain resources.
The best you can do is explicit termination/removal of individual objects:
Stop the graph
Remove all fitlers explicitly using IFilterGraph2.RemoveFilter
Use filter dependent methods calls to possibly terminate individual filters, such as by putting empty path to file source/sink filters
If even leak takes place, the graph should no longer reference resources. Note that you sometimes can also reuse filters if you are re-creating the graph.

Changing frequency of ASP.NET cache item expiration?

I noticed that the ASP.NET cache items are inspected (and possibly removed) every 20 seconds (and oddly enough each time at HH:MM:00, HH:MM:20 and HH:MM:40). I spent about 15 minutes looking how to change this parameter without any success. I also tried to set the following in web.config, but it did not help:
<cache privateBytesPollTime="00:00:05" />
I’m not trying to do anything crazy, but it would be nice if it was, say, 5 seconds instead of 20, or at least 10 for my application.
Poking around with Reflector reveals that the the interval is hardcoded. Expiry is handled by an internal CacheExpires class, whose static constructor contains
_tsPerBucket = new TimeSpan(0, 0, 20);
_tsPerBucket is readonly, so there can't be any configuration setting that modifies it later.
The timer that will trigger the check for expired items is then set up in CacheExpires.EnableExpirationTimer()...
DateTime utcNow = DateTime.UtcNow;
TimeSpan span = _tsPerBucket - new TimeSpan(utcNow.Ticks % _tsPerBucket.Ticks);
this._timer = new Timer(new TimerCallback(this.TimerCallback), null,
span.Ticks / 0x2710L, _tsPerBucket.Ticks / 0x2710L);
The calculation of span ensures that the timer fires exactly on :00, :20, :40 seconds, though I can't see any reason to bother. The method that the timer calls is internal, so I don't think there's any way to set up your own timer to call it more often (ignoring reflection).
However, the good news is that you shouldn't really have any reason to care about the interval. Cache.Get() checks that the item hasn't expired, and if it has then it removes the item from the cache immediately and returns null. Therefore you'll never get an expired item from the cache, even though expired items may stay in the cache for up to 20 seconds.
According to the documentation, privateBytesPollTime is for "worker process memory usage" and the default is 1 second. I don't think this relates to cache item removal.
I did confirm your results using an item removal callback- it looks like items are removed at the bottom of the minute, :20, and :40 seconds. This suggests that an item may remain in the cache for up to 20 seconds past the AbsoluteExpiration set on them. I couldn't find any documentation stating whether the 20 second polling interval could be changed.
Crazy, but working solution (all steps are needed):
// New value for cache expiration cycle
// System.Web.Caching.CacheExpires._tsPerBucket;
// Set 1 seconds instead of 20sec
const string assembly = "System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
var type = Type.GetType("System.Web.Caching.CacheExpires, " + assembly, true, true);
var field = type.GetField("_tsPerBucket", BindingFlags.Static | BindingFlags.NonPublic);
field.SetValue(null, TimeSpan.FromSeconds(1));
// Recreate cache
// HttpRuntime._theRuntime._cacheInternal = null;
// HttpRuntime._theRuntime._cachePublic = null;
type = typeof (HttpRuntime);
field = type.GetField("_theRuntime", BindingFlags.Static | BindingFlags.NonPublic);
var runtime = field.GetValue(null);
field = type.GetField("_cachePublic", BindingFlags.NonPublic | BindingFlags.Instance);
field.SetValue(runtime, null);
field = type.GetField("_cacheInternal", BindingFlags.NonPublic | BindingFlags.Instance);
field.SetValue(runtime, null);

Resources