K-Res

解决jest的”too many open files, watch”问题(Mac OSX)

在对一个有一定规模的react前端项目执行jest单元测试时,遇到了如下问题:

node scripts/test.js –env=jsdom
2020-02-04 11:05 node9117 FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2020-02-04 11:05 node9117 FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2020-02-04 11:05 node9117 FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
events.js:174
throw er; // Unhandled ‘error’ event
^
Error: EMFILE: too many open files, watch
at FSEvent.FSWatcher._handle.onchange (internal/fs/watchers.js:123:28)
Emitted ‘error’ event at:
at FSEvent.FSWatcher._handle.onchange (internal/fs/watchers.js:129:12)
npm ERR! Test failed. See above for more details.

错误信息
Continue reading…

解决Android NDK编译FFmpeg 4.2.2的x86 cpu版时的问题

老规矩,编译环境:Win10 1903,WSL ubuntu,ndk r20b,FFmpeg 4.2.2,首先分享下编译脚本:

#!/bin/bash
make clean

export NDK=/home/kres/android-ndk-r20b
TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/linux-x86_64/
API=21

function build_android
{
	echo "Compiling FFmpeg for $CPU"
	./configure \
		--prefix=$PREFIX \
		--enable-neon \
		--enable-hwaccels \
		--enable-gpl \
		--enable-postproc \
		--enable-shared \
		--enable-jni \
		--enable-mediacodec \
		--disable-decoders \
		    --enable-decoder=h264_mediacodec \
		    --enable-decoder=vp9 \
		    --enable-decoder=h264 \
		    --enable-decoder=mpeg4 \
		    --enable-decoder=aac \
		    --enable-decoder=aac_latm \
		    --enable-decoder=mjpeg \
		    --enable-decoder=png \
		    --enable-decoder=mpeg4_mediacodec \
		--disable-encoders \
		    --enable-encoder=vp9_vaapi --enable-encoder=h264_nvenc --enable-encoder=h264_v4l2m2m --enable-encoder=hevc_nvenc \
		--disable-demuxers \
		    --enable-demuxer=rtsp --enable-demuxer=rtp --enable-demuxer=flv --enable-demuxer=h264 \
		--disable-muxers \
		    --enable-muxer=rtsp --enable-muxer=rtp --enable-muxer=flv --enable-muxer=h264 \
		--disable-parsers \
		    --enable-parser=mpeg4video --enable-parser=aac --enable-parser=h264 --enable-parser=vp9 \
		--disable-protocols \
		    --enable-protocol=rtmp --enable-protocol=rtp --enable-protocol=tcp --enable-protocol=udp \
		--disable-bsfs \
		--disable-indevs --enable-indev=v4l2 \
		--disable-outdevs \
		--disable-filters \
		--disable-postproc \
		--disable-static \
		--disable-doc \
		--disable-ffmpeg \
		--disable-ffplay \
		--disable-ffprobe \
		--enable-avdevice \
		--disable-doc \
		--disable-symver \
		--cross-prefix=$CROSS_PREFIX \
		--target-os=android \
		--arch=$ARCH \
		--cpu=$CPU \
		--cc=$CC \
		--cxx=$CXX \
		--enable-cross-compile \
		--sysroot=$SYSROOT \
		--extra-cflags="-Os -fpic $OPTIMIZE_CFLAGS" \
		--extra-ldflags="$ADDI_LDFLAGS" \
		$ADDITIONAL_CONFIGURE_FLAG

		make clean
		make -j6
		make install
		echo "The Compilation of FFmpeg for $CPU is completed"

}
	#armv8-a
	ARCH=arm64
	CPU=armv8-a
	CC=$TOOLCHAIN/bin/aarch64-linux-android$API-clang
	CXX=$TOOLCHAIN/bin/aarch64-linux-android$API-clang++
	SYSROOT=$NDK/toolchains/llvm/prebuilt/linux-x86_64/sysroot
	CROSS_PREFIX=$TOOLCHAIN/bin/aarch64-linux-android-
	PREFIX=$(pwd)/android/$CPU
	OPTIMIZE_CFLAGS="-march=$CPU"
	build_android

	#armv7-a
	ARCH=arm
	CPU=armv7-a
	CC=$TOOLCHAIN/bin/armv7a-linux-androideabi$API-clang
	CXX=$TOOLCHAIN/bin/armv7a-linux-androideabi$API-clang++
	SYSROOT=$NDK/toolchains/llvm/prebuilt/linux-x86_64/sysroot
	CROSS_PREFIX=$TOOLCHAIN/bin/arm-linux-androideabi-
	PREFIX=$(pwd)/android/$CPU
	OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=vfp -marm -march=$CPU "
	build_android

	#x86
	ARCH=x86
	CPU=x86
	CC=$TOOLCHAIN/bin/i686-linux-android$API-clang
	CXX=$TOOLCHAIN/bin/i686-linux-android$API-clang++
	SYSROOT=$NDK/toolchains/llvm/prebuilt/linux-x86_64/sysroot
	CROSS_PREFIX=$TOOLCHAIN/bin/i686-linux-android-
	PREFIX=$(pwd)/android/$CPU
	OPTIMIZE_CFLAGS="-march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32"
	build_android

	#x86_64
	ARCH=x86_64
	CPU=x86-64
	CC=$TOOLCHAIN/bin/x86_64-linux-android$API-clang
	CXX=$TOOLCHAIN/bin/x86_64-linux-android$API-clang++
	SYSROOT=$NDK/toolchains/llvm/prebuilt/linux-x86_64/sysroot
	CROSS_PREFIX=$TOOLCHAIN/bin/x86_64-linux-android-
	PREFIX=$(pwd)/android/$CPU
	OPTIMIZE_CFLAGS="-march=$CPU -msse4.2 -mpopcnt -m64 -mtune=intel"
	build_android

Continue reading…

关于OpenWrt的log level问题(k2p)

最近在调试k2p官改( V2.0D )的ipv6时,发现怎么都看不到pppoe拨号时的详细信息,无奈之下发现了pppd的写文件log的方式,修改/etc/config/network中的wan接口(或对应uci设置方式):

config interface ‘wan’
option ifname ‘eth1.2’
option peerdns ‘1’
option ignore ‘1’
option dns_opt ‘0’
option pppoe_dns_mode ‘0’
option dhcp_dns_mode ‘0’
option macoperate ‘1’
option DiaMode ‘0’
option mtu ‘1500’
option ipv6 ‘1’
option pppd_options ‘debug logfile /var/log/ppp.log’
option status ‘up’
option proto ‘dhcp’
option ignore_mtu_change_pppoe ‘0’

加入 option pppd_options ‘debug logfile /var/log/ppp.log’ 这行,从而让pppd的调试信息输出到单独指定的日志文件/var/log/ppp.log中,这样便可看到pppd拨号时的详细log了。但是,之前的y1s同样是OpenWrt系统,却不需要写文件的方式,直接加上debug这个option就可以了,后来一通搜索后发现了原来是系统的log level设置所致:

Continue reading…

Wireshark拦截并分析https协议数据包(浏览器和Java程序)

https数据包拦截解析这个事之前也做过,不过是借助一个叫 fiddler 的中间代理软件实现的,https协议包其实是在http包之上加了一层ssl加密,所以直接用Wireshark的话只能看到加密后的TCP包内容,没法拿来分析http请求响应的内容。最近发现其实对于浏览器(Chrome,Firefox,其它未测),可以在Windows系统的环境变量中加入:

Continue reading…

解决Windows 10 1903下IPv6地址无法ping通问题

最近发现宽带IPv6通了, https://ipv6-test.com 测试可以正确检测出公网IPv6地址(检测到的是Win10 DHCP出来的临时地址),但是又发现ICMP一直不通,于是找了个也有v6地址的朋友帮忙测试一下,发现果然是ping不通,但是连接功能正常,于是想到是系统自带防火墙(Win10 1903,不确定其它版本是否也有此问题…)的问题,结果在防火墙设置里怎么都改不好,后来在microsoft官方上看到了这个: https://answers.microsoft.com/en-us/windows/forum/windows_10-networking/windows-10-firewall-filtering-icmp/527551d0-e477-4dd6-a0a0-eae724940ba3 ,于是照做:

netsh firewall set icmpsetting type=all mode=enable

完事后再测,ICMPv6就能通了,特此记录,以备后需。

由RapidJSON发现的成员函数与宏冲突问题

在使用RapidJson的时候,发现了一个之前很少注意到的问题:

