@simba-dev/react-native-media-player 3.3.2 → 3.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,4 +1,114 @@
1
1
 
2
+ ## [3.3.4] - 2026-11-06
3
+
4
+ ### Fixed
5
+
6
+ - **The HOME path opened NO Picture-in-Picture window at all.** This is a regression the 3.3.3
7
+ release shipped, and it is the reason this release exists. Measured on emulator-5554 (API 37) on
8
+ 2026-11-05, and again on 2026-11-06, on the 3.3.3 build:
9
+
10
+ ```
11
+ 15:21:28.392 onPictureInPictureRequested: the platform asked the app to enter PiP
12
+ 15:21:28.423 hideConsumerChrome: hid the chrome view ... visibility=8
13
+ 15:21:28.826 the PiP entry is scheduled for the next draw
14
+ 15:21:29.139 onUserLeaveHint: the user is leaving the app
15
+ 15:21:30.186 askForTheWindow: the OS refused the PiP entry
16
+ ```
17
+
18
+ `dumpsys activity activities` reported `mLastReportedPictureInPictureMode=false` — the entry
19
+ never happened. The cause is measured: 3.3.3 deferred the OS ask to the window's next draw, the
20
+ ask landed **1.8 s** after the platform's request, and by then the Activity had been paused.
21
+ `Activity.enterPictureInPictureMode` throws unless the Activity is RESUMED, so the OS refused
22
+ the entry.
23
+
24
+ **The fix:** the ask is synchronous again — inside `onPictureInPictureRequested()`, in that
25
+ tick, on every API level. The chrome is still hidden before the ask, and the params are still
26
+ committed before it.
27
+
28
+ ### Retracted
29
+
30
+ - **"The hide has to be DRAWN before the platform takes the window."** (3.3.3) That claim was
31
+ **never proven**. It rested on a single measurement — the window's draw counter did not move
32
+ between the hide and the entry — which is consistent with a stale frame AND with a draw that had
33
+ not been scheduled yet. A single screenshot cannot separate the two, and the release stated the
34
+ inference as a measured cause.
35
+
36
+ The mechanism built on that claim — a draw-gated entry on the API 31+ path, waiting for a
37
+ `ViewTreeObserver.OnDrawListener` — is removed here, in the same release that withdraws the
38
+ claim. The 3.3.3 CHANGELOG entry below still quotes the old wording on purpose: a retraction
39
+ that deletes the wrong text is not a retraction.
40
+
41
+ - **"A PiP window that still carries the chrome is better than no PiP window at all."** (3.3.3)
42
+ That was the decision behind the bounded wait, and it was wrong in practice: the wait did not
43
+ produce a PiP window with the chrome, it produced **no PiP window at all**. The entry is worth
44
+ more than the cosmetics.
45
+
46
+ - **"It returns whether the entry was started — on API 31+ that means it was scheduled for the
47
+ next draw."** (README) The entry is no longer scheduled for anything. The return value is the
48
+ OS's answer again: `true` when the Activity entered Picture-in-Picture, `false` when it was
49
+ refused.
50
+
51
+ ### Not claimed
52
+
53
+ - Whether the PiP window shows the app's chrome is **not** settled by this release. The hide is
54
+ applied natively before the entry, and on a playing video the PiP window comes up video-only; on
55
+ a paused video it has been seen carrying the app's full expanded chrome. The mechanism behind
56
+ that difference is still open, and it is measured per release rather than assumed.
57
+
58
+ ## [3.3.3] - 2026-11-05
59
+
60
+ ### Fixed
61
+
62
+ - **The HOME path's PiP window could carry the app's full expanded chrome, scaled down.** The
63
+ 3.3.1 release shipped the entry ORDER — hide the chrome, then ask the OS for the window — and
64
+ that order is right, but it was not enough, and the release said it was. Measured on
65
+ emulator-5554 (API 37) on 2026-11-05, with an instrumented build that logged the chrome view's
66
+ identity, its visibility and the window's draw count at every stage:
67
+
68
+ - the native hide lands on the **right view**: the chrome root went `GONE` and **stayed** gone —
69
+ the same view identity before the hide and after `onPictureInPictureModeChanged(true)`;
70
+ - and yet the PiP window showed the app's **full** expanded chrome — the header band, the ±10
71
+ buttons, the big pause button, the scrub row — over the live video.
72
+
73
+ The cause is measured, not guessed. `View.setVisibility(GONE)` only **schedules** a traversal:
74
+ in that run the window's draw counter did **not move at all** between the hide and the entry, so
75
+ the hide never reached the pixels. The PiP window's UI layer is the app's **last drawn frame** —
76
+ the video keeps playing inside it because the video is a `SurfaceView`, a separate layer the
77
+ platform re-parents into the PiP window, while the app's UI layer is a snapshot. A frame that
78
+ was never drawn cannot be in it.
79
+
80
+ The defect is reproducible without the fix: **pause the video**, so the app has nothing to
81
+ animate and stops drawing, and then press HOME. With the video playing, the same press gives a
82
+ clean, video-only PiP window.
83
+
84
+ **The fix:** the entry now hides the chrome, **forces** the window to schedule a draw that
85
+ carries the hidden chrome (`invalidate()` + `requestLayout()`), and asks the OS for the window
86
+ **from that draw** — a one-shot `ViewTreeObserver.OnDrawListener`. If the window never draws,
87
+ the entry goes on anyway after a bounded wait (250 ms), because a PiP window that still carries
88
+ the chrome is better than no PiP window at all.
89
+
90
+ On API 24-30 the entry is unchanged and immediate: there it runs from `onUserLeaveHint()`, which
91
+ AOSP calls "right before the activity's onPause callback", so there is no frame to wait for and
92
+ `enterPictureInPictureMode()` needs a RESUMED Activity.
93
+
94
+ ### Retracted
95
+
96
+ - **"The chrome is kept out by HIDING it before the entry."** That was the 3.3.1/3.3.2 mechanism,
97
+ and it was **not** enough: the hide has to be **drawn** before the platform takes the window.
98
+ Five shipped places asserted the old mechanism — `MpvBridgeModule.kt` (two docblocks),
99
+ `PipManager.kt`, `src/types/config.ts` and the README — and all of them now say what the
100
+ measurement says. The 3.3.1 CHANGELOG entry below still quotes the old wording on purpose: a
101
+ retraction that deletes the wrong text is not a retraction.
102
+
103
+ - **"Your app is still drawing, so the chrome-less window is presented before the platform
104
+ transitions it."** (README) — the app is still **RESUMED** for a few hundred milliseconds after
105
+ `onPictureInPictureRequested()`, but *drawing* is a different thing, and a paused video leaves
106
+ the app with nothing to draw. The README now says what is true.
107
+
108
+ - **"It returns whether the OS accepted the entry."** (README) — on API 31+ the entry is
109
+ **scheduled** for the next draw, so the return value says the entry was *started*. The OS's
110
+ answer is logged, not returned.
111
+
2
112
  ## [3.3.2] - 2026-11-04
