Closed Bug 1500644 Opened 6 years ago Closed 4 years ago

Make geckoview_example's toolbar behave like Focus's dynamic toolbar

Categories

(GeckoView :: General, enhancement, P3)

Unspecified
Android
enhancement

Tracking

(firefox63 wontfix, firefox64 wontfix, firefox84 fixed)

RESOLVED FIXED
84 Branch
Tracking Status
firefox63 --- wontfix
firefox64 --- wontfix
firefox84 --- fixed

People

(Reporter: cpeterson, Assigned: hiro)

References

Details

Attachments

(1 file)

This was a feature request from the October 2018 performance work week. I don't exactly what about geckoview_example's toolbar needs to change.
Chris will get more details.
Flags: needinfo?(cpeterson)
Markus, did you ask for this toolbar fix at the Toronto performance work week? What was the specific change? For geckoview_example to resize the viewport to account for the toolbar size?
Flags: needinfo?(cpeterson) → needinfo?(mstange)
Priority: -- → P3
Yes, that was me. Focus moves the GeckoView during scrolling when it hides and unhides its toolbar. Initially I thought it was also resizing the view, but it seems that's not the case; things at the bottom just get cut off while the toolbar is showing. Moving and resizing a view can have an impact on performance. Since our performance investigations and profiling are going to happen in the GeckoView example, I'd like GeckoView example to work as similarly to Focus as possible in all ways that can affect performance.
Flags: needinfo?(mstange)
Summary: Make geckoview_example's toolbar behave like Fennec's dynamic toolbar → Make geckoview_example's toolbar behave like Focus's dynamic toolbar
Product: Firefox for Android → GeckoView
Component: General → GeckoViewExample

It would be really great that GekckoView example has the dynamic toolbar feature. (and GeckoViewTestActivity). The dynamic toolbar in android-component is implemented with using CoordinatorLayout which seems to have introduced in API 24.1, but GeckoView example and GeckoViewTestActivity are for testing purpose so that we can use CoordinatorLayout?

This way is basically how android-components provides the dynamic toolbar
feature but there are a couple of caveats on this change as of now.

  1. The toolbar doesn't snap back/forward at all when the user leaves their
    finger in the middle of the toolbar's transition
  2. There is no option to switch the toolbar position at top
  3. This change forces the toolbar to be dynamic, there is no way to make
    it static

Each corresponding file in android-components is;
NestedGeckoView.java <- NestedGeckoView.kt [1]
ToolbarBottomBehavior.java <- BrowserToolbarBottomBehavior.kt [2]
GeckoViewBottomBehavior <- EngineViewBottomBehavior.kt [3]

[1] https://github.com/mozilla-mobile/android-components/blob/b6a5c6444140920768e1332e2618538efe29151e/components/browser/engine-gecko-nightly/src/main/java/mozilla/components/browser/engine/gecko/NestedGeckoView.kt
[2] https://github.com/mozilla-mobile/android-components/blob/b6a5c6444140920768e1332e2618538efe29151e/components/browser/toolbar/src/main/java/mozilla/components/browser/toolbar/behavior/BrowserToolbarBottomBehavior.kt
[3] https://github.com/mozilla-mobile/android-components/blob/b6a5c6444140920768e1332e2618538efe29151e/components/feature/session/src/main/java/mozilla/components/feature/session/behavior/EngineViewBottomBehavior.kt

Assignee: nobody → hikezoe.birchill
Status: NEW → ASSIGNED

I just pushed the current state of the change for this bug, but there is one thing I don't quite understand. That is that an equivalent way in Java as coroutine in Kotlin.

In android-components a coroutine is used to handle the result of onTouchEventForResult, without the coroutine equivalent thing, it looks as it works fine, but there may be race conditions it won't work. So I wonder how we can do the same manner in Java. (I also don't quite understand what value should be returned from the onTouchEventForResult's then lambda.

:snorp, or Agi, can you please shed some lights on that?

(CCing Petru)

Flags: needinfo?(snorp)
Flags: needinfo?(agi)

(In reply to Hiroyuki Ikezoe (:hiro) from comment #6)

I just pushed the current state of the change for this bug, but there is one thing I don't quite understand. That is that an equivalent way in Java as coroutine in Kotlin.

In android-components a coroutine is used to handle the result of onTouchEventForResult, without the coroutine equivalent thing, it looks as it works fine, but there may be race conditions it won't work. So I wonder how we can do the same manner in Java. (I also don't quite understand what value should be returned from the onTouchEventForResult's then lambda.

(CCing Petru)

The launch coroutine builder can be seen as starting an operation to be done in background, without waiting for a response. Fire and forget.

It is used here when the user first touches the screen to decouple GV#onTouchEventForResult off of Main, as waiting for a response from that could take upwards of 500ms (seen on google maps on a Pixel 3, possibly more on older devices) to return how that touch was handled (INPUT_RESULT_UNHANDLED / INPUT_RESULT_HANDLED / INPUT_RESULT_HANDLED_CONTENT).
.then I understand registers a listener for when the GeckoResult resolves so I'd think we're good, no other changes needed.
Don't know about the return of ".then".

(In reply to Hiroyuki Ikezoe (:hiro) from comment #6)

In android-components a coroutine is used to handle the result of onTouchEventForResult, without the coroutine equivalent thing, it looks as it works fine, but there may be race conditions it won't work. So I wonder how we can do the same manner in Java. (I also don't quite understand what value should be returned from the onTouchEventForResult's then lambda.

:snorp, or Agi, can you please shed some lights on that?

The return result of then is used if you want to chain GeckoResults, e.g. like this

result.then(result -> {
      // code
      return doExpensiveAction();
}).then(expensiveActionResult -> {

}).then(...);

If you just want to consume the result you can use accept. E.g. in your code:

            super.onTouchEventForResult(event).accept(inputResult -> {
                mInputResult = inputResult;
                startNestedScroll(ViewCompat.SCROLL_AXIS_VERTICAL);
            });

I'm don't really know anything about coroutines but if it's something like async javascript methods then your java code should be pretty much equivalent to the kotlin code that you linked.

The code running in accept will run in the calling thread, so if this is always called from the same thread there shouldn't be any race condition going on (and I think that this is the case here, since onTouchEvent should be called from the UI thread).

Flags: needinfo?(snorp)
Flags: needinfo?(agi)
Attachment #9179489 - Attachment description: Bug 1500644 - Make GeckoView example toolbar dynamic at bottom by using CoordinatorLayout. → Bug 1500644 - Make GeckoView example toolbar dynamic at bottom by using CoordinatorLayout. r?#geckoview-reviewers

Thank you Agi, that's all what I wanted to know. (and thank you Petru)

(In reply to Hiroyuki Ikezoe (:hiro) from comment #5)

This way is basically how android-components provides the dynamic toolbar
feature but there are a couple of caveats on this change as of now.

  1. The toolbar doesn't snap back/forward at all when the user leaves their
    finger in the middle of the toolbar's transition

I did implement the snap feature in the same way what A-C does.

Pushed by hikezoe.birchill@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/4ecb44816920 Make GeckoView example toolbar dynamic at bottom by using CoordinatorLayout. r=geckoview-reviewers,snorp
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 84 Branch
Regressions: 1675035
Regressions: 1674104
See Also: → 1685242
Regressions: 1686376
Regressions: 1734261
Component: GeckoViewExample → General
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: