Transition blink after orientation change
J

3

8

UPDATE

Ive opened a bug with Google https://issuetracker.google.com/issues/63663775

I am attempting to employ makeSceneTransitionAnimation within my current Android Application.

I have a Source Activity, that contains a Fragment, and within the Fragment is a RecyclerView.

When I click on an image in the RecyclerView I transition to my Target Activity that contains a Fragment which correctly displays the image with an acceptable Animation.

Pressing the back button reverses the animation correctly.

The above works fine in both Portrait and Landscape orientation.

The issue of BLINKING occurs when I change orientation while viewing the target Fragment then press the Back Button.

There are other issues such as the image doesn't return directly to its original position, and on older devices I see horizontal lines like interference from an badly tuned analogue Television.

Its the BLINKING that is very bad, the device screen goes completely BLACK for approximately 500ms.

I have downloaded and deployed the google sample shared element transitions app and it appears to have the same "Feature".

I have tried multiple solutions and none of them have worked, such as this.

Here's a of the that exhibits the issue.

LOGCAT ADDED

07-21 12:57:18.097 1962-1967/com.incentive.yellowpages I/zygote64: Do partial code cache collection, code=30KB, data=21KB
07-21 12:57:18.099 1962-1967/com.incentive.yellowpages I/zygote64: After code cache collection, code=30KB, data=23KB
07-21 12:57:18.099 1962-1967/com.incentive.yellowpages I/zygote64: Increasing code cache capacity to 128KB
07-21 12:57:20.540 1962-2058/com.incentive.yellowpages D/OkHttp: --> GET http://www.spyur.am/en/home/search-1/?company_name=Happy http/1.1
07-21 12:57:20.688 1962-1967/com.incentive.yellowpages I/zygote64: Do partial code cache collection, code=61KB, data=55KB
07-21 12:57:20.688 1962-1967/com.incentive.yellowpages I/zygote64: After code cache collection, code=61KB, data=55KB
07-21 12:57:20.688 1962-1967/com.incentive.yellowpages I/zygote64: Increasing code cache capacity to 256KB
07-21 12:57:21.084 1962-2058/com.incentive.yellowpages D/OkHttp: <-- 200 OK http://www.spyur.am/en/home/search-1/?company_name=Happy (543ms, unknown-length body)
07-21 12:57:22.197 1962-1967/com.incentive.yellowpages I/zygote64: Do full code cache collection, code=124KB, data=93KB
07-21 12:57:22.197 1962-1967/com.incentive.yellowpages I/zygote64: After code cache collection, code=98KB, data=59KB
07-21 12:57:22.377 1962-1967/com.incentive.yellowpages I/zygote64: Do partial code cache collection, code=101KB, data=79KB
07-21 12:57:22.378 1962-1967/com.incentive.yellowpages I/zygote64: After code cache collection, code=101KB, data=79KB
07-21 12:57:22.378 1962-1967/com.incentive.yellowpages I/zygote64: Increasing code cache capacity to 512KB
07-21 12:57:22.378 1962-1967/com.incentive.yellowpages I/zygote64: Compiler allocated 4MB to compile boolean org.jsoup.parser.HtmlTreeBuilderState$7.process(org.jsoup.parser.Token, org.jsoup.parser.HtmlTreeBuilder)
07-21 12:57:22.701 1962-1967/com.incentive.yellowpages I/zygote64: Compiler allocated 4MB to compile void android.view.View.<init>(android.content.Context, android.util.AttributeSet, int, int)
07-21 12:57:24.495 1962-1967/com.incentive.yellowpages I/zygote64: Do full code cache collection, code=245KB, data=178KB
07-21 12:57:24.495 1962-1967/com.incentive.yellowpages I/zygote64: After code cache collection, code=216KB, data=130KB
07-21 12:57:25.040 1962-2058/com.incentive.yellowpages D/OkHttp: --> GET http://www.spyur.am/en/companies/happy-print-printing-house/34896 http/1.1
07-21 12:57:25.101 1962-1962/com.incentive.yellowpages D/ViewRootImpl[DetailActivity]: changeCanvasOpacity: opaque=true
07-21 12:57:25.437 1962-2058/com.incentive.yellowpages D/OkHttp: <-- 200 OK http://www.spyur.am/en/companies/happy-print-printing-house/34896 (396ms, unknown-length body)
07-21 12:57:26.111 1962-1962/com.incentive.yellowpages I/DetailsAdapter: vvv: 0
07-21 12:57:26.123 1962-1967/com.incentive.yellowpages I/zygote64: Do partial code cache collection, code=251KB, data=168KB
07-21 12:57:26.124 1962-1967/com.incentive.yellowpages I/zygote64: After code cache collection, code=249KB, data=168KB
07-21 12:57:26.124 1962-1967/com.incentive.yellowpages I/zygote64: Increasing code cache capacity to 1024KB
07-21 12:57:26.173 1962-1962/com.incentive.yellowpages I/DetailsAdapter: vvv: 1
07-21 12:57:26.177 1962-1962/com.incentive.yellowpages I/DetailsAdapter: vvv: 2
07-21 12:57:26.186 1962-1962/com.incentive.yellowpages I/DetailsAdapter: vvv: 3
07-21 12:57:26.226 1962-1962/com.incentive.yellowpages I/DetailsAdapter: vvv: 4
07-21 12:57:26.232 1962-1962/com.incentive.yellowpages I/DetailsAdapter: vvv: 5
07-21 12:57:26.238 1962-1962/com.incentive.yellowpages I/DetailsAdapter: vvv: 6
07-21 12:57:26.244 1962-1962/com.incentive.yellowpages I/DetailsAdapter: vvv: 7
07-21 12:57:26.265 1962-1967/com.incentive.yellowpages I/zygote64: Compiler allocated 8MB to compile void android.widget.TextView.<init>(android.content.Context, android.util.AttributeSet, int, int)
07-21 12:57:26.437 1962-1962/com.incentive.yellowpages D/ViewRootImpl[DetailActivity]: changeCanvasOpacity: opaque=false
07-21 12:57:26.579 1962-1967/com.incentive.yellowpages I/zygote64: Compiler allocated 6MB to compile void android.view.ViewRootImpl.performTraversals()
07-21 12:57:27.754 1962-1962/com.incentive.yellowpages I/DetailsAdapter: vvv: 0
07-21 12:57:27.761 1962-1962/com.incentive.yellowpages I/DetailsAdapter: vvv: 1
07-21 12:57:27.765 1962-1962/com.incentive.yellowpages I/DetailsAdapter: vvv: 2
07-21 12:57:27.772 1962-1962/com.incentive.yellowpages I/DetailsAdapter: vvv: 3
07-21 12:57:27.784 1962-1962/com.incentive.yellowpages I/DetailsAdapter: vvv: 4
07-21 12:57:27.788 1962-1962/com.incentive.yellowpages I/DetailsAdapter: vvv: 5
07-21 12:57:27.792 1962-1962/com.incentive.yellowpages I/DetailsAdapter: vvv: 6
07-21 12:57:27.796 1962-1962/com.incentive.yellowpages I/DetailsAdapter: vvv: 7
07-21 12:57:29.889 1962-1962/com.incentive.yellowpages D/ViewRootImpl[DetailActivity]: changeCanvasOpacity: opaque=false
07-21 12:57:30.117 1962-1962/com.incentive.yellowpages D/ViewRootImpl[DetailActivity]: changeCanvasOpacity: opaque=false
07-21 12:57:30.756 1962-1962/com.incentive.yellowpages W/AutofillManager: Session 409360048 could not be restored
07-21 12:57:30.922 1962-1967/com.incentive.yellowpages I/zygote64: Do full code cache collection, code=498KB, data=362KB
07-21 12:57:30.923 1962-1967/com.incentive.yellowpages I/zygote64: After code cache collection, code=445KB, data=262KB
Jewbaiting answered 4/7, 2017 at 14:31 Comment(11)
Maybe here: github.com/saulmm/Android-Material-ExamplesFlyaway
Can you post a video with the behavior?Exhale
@Exhale Ive added a link to a video, the BLINK occurs at 0.06 (or just after)Jewbaiting
@Exhale answer does indeed stop the BLINK behaviour however The approach is not acceptable for my particular situation. By keeping the landscape view in portrait while the transition completes leaves the top and bottom of the screen BLANK which is almost as bad as the original symptom of BLINKING the entire screen. It would be nice to understand why the BLINK occurs. I cannot accept the BLINK happens just because the screen has been rebuilt due to orientation change.Jewbaiting
By keeping the landscape view in portrait... - can you clarify what this means? ...leaves the top and bottom of the screen BLANK - maybe some video?Exhale
@Exhale firstly I have to admit I was unable to get your github project built and deployed onto my O device so I am only going from your attached GIF. Your project appears to be both Java and Kotlin, Kotlin is not an option I can use. In your GIF it appears that when screen orientation occurs and the transition "completes" your device is in Portrait with the screen display still showing the landscape view. Maybe this is my mistake as your GIF does not show Click events on the screen so it is impossible to tell when back is pressed.Jewbaiting
@Hector, project is not maintained. Just checked out and saw that no longer builds. Upgraded some plugin, pushed changes. Now builds and runs on Android O.Exhale
@Exhale I just built and deployed your Yellow Pages app onto my O device (PIXEL XL) and it has the BLINK feature as shown here youtu.be/tGA_DGx6lbUJewbaiting
@Hector, wow, that's really interesting. Unfortunately I do not have a device with O and emulator is very unresponsive, stucks and reloads for no reason. Is there something in the logcat?Exhale
@Exhale Ive added all the logcat from the videoJewbaiting
I don't like these lines: "zygote64: Compiler allocated 8MB to compile...". It seems like android O is too strict.Exhale
E
5

Here's the problem: you are starting Activity2 in portrait mode and coming back to Activity1 in a landscape mode. But because you have performed orientation change, the view hierarchy of Activity1 is destroyed and created, thus the there is no more the View that originally the transition was started from.

What you can do, is to re-map the view from the old one to the new using Activity#setExitSharedElementCallback() API. There's a bit of work to do to handle that situation though, which I've already described step-by-step in my this answer.

The best choice for you would be to checkout Alex Lockwood's app at github with the functionality you need, it'll be much more easier for you to understand how to handle the situation.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    setExitSharedElementCallback(new SharedElementCallback() {
        @Override
        public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {

            if (we are coming back to Activity1) {
                View newSharedElement = findViewById(R.id.your_imageview);
                if (newSharedElement != null) {
                    names.clear();
                    names.add("transition name");
                    sharedElements.clear();
                    sharedElements.put("transition name", newSharedElement);
                }
            } else {
                // we are leaving Activity1
            }
        }
    });
}

Basically, you are clearing the map and adding the new "transition name-view" pair to it. You can see how if (we are coming back to Activity1) check is being accomplished here.


Here's the feature, implemented in one of my apps.

enter image description here

Exhale answered 14/7, 2017 at 13:46 Comment(3)
youtu.be/CigNib7UI3g this video shows that the application by Alex has exactly the same issue on orientation changeJewbaiting
I appreciate the work you applied to your example application. For sure there is no BLINK however The approach you have taken is not acceptable for my particular application. Your method of keeping the landscape UI when returning to portrait orientation displays a lot of blank screen realestate.Jewbaiting
As @Jewbaiting said, AlexLockwood's sample app has the blink problem. I can see it on a Nexus 5X, but not on a Samsung Galaxy Note 5. I suggest you to test your app on a Nexus. It's likely not a Nexus 5X bug, because the Google Photos app isn't affected on the 5X, so there's a way to make it work, hidden somewhere...Badlands
E
2

I think the problem is with the ImageView layoutbounds as scene transition calculates the difference between starting and end position and then animate the difference, but here the end position was changed due to orientation change, can you try and recreate the end layout as soon as you backpress in case of orientation change may be I'm wrong but can think of this scenario only, can you provide code for the same?(this was too big to add as a comment so have to add as an answer.)

Enlace answered 14/7, 2017 at 5:3 Comment(0)
B
1

This seems to be occurring only on Oreo. It can be reproduced on an API 26 emulator using Google's sample project available here: https://github.com/googlesamples/android-ActivitySceneTransitionBasic/#readme

I managed to fix the problem in my app by adding this:

<item name="android:windowIsTranslucent">true</item>

To the style of my detail activity.

Badlands answered 20/12, 2017 at 16:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.