Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(YouTube - Hide ads): Hide fullscreen ads crashes app on startup #2908

Closed
3 tasks done
yangton opened this issue Mar 25, 2024 · 5 comments · Fixed by #2910 or #2804
Closed
3 tasks done

bug(YouTube - Hide ads): Hide fullscreen ads crashes app on startup #2908

yangton opened this issue Mar 25, 2024 · 5 comments · Fixed by #2910 or #2804
Labels
Bug report Something isn't working

Comments

@yangton
Copy link

yangton commented Mar 25, 2024

Bug description

yt revanced crashed
The INJECT_EVENTS permission is a sensitive permission that allows apps to control user input. This permission is typically granted to system apps and apps that require accessibility services. Modified apps like Revanced do not have this permission by default.

Error logs

SystemUptimeMs: 218588191
Process: app.revanced.android.youtube
PID: 13211
UID: 10355
Frozen: false
Flags: 0x30dbbe44
Package: app.revanced.android.youtube v1544154560 (19.04.37)
Foreground: Yes
Process-Runtime: 2894
Build: google/oriole_beta/oriole:14/AP21.240216.010/11529813:user/release-keys
Crash-Handler: hfy
Loading-Progress: 1.0
Dropped-Count: 0

java.lang.SecurityException: Injecting input events requires the caller (or the source of the instrumentation, if any) to have the INJECT_EVENTS permission.
	at android.os.Parcel.createExceptionOrNull(Parcel.java:3183)
	at android.os.Parcel.createException(Parcel.java:3167)
	at android.os.Parcel.readException(Parcel.java:3150)
	at android.os.Parcel.readException(Parcel.java:3092)
	at android.hardware.input.IInputManager$Stub$Proxy.injectInputEventToTarget(IInputManager.java:1682)
	at android.hardware.input.InputManagerGlobal.injectInputEvent(InputManagerGlobal.java:1415)
	at android.hardware.input.InputManagerGlobal.injectInputEvent(InputManagerGlobal.java:1425)
	at android.app.Instrumentation.sendKeySync(Instrumentation.java:1206)
	at android.app.Instrumentation.sendKeyDownUpSync(Instrumentation.java:1250)
	at app.revanced.integrations.youtube.patches.components.AdsFilter.lambda$closeFullscreenAd$1(AdsFilter.java:173)
	at app.revanced.integrations.youtube.patches.components.AdsFilter.$r8$lambda$OPSRVU8xFM5HCQeVyfFkDTp9xF0(AdsFilter.java:0)
	at app.revanced.integrations.youtube.patches.components.AdsFilter$$ExternalSyntheticLambda0.run(R8$$SyntheticClass:0)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
	at java.lang.Thread.run(Thread.java:1012)
Caused by: android.os.RemoteException: Remote stack trace:
	at com.android.server.input.InputManagerService.injectInputEventToTarget(InputManagerService.java:935)
	at android.hardware.input.IInputManager$Stub.onTransact(IInputManager.java:788)
	at android.os.Binder.execTransactInternal(Binder.java:1500)
	at android.os.Binder.execTransact(Binder.java:1444)

Solution

One potential solution is to grant the INJECT_EVENTS permission to the Revanced app. However, this is not recommended as it can pose a security risk.
A more secure solution would be to modify the Revanced app to avoid the need for the INJECT_EVENTS permission. This could involve redesigning the app's functionality or using different methods to achieve the desired results.

Steps To Reproduce:

  • Install the Revanced app on an Android device.
  • Open the Revanced app and enable ad blocking.
  • Play a video with ads.
  • Tap on the ad to close it.
  • A "SecurityException" will be thrown.

Acknowledgements

  • This issue is not a duplicate of an existing bug report.
  • I have chosen an appropriate title.
  • All requested information has been provided properly.
@yangton yangton added the Bug report Something isn't working label Mar 25, 2024
@yangton yangton changed the title SecurityException Ad Blocker Functionality Broken YouTube SecurityException Ad Blocker Functionality Broken Mar 25, 2024
@LisoUseInAIKyrios
Copy link
Contributor

Adding new permissions to the manifest won't work for root installations.

This check must be device or OS specific because this exception is not thrown on all devices.

The artificial key press event is used to close a fullscreen ad. The use of the back button appears to sometimes close the app entirely instead of closing just the ad (#2896).

@yangton yangton closed this as completed Mar 25, 2024
@LisoUseInAIKyrios
Copy link
Contributor

Leaving this open until the issue is fixed

@yangton
Copy link
Author

yangton commented Mar 25, 2024

Leaving this open until the issue is fixed

Ok Thanks

@LisoUseInAIKyrios LisoUseInAIKyrios linked a pull request Mar 25, 2024 that will close this issue
1 task
@LisoUseInAIKyrios LisoUseInAIKyrios changed the title YouTube SecurityException Ad Blocker Functionality Broken bug(YouTube - Hide ads): Hide fullscreen ads crashes app on startup Mar 25, 2024
@LisoUseInAIKyrios
Copy link
Contributor

LisoUseInAIKyrios commented Mar 25, 2024

To anyone who has this issue, manually turn off Hide fullscreen ads in ReVanced Settings -> Ads

The next release will automatically turn off the feature if it is not available.

@inotia00
Copy link

inotia00 commented May 9, 2024

I too have been aware of this issue and have been trying to find a way to hide fullscreen ads on YouTube without using the Instrumentation.SendKeySync(KeyEvent) method.

Fullscreen ad was a custom AlertDialog, which can be easily hidden.

The related commits are:
inotia00/revanced-patches@b25413c
inotia00/revanced-integrations@9f45271

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug report Something isn't working
Projects
None yet
3 participants