F:\Projects\test\rapidjson-1.1.0\include\rapidjson\document.h(982,70): error : too few arguments provided to function-like macro invocation
if (a < static_cast(-std::numeric_limits::max())

乍一看好像不是很眼熟的错误提示,没看懂什么意思,惯例搜索引擎查,于是很快发现了这个: https://stackoverflow.com/questions/1394132/macro-and-member-function-conflict ,简单一看就反应过来了,原来是成员函数名(这里是max)和之前不知在哪定义过的同名max冲突了,编译器把本该作为成员函数调用的max当成作了替换,于是就出现了上面的错误。

Continue reading…

Windows 10 1903更新后RDP远程桌面黑屏卡死问题的临时解决方法

最近发现Win10推送了1903更新,迫不及待的装上后还没来得及体验各种变化就发现了一个令人恼火的bug,用远程桌面RDP连接1903版Win10时会出现黑屏卡死的问题!具体状态是RDP服务器是一台CPU比较旧的电脑(G1610 B75 GPU为核显),更新1903之前没任何问题,更新1903后用另一台1903的Win10自带的RDP客户端连接,第一次可以正常连接,断开再重连就必出现黑屏卡死的问题!(同时测试了Android、iOS、Mac OSX上的微软官方RDP客户端连,不会出现卡死的问题!)。搜索了下发现微软官方已经确认了这个问题: https://docs.microsoft.com/en-us/windows/release-information/status-windows-10-1903#534msgdesc ,而目前的状态还是 Investigating ,没有解决方法。

Continue reading…

Phabricator的arcanist在windows下执行arc feature(branch)异常问题的hack修正方法

首先,发现问题的arcanist版本如下:

arc version
arcanist d92fa96366c0ed50e4257508148aa75192d4fb1f (20 Jun 2019)
libphutil b416093386a225b1d9a2de906899b94cbf4babcb (8 Jul 2019)

错误现象为执行arc feature或arc branch时,提示:

[2019-07-20 13:30:05] ERROR 8: Undefined offset: 1 at [D:\phabricator\arcanist\src\repository\api\ArcanistGitAPI.php:1094]
arcanist(head=master, ref.master=d92fa96366c0), phutil(head=master, ref.master=b416093386a2)
  #0 ArcanistGitAPI::getAllBranches() called at [<arcanist>\src\workflow\ArcanistFeatureWorkflow.php:89]
  #1 ArcanistFeatureWorkflow::run() called at [<arcanist>\scripts\arcanist.php:394]
[2019-07-20 13:30:05] ERROR 8: Undefined offset: 2 at [D:\phabricator\arcanist\src\repository\api\ArcanistGitAPI.php:1094]
arcanist(head=master, ref.master=d92fa96366c0), phutil(head=master, ref.master=b416093386a2)
  #0 ArcanistGitAPI::getAllBranches() called at [<arcanist>\src\workflow\ArcanistFeatureWorkflow.php:89]
  #1 ArcanistFeatureWorkflow::run() called at [<arcanist>\scripts\arcanist.php:394]
[2019-07-20 13:30:05] ERROR 8: Undefined offset: 3 at [D:\phabricator\arcanist\src\repository\api\ArcanistGitAPI.php:1094]
arcanist(head=master, ref.master=d92fa96366c0), phutil(head=master, ref.master=b416093386a2)
  #0 ArcanistGitAPI::getAllBranches() called at [<arcanist>\src\workflow\ArcanistFeatureWorkflow.php:89]
  #1 ArcanistFeatureWorkflow::run() called at [<arcanist>\scripts\arcanist.php:394]
[2019-07-20 13:30:05] ERROR 8: Undefined offset: 4 at [D:\phabricator\arcanist\src\repository\api\ArcanistGitAPI.php:1094]
arcanist(head=master, ref.master=d92fa96366c0), phutil(head=master, ref.master=b416093386a2)
  #0 ArcanistGitAPI::getAllBranches() called at [<arcanist>\src\workflow\ArcanistFeatureWorkflow.php:89]
  #1 ArcanistFeatureWorkflow::run() called at [<arcanist>\scripts\arcanist.php:394]
[2019-07-20 13:30:05] ERROR 8: Undefined offset: 5 at [D:\phabricator\arcanist\src\repository\api\ArcanistGitAPI.php:1094]
arcanist(head=master, ref.master=d92fa96366c0), phutil(head=master, ref.master=b416093386a2)
  #0 ArcanistGitAPI::getAllBranches() called at [<arcanist>\src\workflow\ArcanistFeatureWorkflow.php:89]
  #1 ArcanistFeatureWorkflow::run() called at [<arcanist>\scripts\arcanist.php:394]
Usage Exception: No branches in this working copy.
Continue reading…

关于Vue.js项目build后部署到非站点根路径的问题

最近接触了下Vue.js框架,记录个build发布 production 版的部署位置问题:一般情况下,build出的dist直接放到Web服务器的根路径,如 http://www.xxx.com/ 访问就可以了,但如果想要放到子路径下,如 http://www.xxx.com/vue/ ,这时就会发现有资源加载报错了(通过vue-cli一般参数创建的项目, vue版本2.5.2)!

Continue reading…