mukulhase / WebWhatsapp-Wrapper

An API for sending and receiving messages over web.whatsapp [Working as of 18th May 2018]
https://webwhatsapi.readthedocs.io/en/latest/
MIT License
2.02k stars 796 forks source link

Error in getUnreadMessages - Accessing TypedArray data over Xrays is slow #1095

Open roigreenberg opened 2 years ago

roigreenberg commented 2 years ago

Hi. I encounter a new issue, and I'm not sure how to solve it:

  File "groups_bot/load_driver.py", line 84, in run
    for contact in await driver.get_unread(include_notifications=True):
  File "/app/webwhatsapi/async_driver.py", line 107, in get_unread
    return await self._run_async(self._driver.get_unread,
  File "/app/webwhatsapi/async_driver.py", line 41, in _run_async
    return await result if isinstance(result, Awaitable) else result
  File "/app/webwhatsapi/__init__.py", line 400, in get_unread
    raw_message_groups = self.wapi_functions.getUnreadMessages(include_me, include_notifications, use_unread_count)
  File "/app/webwhatsapi/wapi_js_wrapper.py", line 157, in __call__
    raise JsException("Error in function {0} ({1}). Command: {2}".format(self.function_name, e.msg, command))
webwhatsapi.wapi_js_wrapper.JsException: Error in function getUnreadMessages (Error: Accessing TypedArray data over Xrays is slow, and forbidden in order to encourage performant code. To copy TypedArrays across origin boundaries, consider using Components.utils.cloneInto().). Command: return WAPI.getUnreadMessages(false,true,false, arguments[0])

Does anyone encounter this? any solution?

dekkardnexus5 commented 2 years ago

Same error, using WhatsApp Beta Multidevice:

Error in function getAllMessagesInChat (Error: Accessing TypedArray data over Xrays is slow, and forbidden in order to encourage performant code. To copy TypedArrays across origin boundaries, consider using Components.utils.cloneInto().)

dekkardnexus5 commented 2 years ago

on your wapi.js file, change the function below:

window.WAPI.processMessageObj = function (messageObj, includeMe, includeNotifications) { if (messageObj.isNotification) { if (includeNotifications){ ret = WAPI._serializeMessageObj(messageObj); delete ret.waveform delete ret.mediaData.waveform return ret }else{ return; } // System message // (i.e. "Messages you send to this chat and calls are now secured with end-to-end encryption...") } else if (messageObj.id.fromMe === false || includeMe) { ret = WAPI._serializeMessageObj(messageObj); delete ret.waveform delete ret.mediaData.waveform return ret } return; };

angmon73 commented 2 years ago

Hello to everyone. I Had this problem on november 2021 and I solved it changing the function processMessageObj as @dekkardnexus5 says. Unfortunately, starting from the last week I have the same problem again, even though I am using the new code for the previous function. Any idea? I am using the multidevice beta version, while in november 2021 I was using the standard whatsapp version Thanks in advance

erm3nda commented 1 year ago

This happend to me in a instance with 5000 chats. Did not happend to me when having just 5 chats. I only had this problem processing voice messages, no prob with anything else in my case.

Edit: Now happening with just 5 chats, received message of type ptt. (voice message).

Edit: Now is working again with teh big account. TLDR: waveform is useless, but it needs to be present.

Slighty modified the suggested code to:

window.WAPI.processMessageObj = function(messageObj, includeMe, includeNotifications) {
    messageObj.__x_mediaData.waveform = undefined;
    messageObj.__x_waveform = undefined;

Seems that setting them to undefined works, instead of delete a property that may be "forcibly" asked for. I don't really know, but now all is working again.

Hope it helps.

erm3nda commented 4 months ago

This fix doesn't work for quoted messages, didn't find a fix and didn't try. Closing.