jagrosh / MusicBot

🎶 A Discord music bot that's easy to set up and run yourself!
https://jmusicbot.com
Apache License 2.0
5.36k stars 2.56k forks source link

[Bug Report] Volume control doesn't work on Apple M1 chip #1094

Open HandsomeHarry opened 2 years ago

HandsomeHarry commented 2 years ago

Bug Description

I'm trying to host this bot using a 2020 M1 Macbook Air, but every time I try to change the volume it just stops playing. I tried changing Java versions but it doesn't seem to work, currently using OpenJDK 17 LTS

Steps to Reproduce

  1. Start bot on M1 machine
  2. Change volume with !volume

Expected Result

Bot stops playing and goes to next song

Debug Output

System Properties:
  java.version = 17.0.1
  java.vm.name = OpenJDK 64-Bit Server VM
  java.vm.specification.version = 17
  java.runtime.name = OpenJDK Runtime Environment
  java.runtime.version = 17.0.1+12-LTS
  java.specification.version = 17
  os.arch = aarch64
  os.name = Mac OS X

JMusicBot Information:
  Version = 0.3.6
  Owner = 723423425447592036
  Prefix = !
  AltPrefix = .
  MaxSeconds = 0
  NPImages = false
  SongInStatus = false
  StayInChannel = true
  UseEval = false
  UpdateAlerts = true

Dependency Information:
  JDA Version = 4.3.0_324
  JDA-Utilities Version = 3.0.5
  Lavaplayer Version = 1.3.78

Runtime Information:
  Total Memory = 68
  Used Memory = 47

Discord Information:
  ID = 888864354445951008
  Guilds = 2
  Users = 4


### Additional Info

_No response_

### Checklist

- [X] I have looked for information about this [within the documentation](https://jmusicbot.com/)
- [X] I have searched for similar issues [on the issues page](https://github.com/jagrosh/MusicBot/issues?q=is%3Aissue)
- [X] I am running the latest version of the bot: ![Release](https://img.shields.io/github/release/jagrosh/MusicBot.svg)
jagrosh commented 2 years ago

Please try running on an older java version, and please provide the console output when you run the command.

HandsomeHarry commented 2 years ago

I tried other JDKs but only OpenJDK 16 and 17 has a M1 version. Here's the debug log from the console:

Warning: the fonts "Times" and "Times" are not available for the Java logical font "Serif", which may have unexpected appearance or behavior. Re-enable the "Times" font to remove this warning.
[21:54:03] [INFO] [Startup]: Loaded config from /Users/harryyu/Servers/MusicBot/config.txt
[21:54:03] [INFO] [JDA]: Login Successful!
[21:54:03] [INFO] [WebSocketClient]: Connected to WebSocket
[21:54:04] [INFO] [JDA]: Finished Loading!
[21:56:40] [INFO] [NativeLibraryLoader]: Native library libmpg123-0: loading with filter com.sedmelluq.discord.lavaplayer.natives.ConnectorNativeLibLoader$$Lambda$410/0x00000003004a4a30@13e136fe
[21:56:40] [INFO] [NativeLibraryLoader]: Native library connector: loading with filter null
[21:56:40] [ERROR] [NativeLibraryLoader]: Native library connector: loading failed.
java.lang.UnsatisfiedLinkError: /private/var/folders/87/8k23bbsx7png9hz51np7p65m0000gn/T/lava-jni-natives/1641265000321/libconnector.dylib: dlopen(/private/var/folders/87/8k23bbsx7png9hz51np7p65m0000gn/T/lava-jni-natives/1641265000321/libconnector.dylib, 0x0001): tried: '/private/var/folders/87/8k23bbsx7png9hz51np7p65m0000gn/T/lava-jni-natives/1641265000321/libconnector.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/lib/libconnector.dylib' (no such file)
    at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
    at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:383)
    at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:227)
    at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:169)
    at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2383)
    at java.base/java.lang.Runtime.load0(Runtime.java:746)
    at java.base/java.lang.System.load(System.java:1857)
    at com.sedmelluq.lava.common.natives.NativeLibraryLoader.loadFromFile(NativeLibraryLoader.java:118)
    at com.sedmelluq.lava.common.natives.NativeLibraryLoader.loadInternal(NativeLibraryLoader.java:110)
    at com.sedmelluq.lava.common.natives.NativeLibraryLoader.loadWithFailureCheck(NativeLibraryLoader.java:84)
    at com.sedmelluq.lava.common.natives.NativeLibraryLoader.load(NativeLibraryLoader.java:69)
    at com.sedmelluq.discord.lavaplayer.natives.ConnectorNativeLibLoader.loadConnectorLibrary(ConnectorNativeLibLoader.java:21)
    at com.sedmelluq.discord.lavaplayer.natives.opus.OpusDecoderLibrary.getInstance(OpusDecoderLibrary.java:13)
    at com.sedmelluq.discord.lavaplayer.natives.opus.OpusDecoder.<init>(OpusDecoder.java:20)
    at com.sedmelluq.discord.lavaplayer.container.common.OpusPacketRouter.initialiseDecoder(OpusPacketRouter.java:193)
    at com.sedmelluq.discord.lavaplayer.container.common.OpusPacketRouter.checkDecoderNecessity(OpusPacketRouter.java:177)
    at com.sedmelluq.discord.lavaplayer.container.common.OpusPacketRouter.process(OpusPacketRouter.java:93)
    at com.sedmelluq.discord.lavaplayer.container.matroska.MatroskaOpusTrackConsumer.consume(MatroskaOpusTrackConsumer.java:46)
    at com.sedmelluq.discord.lavaplayer.container.matroska.MatroskaStreamingFile.processFrameInBlock(MatroskaStreamingFile.java:371)
    at com.sedmelluq.discord.lavaplayer.container.matroska.MatroskaStreamingFile.parseClusterSimpleBlock(MatroskaStreamingFile.java:335)
    at com.sedmelluq.discord.lavaplayer.container.matroska.MatroskaStreamingFile.parseNextCluster(MatroskaStreamingFile.java:320)
    at com.sedmelluq.discord.lavaplayer.container.matroska.MatroskaStreamingFile.provideFrames(MatroskaStreamingFile.java:296)
    at com.sedmelluq.discord.lavaplayer.container.matroska.MatroskaAudioTrack.lambda$process$0(MatroskaAudioTrack.java:39)
    at com.sedmelluq.discord.lavaplayer.track.playback.LocalAudioTrackExecutor.executeProcessingLoop(LocalAudioTrackExecutor.java:275)
    at com.sedmelluq.discord.lavaplayer.track.playback.LocalAudioTrackExecutor.executeProcessingLoop(LocalAudioTrackExecutor.java:249)
    at com.sedmelluq.discord.lavaplayer.container.matroska.MatroskaAudioTrack.process(MatroskaAudioTrack.java:38)
    at com.sedmelluq.discord.lavaplayer.track.DelegatedAudioTrack.processDelegate(DelegatedAudioTrack.java:25)
    at com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioTrack.processStatic(YoutubeAudioTrack.java:57)
    at com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioTrack.process(YoutubeAudioTrack.java:49)
    at com.sedmelluq.discord.lavaplayer.track.playback.LocalAudioTrackExecutor.execute(LocalAudioTrackExecutor.java:104)
    at com.sedmelluq.discord.lavaplayer.player.DefaultAudioPlayerManager.lambda$executeTrack$1(DefaultAudioPlayerManager.java:348)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
    at java.base/java.lang.Thread.run(Thread.java:831)
