Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MvxLayoutInflater Disposed exception #1924

Closed
Nickolas- opened this issue Jun 8, 2017 · 7 comments
Closed

MvxLayoutInflater Disposed exception #1924

Nickolas- opened this issue Jun 8, 2017 · 7 comments
Labels
p/android Android platform s/needs-more-info Needs more information from the reporter

Comments

@Nickolas-
Copy link
Contributor

Nickolas- commented Jun 8, 2017

To help us fix your issue, please provide the information in the below template.

Hi guys, I need a help with mysterious bug that I can't understand how it happening.
The situation is very complicated and hope I can create test project for that.

I have initial android Activity with 4 fragments. For every fragment I'm using ViewStub to load it lazy. On first start i'm load first fragment. There are just simple RecyclerView. I select any item. Item will open next activity where I can do upload data to the server. The data can be like ~30 mb. While I uploading a data I fast close that activity and try to click on next fragment (toolbar).

When fragment appear I try to inflate ViewStub.

protected void ViewStubInflate()
{
	using (new MvxBindingContextStackRegistration<IMvxAndroidBindingContext>((IMvxAndroidBindingContext)this.BindingContext))
	{
		ViewModel = Mvx.Resolve<IMvxViewModelLoader>().LoadViewModel(new MvxViewModelRequest(typeof(CategoriesListViewModel), null, null, null), null) as CategoriesListViewModel;

		mViewStub.LayoutInflater = Activity.LayoutInflater;
		CreateCategoriesBinding();
	}

Second fragment is living in separate project. But I don't think this is a problem.

If I check this.BindingContext if would find that LayoutInflaterHolder LayoutInflater is Disposed.

image

When viewStub start to inflate , it try to inflate MvxRecyclerView Holder and getting from stack disposed MvxLayoutInflater and then me give exception.

It's very interesting if I open other fragments, there are fine.

How I fixed for right now, I manually create new LayoutInflaterHolder with new MvxLayoutInfalter.

The project is too big to create sample fast. I hope I can reproduce it at test repository with same behavior.

Any advices or any ideas I would appreciate.
Thank you.

Version:
4.4.0

Platform:
Android

@kjeremy
Copy link
Contributor

kjeremy commented Jun 8, 2017

Please use the latest version of MvvmCross. 4.4.0 contains lots of MvxRecyclerView bugs.

@Nickolas-
Copy link
Contributor Author

Nickolas- commented Jun 8, 2017

I don't think this a MvxRecyclerView bug, because problem with BindingContext of Fragment.

mViewStub.LayoutInflater = new MvxLayoutInflater(Activity);
(this.BindingContext as MvxAndroidBindingContext).LayoutInflaterHolder = new MvxSimpleLayoutInflaterHolder(mViewStub.LayoutInflater);

If I wrote this, everything would work as aspected.

@kjeremy
Copy link
Contributor

kjeremy commented Jun 8, 2017

There have been a lot of fixes there too :)

@Nickolas-
Copy link
Contributor Author

Too push new version of mvvmcross is too big for us right now.

@Cheesebaron
Copy link
Member

You could do this:

  • Make a branch in your VCS
  • Update to latest MvvmCross
  • See if your issues still persist

If not, just throw away the branch, no harm done.

@martijn00 martijn00 added p/android Android platform s/needs-more-info Needs more information from the reporter labels Jul 20, 2017
@Guillaume-Fortin
Copy link

I have this problem with an adapter inside a fragment => mvvmcross 5.3.1.

Only one fragment cause the problem. i will investigate

Stack:

System.ObjectDisposedException: Cannot access a disposed object.
10-31 15:31:25.277 I/MonoDroid(22129): Object name: 'MvvmCross.Binding.Droid.Views.MvxLayoutInflater'.
10-31 15:31:25.277 I/MonoDroid(22129): at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00029] in <1d799d87381c4db5b1252825fd105b84>:0
10-31 15:31:25.277 I/MonoDroid(22129): at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00000] in <1d799d87381c4db5b1252825fd105b84>:0
10-31 15:31:25.277 I/MonoDroid(22129): at Android.Views.LayoutInflater.Inflate (System.Int32 resource, Android.Views.ViewGroup root, System.Boolean attachToRoot) [0x0005a] in <484cd191a834496c85d38d0e644a42c4>:0
10-31 15:31:25.277 I/MonoDroid(22129): at MvvmCross.Binding.Droid.Views.MvxLayoutInflater.Inflate (System.Int32 resource, Android.Views.ViewGroup root, System.Boolean attachToRoot) [0x0003e] in C:\projects\mvvmcross\MvvmCross\Binding\Droid\Views\MvxLayoutInflater.cs:137
10-31 15:31:25.277 I/MonoDroid(22129): at MvvmCross.Binding.Droid.BindingContext.MvxAndroidBindingContext.CommonInflate (System.Int32 resourceId, Android.Views.ViewGroup viewGroup, System.Boolean attachToRoot) [0x00013] in C:\projects\mvvmcross\MvvmCross\Binding\Droid\BindingContext\MvxAndroidBindingContext.cs:52
10-31 15:31:25.277 I/MonoDroid(22129): at MvvmCross.Binding.Droid.BindingContext.MvxAndroidBindingContext.BindingInflate (System.Int32 resourceId, Android.Views.ViewGroup viewGroup, System.Boolean attachToRoot) [0x00000] in C:\projects\mvvmcross\MvvmCross\Binding\Droid\BindingContext\MvxAndroidBindingContext.cs:36
10-31 15:31:25.277 I/MonoDroid(22129): at MvvmCross.Droid.Support.V7.RecyclerView.MvxRecyclerAdapter.InflateViewForHolder (Android.Views.ViewGroup parent, System.Int32 viewType, MvvmCross.Binding.Droid.BindingContext.IMvxAndroidBindingContext bindingContext) [0x0000d] in C:\projects\mvvmcross\MvvmCross-AndroidSupport\MvvmCross.Droid.Support.V7.RecyclerView\MvxRecyclerAdapter.cs:173
10-31 15:31:25.277 I/MonoDroid(22129): at keyneo.CustomerSearchAdapter.OnCreateViewHolder (Android.Views.ViewGroup parent, System.Int32 viewType)

@Cheesebaron
Copy link
Member

@Thetyne please open a new issue with repro steps. Closing this one as it is stale and yours doesn't seem to relate to this one directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p/android Android platform s/needs-more-info Needs more information from the reporter
Development

No branches or pull requests

5 participants