wordpress-mobile / wordpress-mobile/WordPress-iOS

Some YouTube embeds don't load in Reader

Open
#20,027 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

[Pri] Low [Type] Bug Reader
Dominant language
Swift
Stars
3.9k
Forks
1.2k
Avg merge
23h 51m
Merged PRs (30d)
58

Description

Expected behavior

All embedded YouTube videos that play on the web also play in Reader in the app.

Actual behavior

Only some embedded YouTube videos that play on the web also play in Reader in the app.

Actual Expected
Simulator Screen Shot - iPhone 14 - 2023-01-27 at 14 32 47 Simulator Screen Shot - iPhone 14 - 2023-01-27 at 14 31 20
Steps to reproduce the behavior
  1. In a WordPress blog on the web, paste these two video URLs into a new post:
  2. Expect: Loading the post on the web shows the videos embedded and playable
  3. In Reader in the app, follow the blog from step 1 and load the post
  4. Observe:
    • Video A: Shows a message "Video unavailable".
    • Video B: Correctly shows a playable video.
  5. Expect: Tapping the globe icon at the top of the UI opens a web view that properly plays both videos.

Research

diff --git a/WordPress/Classes/ViewRelated/Reader/Detail/WebView/ReaderWebView.swift b/WordPress/Classes/ViewRelated/Reader/Detail/WebView/ReaderWebView.swift
index e395fb95af..91a101570e 100644
--- a/WordPress/Classes/ViewRelated/Reader/Detail/WebView/ReaderWebView.swift
+++ b/WordPress/Classes/ViewRelated/Reader/Detail/WebView/ReaderWebView.swift
@@ -28,7 +28,7 @@ class ReaderWebView: WKWebView {
 
         let content = formattedContent(addPlaceholder(string), additionalJavaScript: additionalJavaScript)
 
-        super.loadHTMLString(content, baseURL: Bundle.wordPressSharedBundle.bundleURL)
+        super.loadHTMLString(content, baseURL: postURL ?? URL(string: "https://www.wordpress.com")!)
     }
 
     /// Given a HTML content, returns it formatted.

Note: Patch was applied to aa1d441040bd970878e2d427806cbd318fbbc76d
Note 2: Patch is only for demo purposes, the nil string fallback URL (www.wordpress.com) is probably not the best choice.

Tested on iPhone 12, iOS 16.2, WPiOS 21.6

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in WordPress/Classes/ViewRelated/Reader/Detail/WebView/ReaderWebView.swift at loadHTMLString and inspect how postURL and the bundle URL are used as the base URL. Reproduce the issue with Video A and Video B in Reader, then verify both play in the embedded view while the globe web view remains functional.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, swift
Domain
mobile
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.