3
113
 
4
114
  ### Retracted
package/README.md CHANGED
@@ -386,8 +386,9 @@ callback regardless of if it acts on it or not", and `false` sends the framework
386
386
  path. The same library call serves both, so there is one entry and one owner. Why the API 31+
387
387
  hook matters is in [Why it is native](#why-it-is-native-and-why-your-activity-hands-over-the-activity).
388
388
 
389
- The library then asks the OS for the window, hides your chrome, and brings your chrome back when
390
- Picture-in-Picture ends. It returns whether the OS accepted the entry, so you can log it:
389
+ The library then hides your chrome, asks the OS for the window, and brings your chrome back when
390
+ Picture-in-Picture ends. It returns whether the OS **accepted** the entry, and `false` when the
391
+ entry was refused, so you can log it:
391
392
 
392
393
  ```kotlin
393
394
  val entered = com.simba.player.mpv.MpvBridgeModule.notifyUserLeaveHint(this)
@@ -417,8 +418,11 @@ your Activity is still **RESUMED**. That matters twice over:
417
418
 
418
419
  - `Activity.enterPictureInPictureMode()` throws `IllegalStateException` unless the Activity is
419
420
  resumed, so this is the only moment an explicit entry is legal at all.
420
- - your app is still drawing, so the chrome-less window is presented before the platform
421
- transitions it.
421
+ - the Activity is still **RESUMED** for a few hundred milliseconds after this hook, but the
422
+ library does NOT spend that window waiting: the OS ask happens **inside** this callback, in
423
+ this tick. Measured on emulator-5554 (API 37) on 2026-11-05 and again on 2026-11-06, an ask
424
+ deferred past the callback landed 1.8 s later, by which time the Activity had been paused, and
425
+ the OS **refused** the entry — so no PiP window opened at all.
422
426
 
423
427
  That is why the library does **not** arm the platform's auto-enter switch: with it armed there
424
428
  is no pre-transition hook to use.
@@ -428,7 +432,7 @@ is no pre-transition hook to use.
428
432
  The PiP window **is** your Activity's own window, so whatever your chrome draws is what the PiP
429
433
  window shows. The library hides your chrome root **before** it asks the OS for the window.
430
434
 
431
- Two things have to be right for that to work:
435
+ Three things have to be right for that to work:
432
436
 
433
437
  1. **The hide happens in the entry, not after it.** Hiding from
434
438
  `onPictureInPictureModeChanged(true)` — after the platform has already transitioned the
@@ -437,6 +441,20 @@ Two things have to be right for that to work:
437
441
  2. **The entry happens while your Activity is resumed.** On API 31+ that means
438
442
  `onPictureInPictureRequested()`; see
439
443
  [Why it is native](#why-it-is-native-and-why-your-activity-hands-over-the-activity).
444
+ 3. **Whether that hide is enough is MEASURED, not assumed.** The library hides your chrome root
445
+ and then asks the OS for the window in the same tick. On a playing video the PiP window comes
446
+ up video-only. On a **paused** video the PiP window has been seen carrying the app's full
447
+ expanded chrome.
448
+
449
+ The 3.3.3 release claimed to know why: that `View.setVisibility(GONE)` only *schedules* a
450
+ traversal, so the hide never reached the pixels, and the PiP window therefore showed the app's
451
+ **last drawn frame**. It built a draw-gated entry on that claim — and **the claim was never
452
+ proven**, and the mechanism broke the entry outright (see the retraction below). The honest
453
+ statement today is the narrower one: the hide is applied natively, before the entry, and
454
+ whether the window that results is clean depends on the app still drawing.
455
+
456
+ If your app's PiP window shows your chrome, the first thing to check is whether the app is
457
+ still drawing at the moment of the entry.
440
458
 
441
459
  `PictureInPictureParams.setSourceRectHint(...)` is **not** part of this. It is a TRANSITION
442
460
  hint: it tells the platform which region of your window the PiP window should animate FROM. It
@@ -216,7 +216,8 @@ object PipManager {
216
216
  // This is the rect the PiP window ANIMATES FROM — a transition
217
217
  // hint, nothing more. It does not crop the app's window, so it is
218
218
  // NOT what keeps the app's chrome out of the PiP window; the
219
- // consumer's chrome is hidden before the entry, in native code.
219
+ // consumer's chrome is hidden before the entry, in native code,
220
+ // and that hide is DRAWN before the platform takes the window.
220
221
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && sourceRectHint != null) {
221
222
  builder.setSourceRectHint(sourceRectHint)
222
223
  }
@@ -265,6 +265,13 @@ class MpvBridgeModule(reactContext: ReactApplicationContext) :
265
265
  *
266
266
  * The chrome is kept out by HIDING it before the entry.
267
267
  *
268
+ * Whether that hide is SUFFICIENT — whether the PiP window still
269
+ * shows the chrome — is MEASURED per release, not assumed. The
270
+ * v3.3.3 release asserted that the hide had to be DRAWN before
271
+ * the platform took the window; that assertion was never proven,
272
+ * and the mechanism built on it broke the entry. See
273
+ * `notifyUserLeaveHint(activity)`.
274
+ *
268
275
  * ## Why the restore still happens here
269
276
  *
270
277
  * The chrome comes back when PiP ends, and it comes back EVEN IF
@@ -478,7 +485,57 @@ class MpvBridgeModule(reactContext: ReactApplicationContext) :
478
485
  * @param activity the Activity that is leaving. It is the window
479
486
  * the PiP entry applies to.
480
487
  * @return `true` when the Activity entered Picture-in-Picture,
481
- * `false` when it did not.
488
+ * `false` when the entry was refused.
489
+ */
490
+ /**
491
+ * ## Why the window is asked for INSIDE the callback
492
+ *
493
+ * The ask is SYNCHRONOUS: it happens in this callback, in this
494
+ * tick, on every API level.
495
+ *
496
+ * Measured on emulator-5554 (API 37) on 2026-11-05, and again on
497
+ * 2026-11-06, on the v3.3.3 build — which DEFERRED the ask to the
498
+ * window's next draw:
499
+ *
500
+ * ```
501
+ * 15:21:28.392 onPictureInPictureRequested: the platform asked the app to enter PiP
502
+ * 15:21:28.423 hideConsumerChrome: hid the chrome view ... visibility=8
503
+ * 15:21:28.826 the PiP entry is scheduled for the next draw
504
+ * 15:21:29.139 onUserLeaveHint: the user is leaving the app
505
+ * 15:21:30.186 askForTheWindow: the OS refused the PiP entry
506
+ * ```
507
+ *
508
+ * The deferred ask landed 1.8 s after the platform's request —
509
+ * long after the Activity had been paused.
510
+ * `Activity.enterPictureInPictureMode` throws unless the Activity
511
+ * is RESUMED, so the OS refused the entry and **NO PiP window
512
+ * opened at all**. Both runs were identical, and
513
+ * `dumpsys activity activities` reported
514
+ * `mLastReportedPictureInPictureMode=false`.
515
+ *
516
+ * A PiP window that still carries the chrome is a defect. NO PiP
517
+ * window at all is worse, so the entry wins over the cosmetics.
518
+ *
519
+ * ## What v3.3.3 claimed, and why it is withdrawn
520
+ *
521
+ * v3.3.3 asserted that the chrome's hide had to be DRAWN before
522
+ * the platform took the window, and it gated the entry on a
523
+ * `ViewTreeObserver.OnDrawListener`. That claim was **never
524
+ * proven**. The one measurement it rested on — the window's draw
525
+ * counter did not move between the hide and the entry — is
526
+ * consistent with a stale frame AND with a draw that had not been
527
+ * scheduled yet, and a single screenshot cannot separate the two.
528
+ *
529
+ * The mechanism built on that claim broke the entry outright (see
530
+ * above). It is withdrawn here, in the same release that removes
531
+ * the code.
532
+ *
533
+ * ## What is still open
534
+ *
535
+ * Whether the PiP window shows the chrome is MEASURED, not
536
+ * assumed. The hide-before-ask is kept because it is the only
537
+ * ordering that can help and because it is harmless; whether it
538
+ * is SUFFICIENT is not settled by this file.
482
539
  */
483
540
  fun notifyUserLeaveHint(activity: Activity): Boolean {
484
541
  Log.i(
@@ -540,13 +597,27 @@ class MpvBridgeModule(reactContext: ReactApplicationContext) :
540
597
  // region the PiP window ANIMATES FROM — a transition hint,
541
598
  // not a crop.
542
599
  commitPipParams(activity)
543
- // 6. Ask for the window.
600
+ // 6. Ask for the window — SYNCHRONOUSLY, in this callback, on
601
+ // every API level.
602
+ //
603
+ // This is an EXPLICIT entry. On API 31+ it is legal here
604
+ // because the platform's auto-enter switch is not armed:
605
+ // ATMS refuses a client entry only while auto-enter is
606
+ // enabled ("auto-enter should take in place instead").
607
+ //
608
+ // The ask MUST NOT be deferred. Measured on emulator-5554
609
+ // (API 37) on 2026-11-05 and again on 2026-11-06: a
610
+ // deferred ask (waiting for the window's next draw) landed
611
+ // 1.8 s after the platform's request, the Activity had been
612
+ // paused by then, and the OS REFUSED the entry — so NO PiP
613
+ // window opened at all. `enterPictureInPictureMode` needs a
614
+ // RESUMED Activity, and this callback is the last moment
615
+ // the Activity is guaranteed to be one.
544
616
  //
545
- // This is an EXPLICIT entry on every API level. On API 31+
546
- // it is legal here because the platform's auto-enter
547
- // switch is not armed: ATMS refuses a client entry only
548
- // while auto-enter is enabled ("auto-enter should take in
549
- // place instead").
617
+ // On API 24-30 the entry runs from `onUserLeaveHint()`,
618
+ // which AOSP calls "right before the activity's onPause
619
+ // callback": there is no frame between it and the pause.
620
+ // The entry there is immediate too.
550
621
  val entered = enterPictureInPicture(activity)
551
622
  if (!entered) {
552
623
  Log.w(TAG, "companion.notifyUserLeaveHint: the OS refused the PiP entry")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simba-dev/react-native-media-player",
3
- "version": "3.3.2",
3
+ "version": "3.3.4",
4
4
  "description": "React Native video & audio player powered by libmpv — Picture-in-Picture, MediaSession, foreground service, and a customizable TypeScript UI. Built for Android. Designed as a drop-in replacement for react-native-video / react-native-track-player / expo-av. See CHANGELOG.md for per-version notes.",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -76,7 +76,8 @@ export interface PipConfig {
76
76
  * platform builds the PiP window from the LAST COMMITTED params. The
77
77
  * source rect hint among them is a TRANSITION hint — the region the PiP
78
78
  * window ANIMATES FROM — not a crop. The app's chrome is kept out of the
79
- * PiP window by hiding it before the entry, in native code.
79
+ * PiP window by hiding it before the entry, in native code, and by having
80
+ * that hide DRAWN before the platform takes the window.
80
81
  */
81
82
  autoEnterOnLeave: boolean;
82
83
  /**