[21:56:40] [ERROR] [LocalAudioTrackExecutor]: Error in playback of yKNxeF4KMsY
com.sedmelluq.discord.lavaplayer.tools.FriendlyException: Something went wrong when decoding the track.
    at com.sedmelluq.discord.lavaplayer.tools.ExceptionTools.wrapUnfriendlyExceptions(ExceptionTools.java:44)
    at com.sedmelluq.discord.lavaplayer.track.playback.LocalAudioTrackExecutor.executeProcessingLoop(LocalAudioTrackExecutor.java:293)
    at com.sedmelluq.discord.lavaplayer.track.playback.LocalAudioTrackExecutor.executeProcessingLoop(LocalAudioTrackExecutor.java:249)
    at com.sedmelluq.discord.lavaplayer.container.matroska.MatroskaAudioTrack.process(MatroskaAudioTrack.java:38)
    at com.sedmelluq.discord.lavaplayer.track.DelegatedAudioTrack.processDelegate(DelegatedAudioTrack.java:25)
    at com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioTrack.processStatic(YoutubeAudioTrack.java:57)
    at com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioTrack.process(YoutubeAudioTrack.java:49)
    at com.sedmelluq.discord.lavaplayer.track.playback.LocalAudioTrackExecutor.execute(LocalAudioTrackExecutor.java:104)
    at com.sedmelluq.discord.lavaplayer.player.DefaultAudioPlayerManager.lambda$executeTrack$1(DefaultAudioPlayerManager.java:348)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
    at java.base/java.lang.Thread.run(Thread.java:831)
    Suppressed: com.sedmelluq.discord.lavaplayer.tools.exception.EnvironmentInformation: 
  lavaplayer.version: 1.3.78
  os.arch: aarch64
  os.name: Mac OS X
  os.version: 12.1
  java.vendor: Microsoft
  java.version: 16.0.2
  java.runtime.version: 16.0.2+7
  java.vm.version: 16.0.2+7
