Skip to content

[webview_flutter] Implement clearLocalStorage/onHttpError and add integration tests based on upstream v4.13.1 - #1069

Open
seungsoo47 wants to merge 6 commits into
flutter-tizen:masterfrom
seungsoo47:webview_flutter-update-integration-tests
Open

[webview_flutter] Implement clearLocalStorage/onHttpError and add integration tests based on upstream v4.13.1#1069
seungsoo47 wants to merge 6 commits into
flutter-tizen:masterfrom
seungsoo47:webview_flutter-update-integration-tests

Conversation

@seungsoo47

Copy link
Copy Markdown
Contributor
  • Implement native Tizen support for clearLocalStorage and onHttpError, and bump webview_flutter_tizen to 0.10.1.
  • Port the remaining runnable upstream v4.13.1 integration tests (onHttpError x2, clearLocalStorage) and align async style (await instead of unawaited()) with upstream.
  • Stabilize the scroll position test by polling for the settled value instead of reading it once.
  • Fix a WebView disposal race where engine-owned TBM surfaces could be freed while a raster-thread frame still read them, and work around a chromium-efl crash on the TV 10.0 emulator during teardown.
  • flutter-tizen test (or example integration tests) on TV 10.0 emulator — 19/19 passing, including previously-crashing disposal cases

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements clearLocalStorage and onHttpError for the Tizen WebView, and addresses races, use-after-frees, and crashes during WebView disposal. Additionally, integration tests are updated to await controller calls instead of using unawaited. The reviewer feedback suggests awaiting the controller calls in the newly added onHttpError tests to maintain consistency with these changes.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@JSUYA JSUYA left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do the parts related to dispose and evas_object_del ensure that it works without issues even when displaying multiple views?

Comment on lines +121 to +128
// Set under mutex_ at the start of Dispose(). The raster thread checks it
// in ObtainGpuSurface() and stops being handed engine-owned TBM surfaces
// that are about to be freed by the deferred evas_object_del().
bool is_disposing_ = false;
// Set to false at the start of Dispose(). A pending "navigationRequest"
// reply from Dart (resolved asynchronously) captures a copy and checks it
// before dereferencing this WebView, avoiding a use-after-free.
std::shared_ptr<bool> is_alive_ = std::make_shared<bool>(true);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please delete all unnecessary comments.
If you wish to explain how disposing and is_alive work, please leave an explanation in the PR.
Please only leave comments for parts that must be referenced for functionality (TODO, NOTE) or descriptions that need to be published.

};
auto* context = new TeardownContext{instance, std::move(pool)};
texture_registrar_->UnregisterTexture(GetTextureId(), [context]() {
ecore_main_loop_thread_safe_call_async(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ecore API is no longer in use.

@JSUYA

JSUYA commented Jul 24, 2026

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4ee5d4624f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/webview_flutter/tizen/src/webview.cc Outdated
seungsoo47 and others added 6 commits August 4, 2026 14:53
Add Tizen native implementations for two previously unimplemented APIs:
- clearLocalStorage: clears web local storage via
  ewk_context_web_storage_delete_all.
- onHttpError: reports HTTP error status codes (>= 400) to the navigation
  delegate via the policy,response,decide callback.

Bump version to 0.10.1.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Port the remaining runnable upstream test cases from webview_flutter v4.13.1:
- NavigationDelegate > onHttpError
- NavigationDelegate > onHttpError is not called when no HTTP error is received
- clearLocalStorage

These pass thanks to the new clearLocalStorage and onHttpError
implementations. The other upstream test cases remain omitted because they
cannot run on Tizen: window.open/new-window behavior, HTTP basic auth, and
media playback policy are not supported by the engine.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The test file wrapped most controller setup calls (setJavaScriptMode,
setNavigationDelegate, loadRequest, etc.) in unawaited(), a leftover from an
older upstream version. Match the upstream v4.13.1 style by awaiting those
calls instead, keeping unawaited() only where upstream does (the request
server loop and the two onHttpError tests). No behavior change; the full
suite still passes on the device.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
getScrollPosition() settles asynchronously after scrollTo/scrollBy, so reading
it once right after the call was flaky (more so on software-GL rendering such as
emulators). Poll the scroll position until it reaches the expected value, with a
timeout, so the test waits for the value to settle instead of failing on a
transient stale read.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…rash

Rework WebView::Dispose() to tear resources down safely:

- Detach all engine callbacks (including the missing
  "policy,response,decide") and defer evas_object_del() until the
  embedder's UnregisterTexture completion callback, so the engine-owned
  TBM surfaces are not freed while a raster-thread frame is still reading
  them (flutter-tizen/embedder#182).
- Add is_alive_/is_disposing_ guards so async callbacks arriving after
  disposal no longer touch the destroyed WebView.
- On the Tizen 10.0 TV emulator (TV_PROFILE + x86_64), hide the stopped
  view instead of deleting it to avoid a SIGSEGV in chromium-efl's
  ~SelectionControllerEfl(); revert once the engine fix ships.

Verified on the TV 10.0 emulator: example integration tests previously
crashed on WebView disposal and now pass 19/19.
…r-pool UAF

- Fix a use-after-free in BufferPool: the engine's release_callback for an
  in-flight frame can fire on the raster thread after the owning BufferUnit
  has already been destroyed on the platform thread, dereferencing freed
  memory. Track live BufferUnits in a mutex-guarded registry and have the
  callback check it before touching the buffer. tbm_pool_ is now a shared_ptr
  so its lifetime extends through the deferred teardown below.
- Replace ecore_main_loop_thread_safe_call_async() with GLib, following the
  Ecore removal in flutter-tizen#1033 / flutter-tizen#1045 / flutter-tizen#1046. Must be g_timeout_add_full() at
  G_PRIORITY_HIGH, not g_idle_add(): an idle source runs too late and lets
  the delete race the raster thread.
- Narrow the TV_PROFILE compile-time macro to a runtime getenv("ELM_PROFILE")
  check for the same evas_object_hide()-instead-of-del() workaround. Still
  needed: even with the buffer-pool fix above, evas_object_del() can
  intermittently crash the raster thread on the Tizen 10.0 TV emulator, and
  this replaces the compile-time check the review flagged.
- Trim the disposal comments down to the constraints; the ordering rationale
  moves to the PR description.

Verified via flutter-tizen drive:
- TV 10.0 x86_64 emulator: 8/8 consecutive runs green (0 crashes).
- Real TV device (armv7l): one full clean run (19/19); further repeats hit
  app-launch failures unrelated to this change. I will create a new issue for
  this situation.
@seungsoo47
seungsoo47 force-pushed the webview_flutter-update-integration-tests branch from 1c44536 to bd27a24 Compare August 4, 2026 05:53
@seungsoo47

seungsoo47 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Do the parts related to dispose and evas_object_del ensure that it works without issues even when displaying multiple views?

While the WebView can functionally support multiple views, this isn't currently supported in practice due to memory-leak and crash issues. I will create issues regarding these problems.
#1076
#1077

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants