FabianTerhorst / FastLayout

Generates a Java Object for your xml layout to reduce inflate time to zero
Apache License 2.0
443 stars 35 forks source link

Crash on exit, re-enter app #27

Closed ersin-ertan closed 6 years ago

ersin-ertan commented 7 years ago

Trying a base example, went back, then opened the app again.

E/AndroidRuntime: FATAL EXCEPTION: main
                  Process: com.nullcognition.fastlayout, PID: 30018
                  java.lang.IllegalArgumentException: parameter must be a descendant of this view
                      at android.view.ViewGroup.offsetRectBetweenParentAndChild(ViewGroup.java:5681)
                      at android.view.ViewGroup.offsetDescendantRectToMyCoords(ViewGroup.java:5610)
                      at android.view.ViewGroup$ViewLocationHolder.init(ViewGroup.java:8110)
                      at android.view.ViewGroup$ViewLocationHolder.obtain(ViewGroup.java:8044)
                      at android.view.ViewGroup$ChildListForAccessibility.init(ViewGroup.java:7979)
                      at android.view.ViewGroup$ChildListForAccessibility.obtain(ViewGroup.java:7947)
                      at android.view.ViewGroup.addChildrenForAccessibility(ViewGroup.java:2036)
                      at android.view.ViewGroup.addChildrenForAccessibility(ViewGroup.java:2045)
                      at android.view.ViewGroup.addChildrenForAccessibility(ViewGroup.java:2045)
                      at android.view.ViewGroup.addChildrenForAccessibility(ViewGroup.java:2045)
                      at android.view.ViewGroup.addChildrenForAccessibility(ViewGroup.java:2045)
                      at android.view.ViewGroup.addChildrenForAccessibility(ViewGroup.java:2045)
                      at android.view.ViewGroup.onInitializeAccessibilityNodeInfoInternal(ViewGroup.java:3281)
                      at android.view.View.onInitializeAccessibilityNodeInfo(View.java:6626)
                      at android.view.View.createAccessibilityNodeInfoInternal(View.java:6585)
                      at android.view.View.createAccessibilityNodeInfo(View.java:6570)
                      at android.view.accessibility.AccessibilityRecord.setSource(AccessibilityRecord.java:145)
                      at android.view.accessibility.AccessibilityRecord.setSource(AccessibilityRecord.java:119)
                      at android.view.View.onInitializeAccessibilityEventInternal(View.java:6522)
                      at android.view.View.onInitializeAccessibilityEvent(View.java:6510)
                      at android.view.View.sendAccessibilityEventUncheckedInternal(View.java:6369)
                      at android.view.View.sendAccessibilityEventUnchecked(View.java:6354)
                      at android.view.ViewRootImpl$SendWindowContentChangedAccessibilityEvent.run(ViewRootImpl.java:8912)
                      at android.view.ViewRootImpl$SendWindowContentChangedAccessibilityEvent.runOrPost(ViewRootImpl.java:8938)
                      at android.view.ViewRootImpl.postSendWindowContentChangedCallback(ViewRootImpl.java:7925)
                      at android.view.ViewRootImpl.notifySubtreeAccessibilityStateChanged(ViewRootImpl.java:8104)
                      at android.view.View.notifySubtreeAccessibilityStateChangedIfNeeded(View.java:9394)
                      at android.view.ViewGroup.addViewInner(ViewGroup.java:4715)
                      at android.view.ViewGroup.addView(ViewGroup.java:4490)
                      at android.view.ViewGroup.addView(ViewGroup.java:4462)
                      at com.android.internal.policy.PhoneWindow$DecorView.updateColorViewInt(PhoneWindow.java:3526)
                      at com.android.internal.policy.PhoneWindow$DecorView.updateColorViews(PhoneWindow.java:3434)
                      at com.android.internal.policy.PhoneWindow$DecorView.onApplyWindowInsets(PhoneWindow.java:3377)
                      at android.view.View.dispatchApplyWindowInsets(View.java:7818)
                      at android.view.ViewGroup.dispatchApplyWindowInsets(ViewGroup.java:6647)
                      at android.view.ViewRootImpl.dispatchApplyInsets(ViewRootImpl.java:1662)
                      at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1783)
                      at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1487)
                      at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7456)
                      at android.view.Choreographer$CallbackRecord.run(Choreographer.java:920)
                      at android.view.Choreographer.doCallbacks(Choreographer.java:695)
                      at android.view.Choreographer.doFrame(Choreographer.java:631)
                      at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:906)
                      at android.os.Handler.handleCallback(Handler.java:739)
                      at android.os.Handler.dispatchMessage(Handler.java:95)
                      at android.os.Looper.loop(Looper.java:158)
                      at android.app.ActivityThread.main(ActivityThread.java:7229)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
FabianTerhorst commented 7 years ago

Can you provide an layout xml that is reproducing this error?

ersin-ertan commented 7 years ago

Sure, project is here and the layout is here.

FabianTerhorst commented 7 years ago

Can you test what is happening when you use the layout without using the cache?

ersin-ertan commented 7 years ago

Is this what you mean by without cache. If so, working as intended.

    //ActivityMainLayout layout =
    //LayoutCache.getInstance().getLayout(this, LayoutCache.Activity_Main_Layout);

    setContentView(R.layout.activity_main);
FabianTerhorst commented 7 years ago

New ActivityMainLayout(this)

ersin-ertan commented 7 years ago

Tested with:

ActivityMainLayout layout = new ActivityMainLayout(this);
setContentView(layout);

working as correctly.

FabianTerhorst commented 7 years ago

Looks like the cache needs an invalidation when exiting the App.

ersin-ertan commented 7 years ago

Is this something that the developer should be doing, or done via the library?

FabianTerhorst commented 7 years ago

The Library needs an invalidate inside the cache. The developer has to call this in the ondestroy of the activity.

ersin-ertan commented 7 years ago

Ok, I'll be watching the repo, so if you need someone to test, I can verify functionality.