Caused by: java.lang.RuntimeException: java.lang.UnsatisfiedLinkError: /private/var/folders/87/8k23bbsx7png9hz51np7p65m0000gn/T/lava-jni-natives/1641265000321/libconnector.dylib: dlopen(/private/var/folders/87/8k23bbsx7png9hz51np7p65m0000gn/T/lava-jni-natives/1641265000321/libconnector.dylib, 0x0001): tried: '/private/var/folders/87/8k23bbsx7png9hz51np7p65m0000gn/T/lava-jni-natives/1641265000321/libconnector.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/lib/libconnector.dylib' (no such file)
    at com.sedmelluq.lava.common.natives.NativeLibraryLoader.loadWithFailureCheck(NativeLibraryLoader.java:88)
    at com.sedmelluq.lava.common.natives.NativeLibraryLoader.load(NativeLibraryLoader.java:69)
    at com.sedmelluq.discord.lavaplayer.natives.ConnectorNativeLibLoader.loadConnectorLibrary(ConnectorNativeLibLoader.java:21)
    at com.sedmelluq.discord.lavaplayer.natives.opus.OpusDecoderLibrary.getInstance(OpusDecoderLibrary.java:13)
    at com.sedmelluq.discord.lavaplayer.natives.opus.OpusDecoder.<init>(OpusDecoder.java:20)
    at com.sedmelluq.discord.lavaplayer.container.common.OpusPacketRouter.initialiseDecoder(OpusPacketRouter.java:193)
    at com.sedmelluq.discord.lavaplayer.container.common.OpusPacketRouter.checkDecoderNecessity(OpusPacketRouter.java:177)
    at com.sedmelluq.discord.lavaplayer.container.common.OpusPacketRouter.process(OpusPacketRouter.java:93)
    at com.sedmelluq.discord.lavaplayer.container.matroska.MatroskaOpusTrackConsumer.consume(MatroskaOpusTrackConsumer.java:46)
    at com.sedmelluq.discord.lavaplayer.container.matroska.MatroskaStreamingFile.processFrameInBlock(MatroskaStreamingFile.java:371)
    at com.sedmelluq.discord.lavaplayer.container.matroska.MatroskaStreamingFile.parseClusterSimpleBlock(MatroskaStreamingFile.java:335)
    at com.sedmelluq.discord.lavaplayer.container.matroska.MatroskaStreamingFile.parseNextCluster(MatroskaStreamingFile.java:320)
    at com.sedmelluq.discord.lavaplayer.container.matroska.MatroskaStreamingFile.provideFrames(MatroskaStreamingFile.java:296)
    at com.sedmelluq.discord.lavaplayer.container.matroska.MatroskaAudioTrack.lambda$process$0(MatroskaAudioTrack.java:39)
    at com.sedmelluq.discord.lavaplayer.track.playback.LocalAudioTrackExecutor.executeProcessingLoop(LocalAudioTrackExecutor.java:275)
    ... 10 common frames omitted
Caused by: java.lang.UnsatisfiedLinkError: /private/var/folders/87/8k23bbsx7png9hz51np7p65m0000gn/T/lava-jni-natives/1641265000321/libconnector.dylib: dlopen(/private/var/folders/87/8k23bbsx7png9hz51np7p65m0000gn/T/lava-jni-natives/1641265000321/libconnector.dylib, 0x0001): tried: '/private/var/folders/87/8k23bbsx7png9hz51np7p65m0000gn/T/lava-jni-natives/1641265000321/libconnector.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/lib/libconnector.dylib' (no such file)
    at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
    at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:383)
    at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:227)
    at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:169)
    at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2383)
    at java.base/java.lang.Runtime.load0(Runtime.java:746)
    at java.base/java.lang.System.load(System.java:1857)
    at com.sedmelluq.lava.common.natives.NativeLibraryLoader.loadFromFile(NativeLibraryLoader.java:118)
    at com.sedmelluq.lava.common.natives.NativeLibraryLoader.loadInternal(NativeLibraryLoader.java:110)
    at com.sedmelluq.lava.common.natives.NativeLibraryLoader.loadWithFailureCheck(NativeLibraryLoader.java:84)
    ... 24 common frames omitted
[21:56:41] [WARN] [NativeResourceHolder]: Should have been closed before finalization (com.sedmelluq.discord.lavaplayer.natives.opus.OpusDecoder).
Sanduhr32 commented 2 years ago

Lavaplayers libraries for the apple ecosystem are only compatible to machines running on x86 processors. ARM based systems like M1's are not supported (yet).

(mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))

Why is a native binary required?

It's faster & more efficient running a native binary, that decodes the audio, changes the volume & encodes it again.

aikaterna commented 2 years ago

Alternatively if you install an intel build of Java instead of an M1 version, Rosetta2 will translate it in-place and it will utilize the built in Mac x86-64 natives.